-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtable_maxp_test.go
60 lines (52 loc) · 1.14 KB
/
table_maxp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.md', which is part of this source code package.
*/
package unitype
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMaxpTable(t *testing.T) {
// Run only this function in debugmode.
/*
common.SetLogger(common.NewConsoleLogger(common.LogLevelDebug))
defer func() {
common.SetLogger(common.NewConsoleLogger(common.LogLevelInfo))
}()
*/
testcases := []struct {
fontPath string
numGlyphs int
}{
{
"./testdata/FreeSans.ttf",
3726,
},
{
"./testdata/wts11.ttf",
14148,
},
{
"./testdata/roboto/Roboto-BoldItalic.ttf",
1294,
},
}
for _, tcase := range testcases {
t.Run(tcase.fontPath, func(t *testing.T) {
t.Logf("%s", tcase.fontPath)
f, err := os.Open(tcase.fontPath)
assert.Equal(t, nil, err)
defer f.Close()
br := newByteReader(f)
fnt, err := parseFont(br)
assert.Equal(t, nil, err)
require.NoError(t, err)
require.NotNil(t, fnt)
require.NotNil(t, fnt.maxp)
require.Equal(t, int(tcase.numGlyphs), int(fnt.maxp.numGlyphs))
})
}
}