text/v2: add a test to parse a collection file

This test failed at c985e9bdc6, but
fixed at 999c64cb78 accidentally.

This issue was introduced in 2.9 (maybe d19a774316),
so this doesn't have to be cherry-picked.
This commit is contained in:
Hajime Hoshi 2024-12-25 23:22:05 +09:00
parent 999c64cb78
commit 88a2c14a8e

View File

@ -448,3 +448,30 @@ func TestGoXFaceMetrics(t *testing.T) {
})
}
}
func TestCollection(t *testing.T) {
fontFilePaths := []string{
// If a font file doesn't exist, the test is skipped.
"/System/Library/Fonts/Helvetica.ttc",
}
for _, path := range fontFilePaths {
path := path
t.Run(path, func(t *testing.T) {
bs, err := os.ReadFile(path)
if err != nil {
t.Skipf("skipping: failed to read %s", path)
}
fs, err := text.NewGoTextFaceSourcesFromCollection(bytes.NewBuffer(bs))
if err != nil {
t.Fatal(err)
}
for _, f := range fs {
dst := ebiten.NewImage(16, 16)
text.Draw(dst, "a", &text.GoTextFace{
Source: f,
Size: 16,
}, nil)
}
})
}
}