move source files to src

This commit is contained in:
2023-07-08 12:20:34 +02:00
parent 6028c5770f
commit e5c2294f6c
43 changed files with 23 additions and 21 deletions
+39
View File
@@ -0,0 +1,39 @@
package konstructor
import (
"image/color"
"io/ioutil"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
type FontName string
type FontLayout struct {
Path string
DPI float64
Size float64
Color color.Color
SelectedColor color.Color
cachedFontFace font.Face
}
func (fl *FontLayout) GetFontFace(scale int) 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{
Size: fl.Size * float64(scale),
DPI: fl.DPI,
Hinting: font.HintingVertical,
})
fl.cachedFontFace = font_face
return font_face
}
func GetFontPath(name FontName) string {
return "assets/fonts/" + string(name) + ".ttf"
}