Files
ordoor/internal/conv/font.go
Nick Thomas 0320743b30 Play around with menus some more
We now display the buttons in Main.mnu, but a lot remains unknown.
2019-10-09 00:41:41 +01:00

38 lines
699 B
Go

package conv
import (
"fmt"
"github.com/faiface/pixel"
"github.com/faiface/pixel/text"
"golang.org/x/image/colornames"
"golang.org/x/image/font/basicfont"
"ur.gs/ordoor/internal/fonts"
)
type Font struct {
Name string
Atlas *text.Atlas
Text *text.Text
}
func (f *Font) Output(to pixel.Target, m pixel.Matrix, format string, args ...interface{}) {
text := text.New(pixel.V(0.0, 0.0), f.Atlas)
text.Color = colornames.White
fmt.Fprintf(text, format, args...)
text.Draw(to, m)
}
func ConvertFont(font *fonts.Font) *Font {
// FIXME: actually use the pixel data in font
atlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
return &Font{
Name: font.Name,
Atlas: atlas,
}
}