gg/text.go

52 lines
776 B
Go
Raw Normal View History

2024-01-13 18:17:34 +03:00
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
2024-05-28 11:24:12 +03:00
type FontTTF = opentype.Font
type FaceOptionsTTF = opentype.FaceOptions
type FaceTTF = opentype.Face
2024-01-13 18:17:34 +03:00
2024-05-28 11:24:12 +03:00
func MakeFaceFromTTF(
src io.ReaderAt,
opts *FaceOptionsTTF,
) (Face, error) {
fnt, err := ParseFontTTF(src)
2024-01-13 18:17:34 +03:00
if err != nil {
return nil, err
}
2024-05-28 11:24:12 +03:00
face, err := NewFaceTTF(fnt, opts)
2024-01-13 18:17:34 +03:00
if err != nil {
return nil, err
}
return face, nil
}
2024-05-28 11:24:12 +03:00
func ParseFontTTF(
src io.ReaderAt,
) (*FontTTF, error) {
2024-01-13 18:17:34 +03:00
return opentype.ParseReaderAt(src)
}
2024-05-28 11:24:12 +03:00
func NewFaceTTF(
fnt *FontTTF,
opts *FaceOptionsTTF,
) (Face, error) {
2024-01-13 18:17:34 +03:00
return opentype.NewFace(fnt, opts)
}