For example, "Apple Color Emoji.ttc" has such a cmap. After this commit,
we can render its glyph for "U+0001F1E6 REGIONAL INDICATOR SYMBOL LETTER
A", which is clearly outside the Unicode BMP.
Note that this only lets us render black-and-white glyphs for out-of-BMP
runes. Rendering color glyphs (i.e. emoji) remains TODO.
Updates #45
The previous "the endpoints are inclusive" comment seems confusing. It's true
that the bounding box's max X equals the right-most coordinate, which suggests
<= instead of <, but that node's coordinate is itself exclusive. Consider the
solid 1-pixel square: (0, 0), (64, 0), (64, 64), (0, 64) in fixed.Point26_6
coordinates. The right-most coordinate is 64, and the bounding box's max X
equals 64, but rasterizing that square only affects sub-pixels up to but not
including 64.
Instead, it seems accurate to follow the fixed.Rectangle26_6 description, in
that the max values are exclusive.
This is in anticipation of caching glyph images. Quantization means that cache
hits are more likely.
Also make NewFace take an *Options instead of an Options.
benchmark old ns/op new ns/op delta
BenchmarkDrawString-4 96914389 88683659 -8.49%
benchmark old allocs new allocs delta
BenchmarkDrawString-4 32287 0 -100.00%
benchmark old bytes new bytes delta
BenchmarkDrawString-4 1929619 156 -99.99%
Its implementation is mostly a copy/paste of the freetype.Context type.
Follow-up commits will make it more efficient.
Also add an example that uses a truetype.Face and the
golang.org/x/exp/shiny/font package to draw text.