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:
@@ -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,
|
||||
|
Reference in New Issue
Block a user