Skip to content

Build Tags

Taco de Wolff edited this page Jun 25, 2024 · 3 revisions

Canvas uses build tags to select optional replacement implementations. By default canvas will use native Go implementations, which usually have limited or very basic functionality, instead of external or CGO implementations. Below is a list of the different build tags:

  • harfbuzz will use the CGO binding for HarfBuzz, otherwise basic shaping is performed using the hmtx and kern tables. When using RTL or complex Asian scripts, it is recommended to enable HarfBuzz. Make sure to have HarfBuzz installed on the machine.
  • fribidi will use the CGO binding for GNU's FriBidi, otherwise no script itemization is performed. FriBidi needs to be installed on the machine.
  • latex will use the latex and dvisvgm binaries that need to be installed on the machine. Otherwise a Go implementation is used.
  • formats will enable the AVIF and WebP image formats for renderers.

Usage

To use build tags, add the -tags command line flag when using the go command, e.g.:

$ go install -tags harfbuzz,fribidi
# go build -tags harfbuzz,fribidi
$ go run -tags harfbuzz,fribidi main.go
Clone this wiki locally