From 1329aa51b605cb54ba9aae3a82a0a87b881fb7b3 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 13 Nov 2017 09:09:58 -0800 Subject: Updating server dependancies. (#7816) --- vendor/golang.org/x/image/font/sfnt/sfnt_test.go | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'vendor/golang.org/x/image/font/sfnt/sfnt_test.go') diff --git a/vendor/golang.org/x/image/font/sfnt/sfnt_test.go b/vendor/golang.org/x/image/font/sfnt/sfnt_test.go index 74de278dd..b9b66a786 100644 --- a/vendor/golang.org/x/image/font/sfnt/sfnt_test.go +++ b/vendor/golang.org/x/image/font/sfnt/sfnt_test.go @@ -214,6 +214,40 @@ func TestBounds(t *testing.T) { } } +func TestMetrics(t *testing.T) { + cmapFont, err := ioutil.ReadFile(filepath.FromSlash("../testdata/cmapTest.ttf")) + if err != nil { + t.Fatal(err) + } + testCases := map[string]struct { + font []byte + want font.Metrics + }{ + "goregular": {goregular.TTF, font.Metrics{Height: 2048, Ascent: 1935, Descent: 432}}, + // cmapTest.ttf has a non-zero lineGap. + "cmapTest": {cmapFont, font.Metrics{Height: 2232, Ascent: 1365, Descent: 0}}, + } + var b Buffer + for name, tc := range testCases { + f, err := Parse(tc.font) + if err != nil { + t.Errorf("name=%q: Parse: %v", name, err) + continue + } + ppem := fixed.Int26_6(f.UnitsPerEm()) + + got, err := f.Metrics(&b, ppem, font.HintingNone) + if err != nil { + t.Errorf("name=%q: Metrics: %v", name, err) + continue + } + if got != tc.want { + t.Errorf("name=%q: Metrics: got %v, want %v", name, got, tc.want) + continue + } + } +} + func TestGlyphAdvance(t *testing.T) { testCases := map[string][]struct { r rune -- cgit v1.2.3-1-g7c22