@@ -139,11 +139,12 @@ func (o *Options) subPixelsY() (value uint32, halfQuantum, mask fixed.Int26_6) {
139139//
140140// For example, q == 4 leads to a bias of 8 and a mask of 0xfffffff0, or -16,
141141// because we want to round fractions of fixed.Int26_6 as:
142- // - 0 to 7 rounds to 0.
143- // - 8 to 23 rounds to 16.
144- // - 24 to 39 rounds to 32.
145- // - 40 to 55 rounds to 48.
146- // - 56 to 63 rounds to 64.
142+ // - 0 to 7 rounds to 0.
143+ // - 8 to 23 rounds to 16.
144+ // - 24 to 39 rounds to 32.
145+ // - 40 to 55 rounds to 48.
146+ // - 56 to 63 rounds to 64.
147+ //
147148// which means to add 8 and then bitwise-and with -16, in two's complement
148149// representation.
149150//
@@ -205,6 +206,7 @@ func NewFace(f *Font, opts *Options) IndexableFace {
205206 glyphCache : make ([]glyphCacheEntry , opts .glyphCacheEntries ()),
206207 stroke : fixed .I (opts .Stroke * 2 ),
207208 }
209+ a .r .UseNonZeroWinding = true // key for fonts
208210 a .subPixelX , a .subPixelBiasX , a .subPixelMaskX = opts .subPixelsX ()
209211 a .subPixelY , a .subPixelBiasY , a .subPixelMaskY = opts .subPixelsY ()
210212
@@ -388,13 +390,15 @@ func (a *face) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool) {
388390 }
389391 advance , ok = a .advanceCache [r ]
390392 if ok {
391- return
393+ idx := a .index (r )
394+ return advance , (idx != 0 )
392395 }
393- if err := a .glyphBuf .Load (a .f , a .scale , a .index (r ), a .hinting ); err != nil {
396+ idx := a .index (r )
397+ if err := a .glyphBuf .Load (a .f , a .scale , idx , a .hinting ); err != nil {
394398 return 0 , false
395399 }
396400 a .advanceCache [r ] = a .glyphBuf .AdvanceWidth
397- return a .glyphBuf .AdvanceWidth , true
401+ return a .glyphBuf .AdvanceWidth , ( idx != 0 )
398402}
399403
400404// rasterize returns the advance width, integer-pixel offset to render at, and
0 commit comments