Skip to content

Commit

Permalink
text/v2: add a test to parse a collection file
Browse files Browse the repository at this point in the history
This test failed at c985e9b, but
fixed at 999c64c accidentally.

This issue was introduced in 2.9 (maybe d19a774),
so this doesn't have to be cherry-picked.
  • Loading branch information
hajimehoshi committed Dec 25, 2024
1 parent 999c64c commit 88a2c14
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions text/v2/text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}

0 comments on commit 88a2c14

Please sign in to comment.