130 lines
2.4 KiB
Go
130 lines
2.4 KiB
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
_ "embed"
|
||
|
|
"log"
|
||
|
|
|
||
|
|
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
|
||
|
|
"golang.org/x/image/font"
|
||
|
|
"golang.org/x/image/font/opentype"
|
||
|
|
)
|
||
|
|
|
||
|
|
var (
|
||
|
|
DashFont *FontBase
|
||
|
|
|
||
|
|
//go:embed resources/fonts/bahnschrift.ttf
|
||
|
|
banschrift_ttf []byte
|
||
|
|
)
|
||
|
|
|
||
|
|
type FontBase struct {
|
||
|
|
PrincipleTimer font.Face
|
||
|
|
Title font.Face
|
||
|
|
Normal font.Face
|
||
|
|
Expiry font.Face
|
||
|
|
Debug font.Face
|
||
|
|
Celebration font.Face
|
||
|
|
Points font.Face
|
||
|
|
TeamBackgroundName font.Face
|
||
|
|
TeamBarName font.Face
|
||
|
|
}
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
|
||
|
|
const dpi = 72
|
||
|
|
DashFont = &FontBase{}
|
||
|
|
tt, err := opentype.ParseCollection(banschrift_ttf)
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
//fmt.Printf("%d\n", tt.NumFonts())
|
||
|
|
|
||
|
|
fnt, _ := tt.Font(0)
|
||
|
|
DashFont.PrincipleTimer, err = opentype.NewFace(fnt, &opentype.FaceOptions{
|
||
|
|
Size: 200,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Expiry, err = opentype.NewFace(fnt, &opentype.FaceOptions{
|
||
|
|
Size: 120,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Title, err = opentype.NewFace(fnt, &opentype.FaceOptions{
|
||
|
|
Size: 40,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Normal, err = opentype.NewFace(fnt, &opentype.FaceOptions{
|
||
|
|
Size: 20,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Points, err = opentype.NewFace(fnt, &opentype.FaceOptions{
|
||
|
|
Size: 15,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
p2tt, err := opentype.Parse(fonts.PressStart2P_ttf)
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Celebration, err = opentype.NewFace(p2tt, &opentype.FaceOptions{
|
||
|
|
Size: 72,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.TeamBackgroundName, err = opentype.NewFace(p2tt, &opentype.FaceOptions{
|
||
|
|
Size: 40,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.TeamBarName, err = opentype.NewFace(p2tt, &opentype.FaceOptions{
|
||
|
|
Size: 25,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
DashFont.Debug, err = opentype.NewFace(p2tt, &opentype.FaceOptions{
|
||
|
|
Size: 15,
|
||
|
|
DPI: dpi,
|
||
|
|
Hinting: font.HintingVertical,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|