Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TagWght = text.MustParseTag("wght") TagItal = text.MustParseTag("ital") TagLiga = text.MustParseTag("liga") TagTnum = text.MustParseTag("tnum") )
Tags of the OpenType variation axes and features with dedicated handling.
Functions ¶
func RegisterFaceSourceEntries ¶
func RegisterFaceSourceEntries(add func(*guigui.Context, *FaceSourceEntryAdder))
RegisterFaceSourceEntries registers add as a contributor to the fallback resolution stack. add adds its face source entries through the provided FaceSourceEntryAdder.
Types ¶
type Attributes ¶
type Attributes struct {
Size float64
Lang language.Tag
// Italic selects an italic face from the family's sources. When the
// family has no italic source, the text renders with a regular face.
Italic bool
// contains filtered or unexported fields
}
Attributes is a comparable set of text rendering attributes: size, language, italic face selection, and OpenType variation and feature settings. A face is resolved from Attributes together with a Family; the attributes alone do not identify a font.
func (Attributes) WithFeature ¶
func (a Attributes) WithFeature(tag text.Tag, value uint32) Attributes
WithFeature returns a with the OpenType feature tag set to value.
func (Attributes) WithVariation ¶
func (a Attributes) WithVariation(tag text.Tag, value float32) Attributes
WithVariation returns a with the OpenType variation axis tag set to value.
type Face ¶
type Face struct {
// contains filtered or unexported fields
}
Face is a resolved text face.
func NewFace ¶
func NewFace(context *guigui.Context, fnt *Family, attributes Attributes) Face
NewFace resolves the text face for attributes, rendering with fnt's face source entries followed by the registered fallback stack (unless fnt disables fallback). A nil fnt resolves using the registered fallback stack alone.
func NewFaceForTest ¶
func NewFaceForTest(face text.Face, attributes Attributes) Face
NewFaceForTest wraps face directly with attributes, bypassing font resolution. It is intended for tests that supply a specific text.Face.
func (Face) Attributes ¶
func (f Face) Attributes() Attributes
Attributes returns the render attributes f was resolved from.
func (Face) Family ¶
Family returns the Family f was resolved from, or nil when f was resolved without a family.
type FaceSourceEntry ¶
type FaceSourceEntry struct {
FaceSource *text.GoTextFaceSource
UnicodeRanges []UnicodeRange
}
FaceSourceEntry pairs a face source with the optional Unicode ranges it is limited to. An empty UnicodeRanges means the source is not range-limited.
func DefaultFaceSourceEntry ¶
func DefaultFaceSourceEntry() FaceSourceEntry
DefaultFaceSourceEntry returns the entry for the bundled default face.
type FaceSourceEntryAdder ¶
type FaceSourceEntryAdder struct {
// contains filtered or unexported fields
}
FaceSourceEntryAdder collects face source entries for the fallback resolution stack.
func (*FaceSourceEntryAdder) Add ¶
func (a *FaceSourceEntryAdder) Add(entry FaceSourceEntry)
Add adds entry to the fallback resolution stack at the adder's current priority, which is FaceSourceEntryPriorityNormal until changed by SetPriority.
func (*FaceSourceEntryAdder) SetPriority ¶
func (a *FaceSourceEntryAdder) SetPriority(priority FaceSourceEntryPriority)
SetPriority sets the priority applied to entries added afterward. A higher priority resolves earlier; entries of equal priority resolve in the order they are added.
type FaceSourceEntryPriority ¶
type FaceSourceEntryPriority int
FaceSourceEntryPriority orders entries in the fallback resolution stack; a higher value resolves earlier.
const ( FaceSourceEntryPriorityLow FaceSourceEntryPriority = 100 FaceSourceEntryPriorityNormal FaceSourceEntryPriority = 200 FaceSourceEntryPriorityHigh FaceSourceEntryPriority = 300 )
type Family ¶
type Family struct {
// contains filtered or unexported fields
}
Family is an immutable ordered list of FaceSourceEntry values, optionally followed by the registered fallback stack. Size, weight, language, and OpenType features are not part of a Family; they are applied at render time.
func NewFamily ¶
func NewFamily(entries []FaceSourceEntry, opts *FamilyOptions) *Family
NewFamily returns a Family that renders using entries. A nil opts is treated the same as the zero FamilyOptions.
type FamilyOptions ¶
type FamilyOptions struct {
// DisableFallback restricts rendering to the Family's own entries, skipping
// the fallback stack.
DisableFallback bool
}
FamilyOptions controls how a Family resolves glyphs.
type Feature ¶
type Feature struct {
// Tag identifies the feature, like 'liga'.
Tag text.Tag
// Value is the feature value handed to the font. For typical on/off
// features, 0 disables and 1 enables the feature.
Value uint32
}
Feature is an OpenType feature setting.
type UnicodeRange ¶
UnicodeRange is an inclusive range of code points.