diff --git a/font/opentype/face_test.go b/font/opentype/face_test.go index 224b0f2..524a7f6 100644 --- a/font/opentype/face_test.go +++ b/font/opentype/face_test.go @@ -82,7 +82,7 @@ func TestFaceKern(t *testing.T) { } func TestFaceMetrics(t *testing.T) { - want := font.Metrics{Height: 768, Ascent: 726, Descent: 162} + want := font.Metrics{Height: 888, Ascent: 726, Descent: 162} got := regular.Metrics() if got != want { t.Fatalf("metrics failed. got=%#v. want=%#v", got, want) diff --git a/font/sfnt/sfnt.go b/font/sfnt/sfnt.go index cc4ceac..21a7927 100644 --- a/font/sfnt/sfnt.go +++ b/font/sfnt/sfnt.go @@ -1357,8 +1357,7 @@ func (f *Font) Kern(b *Buffer, x0, x1 GlyphIndex, ppem fixed.Int26_6, h font.Hin // Metrics returns the metrics of this font. func (f *Font) Metrics(b *Buffer, ppem fixed.Int26_6, h font.Hinting) (font.Metrics, error) { m := font.Metrics{ - // TODO: is adding lineGap correct? - Height: ppem + scale(fixed.Int26_6(f.cached.lineGap)*ppem, f.cached.unitsPerEm), + Height: scale(fixed.Int26_6(f.cached.ascent-f.cached.descent+f.cached.lineGap)*ppem, f.cached.unitsPerEm), Ascent: +scale(fixed.Int26_6(f.cached.ascent)*ppem, f.cached.unitsPerEm), Descent: -scale(fixed.Int26_6(f.cached.descent)*ppem, f.cached.unitsPerEm), } diff --git a/font/sfnt/sfnt_test.go b/font/sfnt/sfnt_test.go index b9b66a7..ca52fba 100644 --- a/font/sfnt/sfnt_test.go +++ b/font/sfnt/sfnt_test.go @@ -223,9 +223,9 @@ func TestMetrics(t *testing.T) { font []byte want font.Metrics }{ - "goregular": {goregular.TTF, font.Metrics{Height: 2048, Ascent: 1935, Descent: 432}}, + "goregular": {goregular.TTF, font.Metrics{Height: 2367, Ascent: 1935, Descent: 432}}, // cmapTest.ttf has a non-zero lineGap. - "cmapTest": {cmapFont, font.Metrics{Height: 2232, Ascent: 1365, Descent: 0}}, + "cmapTest": {cmapFont, font.Metrics{Height: 1549, Ascent: 1365, Descent: 0}}, } var b Buffer for name, tc := range testCases { @@ -574,11 +574,11 @@ func TestTrueTypeSegments(t *testing.T) { lineTo(136, 1297), lineTo(136, 68), }, { - // .null - // Empty glyph. + // .null + // Empty glyph. }, { - // nonmarkingreturn - // Empty glyph. + // nonmarkingreturn + // Empty glyph. }, { // zero // - contour #0