font

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValidFontName = errors.New("no valid font names found")
	ErrNoValidFontFace = errors.New("no valid font face found")
	ErrNoContainFace   = errors.New("font contains no valid faces")
	ErrEmptySubsetData = errors.New("no subset font data collected")
	ErrNoFontFileFound = errors.New("no font files found")
)

Functions

This section is empty.

Types

type CheckErrFn

type CheckErrFn func(error) bool

type ErrGetSFNTName

type ErrGetSFNTName struct {
	// contains filtered or unexported fields
}

func NewErrGetSFNTName

func NewErrGetSFNTName(faceIdx uint, nameIdx uint, c int) *ErrGetSFNTName

func (*ErrGetSFNTName) Error

func (e *ErrGetSFNTName) Error() string

type ErrMissCodepoints

type ErrMissCodepoints struct {
	// contains filtered or unexported fields
}

func NewErrMissCodepoints

func NewErrMissCodepoints(fontDesc *ass.FontDesc, source *FontFaceLocation, missingCodepoints []rune) *ErrMissCodepoints

func (*ErrMissCodepoints) Error

func (e *ErrMissCodepoints) Error() string

type ErrMissingFontFaceFound

type ErrMissingFontFaceFound ass.FontDesc

func NewErrMissingFontFaceFound

func NewErrMissingFontFaceFound(f ass.FontDesc) *ErrMissingFontFaceFound

func (*ErrMissingFontFaceFound) Error

func (e *ErrMissingFontFaceFound) Error() string

type ErrOpenFontFace

type ErrOpenFontFace struct {
	// contains filtered or unexported fields
}

func NewErrOpenFontFace

func NewErrOpenFontFace(p string, i uint, c int) *ErrOpenFontFace

func (*ErrOpenFontFace) Error

func (e *ErrOpenFontFace) Error() string

type ErrSubsetDataGet

type ErrSubsetDataGet struct {
	// contains filtered or unexported fields
}

func NewErrSubsetDataGet

func NewErrSubsetDataGet(s *FontFaceLocation, dataLength uint) *ErrSubsetDataGet

func (*ErrSubsetDataGet) Error

func (e *ErrSubsetDataGet) Error() string

type ErrSubsetFail

type ErrSubsetFail struct {
	// contains filtered or unexported fields
}

func NewErrSubsetFail

func NewErrSubsetFail(s *FontFaceLocation, codepointCount int) *ErrSubsetFail

func (*ErrSubsetFail) Error

func (e *ErrSubsetFail) Error() string

type ErrSubsetInputCreate

type ErrSubsetInputCreate struct {
	// contains filtered or unexported fields
}

func NewErrSubsetInputCreate

func NewErrSubsetInputCreate(s *FontFaceLocation) *ErrSubsetInputCreate

func (*ErrSubsetInputCreate) Error

func (e *ErrSubsetInputCreate) Error() string

type ErrUnSupportEncode

type ErrUnSupportEncode string

func NewErrUnSupportEncode

func NewErrUnSupportEncode(s string) *ErrUnSupportEncode

func (ErrUnSupportEncode) Error

func (e ErrUnSupportEncode) Error() string

type ErrUnsupportedID

type ErrUnsupportedID struct {
	// contains filtered or unexported fields
}

func (*ErrUnsupportedID) Error

func (e *ErrUnsupportedID) Error() string

type ErrUnsupportedPlatform

type ErrUnsupportedPlatform struct {
	// contains filtered or unexported fields
}

func (*ErrUnsupportedPlatform) Error

func (e *ErrUnsupportedPlatform) Error() string

type FontDataBase

type FontDataBase struct {
	BigMemoryMode bool
	// contains filtered or unexported fields
}

func NewFontDataBase

func NewFontDataBase(lib *FreeTypeLibrary) (*FontDataBase, error)

创建一个新的 FontDataBase 对象 如果传入 FreeTypeLibrary 为 nil,则会创建一个内部的 FreeTypeLibrary 实例 如果传入的 FreeTypeLibrary 不为 nil,则使用该实例 注意:如果传入的 FreeTypeLibrary 是内部创建的,需要调用 Close() 方法

