53 lines
857 B
Go
53 lines
857 B
Go
package gg
|
|
|
|
import (
|
|
//"strings"
|
|
"golang.org/x/image/font"
|
|
"golang.org/x/image/font/opentype"
|
|
//"github.com/hajimehoshi/ebiten/v2/text"
|
|
//"github.com/hajimehoshi/ebiten/v2"
|
|
"io"
|
|
//"fmt"
|
|
)
|
|
|
|
//type FontOptions = font.Options
|
|
var (
|
|
FontHintingNone = font.HintingNone
|
|
)
|
|
type Face = font.Face
|
|
|
|
type FontTTF = opentype.Font
|
|
type FaceOptionsTTF = opentype.FaceOptions
|
|
type FaceTTF = opentype.Face
|
|
|
|
func MakeFaceFromTTF(
|
|
src io.ReaderAt,
|
|
opts *FaceOptionsTTF,
|
|
) (Face, error) {
|
|
fnt, err := ParseFontTTF(src)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
face, err := NewFaceTTF(fnt, opts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return face, nil
|
|
}
|
|
|
|
func ParseFontTTF(
|
|
src io.ReaderAt,
|
|
) (*FontTTF, error) {
|
|
return opentype.ParseReaderAt(src)
|
|
}
|
|
|
|
func NewFaceTTF(
|
|
fnt *FontTTF,
|
|
opts *FaceOptionsTTF,
|
|
) (Face, error) {
|
|
return opentype.NewFace(fnt, opts)
|
|
}
|
|
|
|
|