38 lines
699 B
Go
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,
|
|
}
|
|
}
|