-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgraphite_test.go
59 lines (51 loc) · 1.26 KB
/
graphite_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
package graphite
import (
"bytes"
"fmt"
"math/rand"
"testing"
testdata "github.com/benoitkugler/textlayout-testdata/graphite"
"github.com/benoitkugler/textlayout/fonts/truetype"
)
func loadGraphite(t *testing.T, filename string) *GraphiteFace {
f, err := testdata.Files.ReadFile(filename)
if err != nil {
t.Fatalf("can't open font file: %s", err)
}
ft, err := truetype.Parse(bytes.NewReader(f))
if err != nil {
t.Fatalf("can't parse truetype font %s: %s", filename, err)
}
font, err := LoadGraphite(ft)
if err != nil {
t.Fatalf("can't load graphite tables (font %s): %s", filename, err)
}
return font
}
func TestLoadGraphite(t *testing.T) {
filenames := []string{
"Annapurnarc2.ttf",
"Scheherazadegr.ttf",
"Awami_test.ttf",
"charis.ttf",
"Padauk.ttf",
"MagyarLinLibertineG.ttf",
"AwamiNastaliq-Regular.ttf",
"Awami_compressed_test.ttf",
}
for _, filename := range filenames {
font := loadGraphite(t, filename)
fmt.Println(len(font.glyphs))
// fmt.Println(font.glyphs[10].boxes
}
}
func TestCrash(t *testing.T) {
for range [100]int{} {
input := make([]byte, rand.Intn(1000))
rand.Read(input)
parseTableSilf(input, 5, 5)
parseTableSill(input)
parseTableFeat(input)
parseTableGlat(input, []uint32{1, 45, 78, 896, 4566})
}
}