34 lines
726 B
Go
34 lines
726 B
Go
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.dwysokinski.me/classic-games/tennis-game/internal/resource"
|
|
"golang.org/x/image/font"
|
|
"golang.org/x/image/font/opentype"
|
|
)
|
|
|
|
type fonts struct {
|
|
robotoRegularFont font.Face
|
|
}
|
|
|
|
func newFonts() (*fonts, error) {
|
|
robotoRegular, err := opentype.Parse(resource.FontRobotoRegular)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("couldn't parse roboto regular: %w", err)
|
|
}
|
|
|
|
robotoRegularFont, err := opentype.NewFace(robotoRegular, &opentype.FaceOptions{
|
|
Size: 24,
|
|
DPI: 72,
|
|
Hinting: font.HintingVertical,
|
|
})
|
|
if err != nil {
|
|
return nil, fmt.Errorf("couldn't construct roboto regular font.Face: %w", err)
|
|
}
|
|
|
|
return &fonts{
|
|
robotoRegularFont: robotoRegularFont,
|
|
}, nil
|
|
}
|