package assets import ( "embed" "log" "golang.org/x/image/font" "golang.org/x/image/font/opentype" ) //go:embed * var FontFiles embed.FS var fontFace font.Face func LoadFontFace(fileName string, size float64) font.Face { fontBytes, err := FontFiles.ReadFile(fileName) if err != nil { log.Fatal(err) } tt, err := opentype.Parse(fontBytes) if err != nil { log.Fatal(err) } const dpi = 144 fontFace, err = opentype.NewFace(tt, &opentype.FaceOptions{ Size: size, DPI: dpi, Hinting: font.HintingNone, }) if err != nil { log.Fatal(err) } return fontFace }