func (*FontDataBase) BuildDB

func (db *FontDataBase) BuildDB(fontsDirs []string, withSystemFontPath bool, fn CheckErrFn) error

func (*FontDataBase) CheckGlyph

func (db *FontDataBase) CheckGlyph(fontData []byte, source *FontFaceLocation, fontSet ass.CodepointSet, fontDesc *ass.FontDesc) error

func (*FontDataBase) Close

func (fdb *FontDataBase) Close() error

关闭 FontDataBase 如果 FontDataBase 是内部创建的 FreeTypeLibrary 实例,则会关闭该实例 如果传入的 FreeTypeLibrary 是外部创建的,则不会关闭该实例

func (*FontDataBase) CreatSubfont

func (db *FontDataBase) CreatSubfont(subsetFontInfo *SubsetFontInfo, fontData []byte) ([]byte, error)

func (*FontDataBase) FindFont

func (db *FontDataBase) FindFont(fontDesc *ass.FontDesc, fontSet ass.CodepointSet) (*FontFaceLocation, int, *ErrMissingFontFaceFound)

func (*FontDataBase) LoadDB

func (db *FontDataBase) LoadDB(dbPath string) error

LoadDB 加载字体数据库

func (*FontDataBase) SaveDB

func (db *FontDataBase) SaveDB(dbPath string) error

func (*FontDataBase) Subset

func (db *FontDataBase) Subset(ap *ass.ASSParser, opts ...SubsetOption) (map[string][]byte, error)

读取 ass.ASSParser 中的所有字形,在 FontDataBase 中查找对应字体的路径,通过 CreatSubfont 子集化后返回子集化后的字体文件

type FontFaceInfo

type FontFaceInfo struct {
	Source   FontFaceLocation `json:"source"`   // 字体来源信息
	Name     FontName         `json:"name"`     // 字体名称信息
	Weight   uint             `json:"weight"`   // 字重
	Slant    uint             `json:"slant"`    // 倾斜角度
	Modified time.Time        `json:"modified"` // 字体文件最后修改时间
}

type FontFaceLocation

type FontFaceLocation struct {
	Path  string `json:"path"`  // 字体文件路径
	Index uint   `json:"index"` // 字体集合中的索引位置
}

type FontName

type FontName struct {
	FamilyNames []string `json:"family_names"` // 字体家族名称列表
	FullNames   []string `json:"full_names"`   // 字体完整名称列表
	PSNames     []string `json:"ps_names"`     // PostScript 名称列表
}

type FreeTypeLibrary

type FreeTypeLibrary struct {
	// contains filtered or unexported fields
}

func NewFreeTypeLibrary

func NewFreeTypeLibrary() (*FreeTypeLibrary, error)

初始化FreeType库

func (*FreeTypeLibrary) Close

func (lib *FreeTypeLibrary) Close() error

关闭FreeType库

func (*FreeTypeLibrary) ParseFont

func (lib *FreeTypeLibrary) ParseFont(fontPath string, fn func(error) bool) ([]FontFaceInfo, error)

解析字体文件

type InfoMsg

type InfoMsg string

func NewInfoMsg

func NewInfoMsg(format string, a ...any) *InfoMsg

func (InfoMsg) Error

func (i InfoMsg) Error() string

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type SubsetFontInfo

type SubsetFontInfo struct {
	FontsDesc  ass.FontDesc     // 字体描述列表
	Codepoints ass.CodepointSet // 码点集合
	Source     FontFaceLocation // 字体路径及索引
}

type SubsetOption

type SubsetOption func(*subsetConfig)

func WithCheckErr

func WithCheckErr(fn CheckErrFn) SubsetOption

func WithCheckGlyph

func WithCheckGlyph() SubsetOption

func WithConcurrent

func WithConcurrent() SubsetOption

type WarningMsg

type WarningMsg string

func NewWarningMsg

func NewWarningMsg(format string, a ...any) *WarningMsg

func (WarningMsg) Error

func (w WarningMsg) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL