aboutsummaryrefslogtreecommitdiff
path: root/go/font
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-12-28 11:34:53 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:59 +0100
commitd7bac40f11fc18121ca3d26175fb85f187a6f24c (patch)
tree0cfd498fa94fdcef079761d04768796f7d8e3ea4 /go/font
parent660c175c66c5ba6af55c1c86a59d49736c191115 (diff)
downloadmuhqs-game-d7bac40f11fc18121ca3d26175fb85f187a6f24c.tar.gz
muhqs-game-d7bac40f11fc18121ca3d26175fb85f187a6f24c.zip
migrate to ebiten/v2/text/v2
Diffstat (limited to 'go/font')
-rw-r--r--go/font/font.go37
1 files changed, 17 insertions, 20 deletions
diff --git a/go/font/font.go b/go/font/font.go
index ae75cf8d..e594c39f 100644
--- a/go/font/font.go
+++ b/go/font/font.go
@@ -1,38 +1,35 @@
package font
import (
+ "bytes"
"log"
- "golang.org/x/image/font"
"golang.org/x/image/font/gofont/goregular"
- "golang.org/x/image/font/opentype"
+
+ "github.com/hajimehoshi/ebiten/v2/text/v2"
)
-var Font24 font.Face
-var Font18 font.Face
-var Font12 font.Face
+var fontSource *text.GoTextFaceSource
+var Font24 *text.GoTextFace
+var Font18 *text.GoTextFace
+var Font12 *text.GoTextFace
func InitFont() {
- tt, err := opentype.Parse(goregular.TTF)
+ fontSource, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF))
if err != nil {
log.Fatal(err)
}
- opts := &opentype.FaceOptions{Size: 24, DPI: 72}
- Font24, err = opentype.NewFace(tt, opts)
- if err != nil {
- log.Fatal(err)
+ Font24 = &text.GoTextFace{
+ Source: fontSource,
+ Size: 24,
}
-
- opts = &opentype.FaceOptions{Size: 18, DPI: 72}
- Font18, err = opentype.NewFace(tt, opts)
- if err != nil {
- log.Fatal(err)
+ Font18 = &text.GoTextFace{
+ Source: fontSource,
+ Size: 18,
}
-
- opts = &opentype.FaceOptions{Size: 12, DPI: 72}
- Font12, err = opentype.NewFace(tt, opts)
- if err != nil {
- log.Fatal(err)
+ Font12 = &text.GoTextFace{
+ Source: fontSource,
+ Size: 12,
}
}