move GetFontFace into FontLayout struct

This commit is contained in:
2023-07-05 22:55:37 +02:00
parent 607cf0d44f
commit 41a32a8fe5
4 changed files with 20 additions and 17 deletions

View File

@@ -1,6 +1,12 @@
package entity
import "image/color"
import (
"image/color"
"io/ioutil"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
type FontLayout struct {
Path string
@@ -9,3 +15,14 @@ type FontLayout struct {
Color color.Color
SelectedColor color.Color
}
func (fl *FontLayout) GetFontFace() font.Face {
file, _ := ioutil.ReadFile(fl.Path)
tt, _ := opentype.Parse(file)
face, _ := opentype.NewFace(tt, &opentype.FaceOptions{
Size: fl.DPI,
DPI: fl.Size,
Hinting: font.HintingVertical,
})
return face
}