refactoring finished

This commit is contained in:
Dmitry Sergeev
2026-09-17 20:42:38 +03:00
parent de4dfcf101
commit e30cb7a168
11 changed files with 92 additions and 48 deletions
+12 -2
View File
@@ -33,9 +33,19 @@ func LoadFace(path string, size float64) (font.Face, error) {
if err != nil {
return nil, fmt.Errorf("text: %w", err)
}
face, err := NewFace(data, size)
if err != nil {
return nil, fmt.Errorf("text: load %s: %w", path, err)
}
return face, nil
}
// NewFace parses TTF/OTF data and builds a render-ready face at the given
// pixel size (DPI 72, full hinting for crisp video text).
func NewFace(data []byte, size float64) (font.Face, error) {
f, err := opentype.Parse(data)
if err != nil {
return nil, fmt.Errorf("text: parse %s: %w", path, err)
return nil, fmt.Errorf("parse font: %w", err)
}
face, err := opentype.NewFace(f, &opentype.FaceOptions{
Size: size,
@@ -43,7 +53,7 @@ func LoadFace(path string, size float64) (font.Face, error) {
Hinting: font.HintingFull,
})
if err != nil {
return nil, fmt.Errorf("text: face %s: %w", path, err)
return nil, fmt.Errorf("create font face: %w", err)
}
return face, nil
}