Make a start on font rendering

I was hopeful I could use ebiten/text, but font.Face doesn't seem set
up for fixed-colour fonts.
This commit is contained in:
2020-03-30 00:15:19 +01:00
parent 27fbccdc5f
commit b5a722eef0
10 changed files with 334 additions and 33 deletions

View File

@@ -8,8 +8,9 @@ import (
type Menu struct {
assets *AssetStore
obj *Object // TODO: handle multiple objects in the menu
raw *menus.Menu
fonts []*Font // TODO: place the fonts directly into the relevant records
obj *Object // TODO: handle multiple objects in the menu
raw *menus.Menu // TODO: remove raw
Name string
}
@@ -19,6 +20,11 @@ func (m *Menu) Records() []*menus.Record {
return m.raw.Records
}
// FIXME: don't expose this
func (m *Menu) Font(idx int) *Font {
return m.fonts[idx]
}
func (m *Menu) Images(start, count int) ([]*ebiten.Image, error) {
out := make([]*ebiten.Image, count)
@@ -70,6 +76,16 @@ func (a *AssetStore) Menu(name string) (*Menu, error) {
return nil, err
}
var fonts []*Font
for _, fontName := range raw.FontNames {
fnt, err := a.Font(fontName)
if err != nil {
return nil, err
}
fonts = append(fonts, fnt)
}
i18n, err := a.i18n()
if err != nil {
return nil, err
@@ -84,6 +100,7 @@ func (a *AssetStore) Menu(name string) (*Menu, error) {
menu := &Menu{
assets: a,
fonts: fonts,
obj: obj,
raw: raw,
Name: name,