diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-11-13 09:09:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 09:09:58 -0800 |
commit | 1329aa51b605cb54ba9aae3a82a0a87b881fb7b3 (patch) | |
tree | 93cbf354ab894a560fc2cef8ef685d681b4ff889 /vendor/golang.org/x/image/font/sfnt/sfnt_test.go | |
parent | 7304a61ef597970be3031b14e652fb3a4df44304 (diff) | |
download | chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.gz chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.bz2 chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.zip |
Updating server dependancies. (#7816)
Diffstat (limited to 'vendor/golang.org/x/image/font/sfnt/sfnt_test.go')
-rw-r--r-- | vendor/golang.org/x/image/font/sfnt/sfnt_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
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 |