Commit graph

15 commits

Author SHA1 Message Date
1d07a50459
Change import paths 2018-11-14 10:38:19 +01:00
Nigel Tao
f9531a3606 Add a face.Metrics method, and parse hhea ascent and descent.
A recent change added a Metrics method to the font.Face interface.
2016-03-24 11:05:48 +11:00
Nigel Tao
41fa49aa5b Update x/exp/shiny/font to x/image/font. 2015-09-01 15:49:46 +10:00
Nigel Tao
494079eb2b Cache the glyph index lookup.
benchmark                 old ns/op     new ns/op     delta
BenchmarkDrawString-8     8618239       8149527       -5.44%
2015-08-31 14:14:50 +10:00
Nigel Tao
03bdcc0fe1 Have face.Glyph return an advance width, not the new dot.
This tracks an upstream change in the x/exp/shiny/font package.
2015-08-31 11:34:42 +10:00
Nigel Tao
8a4428169d Make raster.Painter's max alpha 1<<16-1, not 1<<32-1.
This is more consistent with the standard library's image/color package.

The benchmarks didn't seem to change significantly.
2015-08-30 23:48:43 +10:00
Nigel Tao
3ba1c0f728 Rename Point and End slices to Points and Ends.
The slice Foos is plural; it refers to multiple elements. The element Foos[i]
is the i'th Foo.
2015-08-30 22:27:18 +10:00
Nigel Tao
3cc748686b Use fixed.Rectangle26_6 instead of truetype.Bounds.
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.
2015-08-30 22:06:37 +10:00
Nigel Tao
fe26067669 Cache glyph mask images.
benchmark                 old ns/op     new ns/op     delta
BenchmarkDrawString-4     88103151      14188817      -83.90%
2015-08-27 22:16:16 +10:00
Nigel Tao
62e59645ee Quantize sub-pixel glyph rendering.
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.
2015-08-25 22:34:31 +10:00
Nigel Tao
a021a5f23e Rename Kerning to Kern. 2015-08-24 16:17:16 +10:00
Nigel Tao
db77c6a161 Delete some unnecessary fixed.Int26_6 conversions. 2015-08-24 15:57:20 +10:00
Nigel Tao
24265d1c91 Implement GlyphBounds and GlyphAdvance. 2015-08-24 15:51:50 +10:00
Nigel Tao
9c46b87503 Make face.Glyph not allocate a new mask each time.
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%
2015-08-23 21:11:02 +10:00
Nigel Tao
6deea24143 Add a truetype.Face type.
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.
2015-08-22 14:46:12 +10:00