cachedFont
This commit is contained in:
@@ -14,9 +14,13 @@ type FontLayout struct {
|
||||
Size float64
|
||||
Color color.Color
|
||||
SelectedColor color.Color
|
||||
cachedFontFace font.Face
|
||||
}
|
||||
|
||||
func (fl *FontLayout) GetFontFace() font.Face {
|
||||
if fl.cachedFontFace != nil {
|
||||
return fl.cachedFontFace
|
||||
}
|
||||
file, _ := ioutil.ReadFile(fl.Path)
|
||||
true_type, _ := opentype.Parse(file)
|
||||
font_face, _ := opentype.NewFace(true_type, &opentype.FaceOptions{
|
||||
@@ -24,5 +28,6 @@ func (fl *FontLayout) GetFontFace() font.Face {
|
||||
DPI: fl.Size,
|
||||
Hinting: font.HintingVertical,
|
||||
})
|
||||
fl.cachedFontFace = font_face
|
||||
return font_face
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user