From 1f81822fe126b42ef255965773e447f0a48f938d Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 30 Oct 2013 07:50:48 +1100 Subject: [PATCH] freetype/truetype: recalculate 'phantom point 1' after rounding. R=bsiegert CC=golang-dev, remyoudompheng https://codereview.appspot.com/19090043 --- freetype/truetype/glyph.go | 7 ++++--- freetype/truetype/truetype_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/freetype/truetype/glyph.go b/freetype/truetype/glyph.go index 8dcb336..c6fc786 100644 --- a/freetype/truetype/glyph.go +++ b/freetype/truetype/glyph.go @@ -167,16 +167,17 @@ func (g *GlyphBuf) load(recursion int32, i Index, useMyMetrics bool) (err error) } // Drop the four phantom points. pp1x = g.Point[len(g.Point)-4].X - g.Point = g.Point[:len(g.Point)-4] if g.hinter != nil { - g.InFontUnits = g.InFontUnits[:len(g.InFontUnits)-4] - g.Unhinted = g.Unhinted[:len(g.Unhinted)-4] if dx := ((pp1x + 32) &^ 63) - pp1x; dx != 0 { for i := np0; i < len(g.Point); i++ { g.Point[i].X += dx } + pp1x = g.Point[len(g.Point)-4].X } + g.InFontUnits = g.InFontUnits[:len(g.InFontUnits)-4] + g.Unhinted = g.Unhinted[:len(g.Unhinted)-4] } + g.Point = g.Point[:len(g.Point)-4] if np0 != 0 { // The hinting program expects the []End values to be indexed relative // to the inner glyph, not the outer glyph, so we delay adding np0 until diff --git a/freetype/truetype/truetype_test.go b/freetype/truetype/truetype_test.go index d5ded68..5b37c1c 100644 --- a/freetype/truetype/truetype_test.go +++ b/freetype/truetype/truetype_test.go @@ -253,7 +253,7 @@ var scalingTestCases = []struct { }{ {"luxisr", 12, -1}, {"x-arial-bold", 11, 0}, - {"x-deja-vu-sans-oblique", 17, 229}, + {"x-deja-vu-sans-oblique", 17, 513}, {"x-droid-sans-japanese", 9, 0}, {"x-times-new-roman", 13, 0}, }