gg/text.go
2024-06-01 18:07:28 +05:00

51 lines
776 B
Go

package gg
import (
//"strings"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
"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)
}