Documentation
¶
Overview ¶
Package ot provides OpenType font table parsing.
Package ot provides OpenType font table parsing.
Index ¶
- Constants
- Variables
- func BuildLoca(offsets []uint32, useShort bool) []byte
- func ClearShaperCache()
- func GetGlyphName(glyph GlyphID) string
- func RemapCharString(cs []byte, globalMap, localMap map[int]int, ...) []byte
- func RemapComposite(data []byte, glyphMap map[GlyphID]GlyphID) []byte
- func Shape(font *Font, buf *Buffer, features []Feature) error
- type AlternateSubst
- type Anchor
- type AttachList
- type BaseArray
- type Buffer
- type BufferFlags
- type CFF
- type CaretValue
- type ChainContextPos
- type ChainContextSubst
- type ChainRule
- type CharStringInterpreter
- type ClassDef
- type Cmap
- type CmapIter
- type Codepoint
- type CompositeComponent
- type ContextPos
- type ContextRule
- type ContextSubst
- type Coverage
- type CursivePos
- type Direction
- type EntryExitRecord
- type Face
- func (f *Face) Ascender() int16
- func (f *Face) BBox() (xMin, yMin, xMax, yMax int16)
- func (f *Face) CapHeight() int16
- func (f *Face) Cmap() *Cmap
- func (f *Face) Descender() int16
- func (f *Face) FamilyName() string
- func (f *Face) GetHExtents() FontExtents
- func (f *Face) HorizontalAdvance(glyph GlyphID) float32
- func (f *Face) IsCFF() bool
- func (f *Face) IsFixedPitch() bool
- func (f *Face) IsItalic() bool
- func (f *Face) ItalicAngle() int32
- func (f *Face) LineGap() int16
- func (f *Face) PostscriptName() string
- func (f *Face) Upem() uint16
- func (f *Face) WeightClass() uint16
- func (f *Face) XHeight() int16
- type Feature
- type FeatureList
- type FeatureRecord
- type Font
- type FontDict
- type FontExtents
- type GDEF
- func (g *GDEF) GetAttachPoints(glyph GlyphID) []uint16
- func (g *GDEF) GetGlyphClass(glyph GlyphID) int
- func (g *GDEF) GetLigCaretCount(glyph GlyphID) int
- func (g *GDEF) GetLigCarets(glyph GlyphID) []CaretValue
- func (g *GDEF) GetMarkAttachClass(glyph GlyphID) int
- func (g *GDEF) HasAttachList() bool
- func (g *GDEF) HasGlyphClasses() bool
- func (g *GDEF) HasLigCaretList() bool
- func (g *GDEF) HasMarkAttachClasses() bool
- func (g *GDEF) HasMarkGlyphSets() bool
- func (g *GDEF) IsBaseGlyph(glyph GlyphID) bool
- func (g *GDEF) IsComponentGlyph(glyph GlyphID) bool
- func (g *GDEF) IsInMarkGlyphSet(glyph GlyphID, setIndex int) bool
- func (g *GDEF) IsLigatureGlyph(glyph GlyphID) bool
- func (g *GDEF) IsMarkGlyph(glyph GlyphID) bool
- func (g *GDEF) MarkGlyphSetCount() int
- func (g *GDEF) Version() (uint16, uint16)
- type GPOS
- func (g *GPOS) ApplyKerning(glyphs []GlyphID) []GlyphPosition
- func (g *GPOS) ApplyKerningWithGDEF(glyphs []GlyphID, gdef *GDEF) []GlyphPosition
- func (g *GPOS) ApplyLookup(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition)
- func (g *GPOS) ApplyLookupWithDirection(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition, ...)
- func (g *GPOS) ApplyLookupWithGDEF(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition, ...)
- func (g *GPOS) GetLookup(index int) *GPOSLookup
- func (g *GPOS) NumLookups() int
- func (g *GPOS) ParseFeatureList() (*FeatureList, error)
- type GPOSChainRule
- type GPOSContext
- type GPOSContextRule
- type GPOSLookup
- type GPOSLookupRecord
- type GPOSSubtable
- type GSUB
- func (g *GSUB) ApplyFeature(tag Tag, glyphs []GlyphID) []GlyphID
- func (g *GSUB) ApplyFeatureWithGDEF(tag Tag, glyphs []GlyphID, gdef *GDEF) []GlyphID
- func (g *GSUB) ApplyLookup(lookupIndex int, glyphs []GlyphID) []GlyphID
- func (g *GSUB) ApplyLookupReverse(lookupIndex int, glyphs []GlyphID) []GlyphID
- func (g *GSUB) ApplyLookupReverseWithGDEF(lookupIndex int, glyphs []GlyphID, gdef *GDEF) []GlyphID
- func (g *GSUB) ApplyLookupWithGDEF(lookupIndex int, glyphs []GlyphID, gdef *GDEF) []GlyphID
- func (g *GSUB) GetLookup(index int) *GSUBLookup
- func (g *GSUB) NumLookups() int
- func (g *GSUB) ParseFeatureList() (*FeatureList, error)
- type GSUBContext
- func (ctx *GSUBContext) DeleteGlyph()
- func (ctx *GSUBContext) Ligate(ligGlyph GlyphID, numGlyphs int)
- func (ctx *GSUBContext) NextGlyph(startIndex int) int
- func (ctx *GSUBContext) PrevGlyph(startIndex int) int
- func (ctx *GSUBContext) ReplaceGlyph(newGlyph GlyphID)
- func (ctx *GSUBContext) ReplaceGlyphs(newGlyphs []GlyphID)
- func (ctx *GSUBContext) ShouldSkipGlyph(index int) bool
- type GSUBLookup
- type GSUBSubtable
- type Glyf
- type GlyphData
- type GlyphExtents
- type GlyphID
- type GlyphInfo
- type GlyphPos
- type GlyphPosition
- type Head
- type Hhea
- type Hmtx
- type LigCaretList
- type LigGlyph
- type Ligature
- type LigatureArray
- type LigatureAttach
- type LigatureSubst
- type Loca
- type LongHorMetric
- type LookupRecord
- type MarkArray
- type MarkBasePos
- type MarkGlyphSetsDef
- type MarkLigPos
- func (m *MarkLigPos) Apply(ctx *GPOSContext) bool
- func (m *MarkLigPos) ApplyWithComponent(ctx *GPOSContext, componentIndex int) bool
- func (m *MarkLigPos) ClassCount() uint16
- func (m *MarkLigPos) LigatureArray() *LigatureArray
- func (m *MarkLigPos) LigatureCoverage() *Coverage
- func (m *MarkLigPos) MarkArray() *MarkArray
- func (m *MarkLigPos) MarkCoverage() *Coverage
- type MarkMarkPos
- type MarkRecord
- type MultipleSubst
- type Name
- type OS2
- type PairClassRecord
- type PairPos
- func (pp *PairPos) Apply(ctx *GPOSContext) bool
- func (pp *PairPos) Class1Count() uint16
- func (pp *PairPos) Class2Count() uint16
- func (pp *PairPos) ClassDef1() *ClassDef
- func (pp *PairPos) ClassDef2() *ClassDef
- func (pp *PairPos) ClassMatrix() [][]PairClassRecord
- func (pp *PairPos) Coverage() *Coverage
- func (pp *PairPos) Format() uint16
- func (pp *PairPos) PairSets() [][]PairValueRecord
- func (pp *PairPos) ValueFormat1() uint16
- func (pp *PairPos) ValueFormat2() uint16
- type PairValueRecord
- type Parser
- func (p *Parser) Bytes(n int) ([]byte, error)
- func (p *Parser) Data() []byte
- func (p *Parser) I16() (int16, error)
- func (p *Parser) I16At(off int) (int16, error)
- func (p *Parser) I32() (int32, error)
- func (p *Parser) Offset() int
- func (p *Parser) Remaining() int
- func (p *Parser) SetOffset(off int) error
- func (p *Parser) Skip(n int) error
- func (p *Parser) SubParser(off, length int) (*Parser, error)
- func (p *Parser) SubParserFromOffset(off int) (*Parser, error)
- func (p *Parser) Tag() (Tag, error)
- func (p *Parser) U8() (uint8, error)
- func (p *Parser) U16() (uint16, error)
- func (p *Parser) U16At(off int) (uint16, error)
- func (p *Parser) U32() (uint32, error)
- func (p *Parser) U32At(off int) (uint32, error)
- type Post
- type PrivateDict
- type ReverseChainSingleSubst
- type Shaper
- func (s *Shaper) Font() *Font
- func (s *Shaper) GDEF() *GDEF
- func (s *Shaper) GetDefaultFeatures() []Feature
- func (s *Shaper) HasGDEF() bool
- func (s *Shaper) HasGPOS() bool
- func (s *Shaper) HasGSUB() bool
- func (s *Shaper) HasHmtx() bool
- func (s *Shaper) SetDefaultFeatures(features []Feature)
- func (s *Shaper) Shape(buf *Buffer, features []Feature)
- func (s *Shaper) ShapeString(text string) ([]GlyphID, []GlyphPos)
- type SinglePos
- type SingleSubst
- type Tag
- type TopDict
- type ValueRecord
Constants ¶
const ( // FeatureGlobalStart indicates feature applies from buffer start. FeatureGlobalStart uint = 0 // FeatureGlobalEnd indicates feature applies to buffer end. FeatureGlobalEnd uint = ^uint(0) )
const ( GlyphClassUnclassified = 0 // Unclassified glyph GlyphClassBase = 1 // Base glyph (single character, spacing glyph) GlyphClassLigature = 2 // Ligature glyph (multiple characters, spacing glyph) GlyphClassMark = 3 // Mark glyph (non-spacing combining glyph) GlyphClassComponent = 4 // Component glyph (part of a ligature) )
GlyphClass constants for GDEF glyph classification.
const ( GPOSTypeSingle = 1 GPOSTypePair = 2 GPOSTypeCursive = 3 GPOSTypeMarkBase = 4 GPOSTypeMarkLig = 5 GPOSTypeMarkMark = 6 GPOSTypeContext = 7 GPOSTypeChainContext = 8 GPOSTypeExtension = 9 )
GPOS lookup types
const ( ValueFormatXPlacement = 0x0001 // Horizontal adjustment for placement ValueFormatYPlacement = 0x0002 // Vertical adjustment for placement ValueFormatXAdvance = 0x0004 // Horizontal adjustment for advance ValueFormatYAdvance = 0x0008 // Vertical adjustment for advance ValueFormatXPlaDevice = 0x0010 // Device table for horizontal placement ValueFormatYPlaDevice = 0x0020 // Device table for vertical placement ValueFormatXAdvDevice = 0x0040 // Device table for horizontal advance ValueFormatYAdvDevice = 0x0080 // Device table for vertical advance )
ValueFormat flags - determine which values are present in a ValueRecord
const ( // LookupFlagRightToLeft indicates right-to-left cursive attachment. LookupFlagRightToLeft = 0x0001 // LookupFlagIgnoreBaseGlyphs causes base glyphs to be skipped. LookupFlagIgnoreBaseGlyphs = 0x0002 // LookupFlagIgnoreLigatures causes ligature glyphs to be skipped. LookupFlagIgnoreLigatures = 0x0004 // LookupFlagIgnoreMarks causes mark glyphs to be skipped. LookupFlagIgnoreMarks = 0x0008 // LookupFlagUseMarkFilteringSet indicates that MarkFilteringSet is used. LookupFlagUseMarkFilteringSet = 0x0010 // LookupFlagMarkAttachTypeMask is the mask for mark attachment type filtering. LookupFlagMarkAttachTypeMask = 0xFF00 )
LookupFlag bit constants for GSUB/GPOS lookups.
const ( AttachTypeNone = 0 AttachTypeMark = 1 AttachTypeCursive = 2 )
AttachType constants for glyph attachment
const ( GSUBTypeSingle = 1 GSUBTypeMultiple = 2 GSUBTypeAlternate = 3 GSUBTypeLigature = 4 GSUBTypeContext = 5 GSUBTypeChainContext = 6 GSUBTypeExtension = 7 GSUBTypeReverseChainSingle = 8 )
GSUB lookup types
const NotCovered = ^uint32(0)
NotCovered is returned when a glyph is not in a coverage table.
Variables ¶
var ( TagKern = MakeTag('k', 'e', 'r', 'n') // Kerning TagMark = MakeTag('m', 'a', 'r', 'k') // Mark Positioning TagMkmk = MakeTag('m', 'k', 'm', 'k') // Mark-to-Mark Positioning )
Common GPOS feature tags
var ( TagLiga = MakeTag('l', 'i', 'g', 'a') // Standard Ligatures TagClig = MakeTag('c', 'l', 'i', 'g') // Contextual Ligatures TagDlig = MakeTag('d', 'l', 'i', 'g') // Discretionary Ligatures TagHlig = MakeTag('h', 'l', 'i', 'g') // Historical Ligatures TagCcmp = MakeTag('c', 'c', 'm', 'p') // Glyph Composition/Decomposition TagLocl = MakeTag('l', 'o', 'c', 'l') // Localized Forms TagRlig = MakeTag('r', 'l', 'i', 'g') // Required Ligatures TagSmcp = MakeTag('s', 'm', 'c', 'p') // Small Capitals TagCalt = MakeTag('c', 'a', 'l', 't') // Contextual Alternates )
Common feature tags
var ( ErrInvalidFont = errors.New("invalid font data") ErrTableNotFound = errors.New("table not found") ErrInvalidTable = errors.New("invalid table data") ErrInvalidOffset = errors.New("offset out of bounds") ErrInvalidFormat = errors.New("unsupported format") ErrInvalidFeature = errors.New("invalid feature string") )
Common errors
var ( TagCmap = MakeTag('c', 'm', 'a', 'p') TagHead = MakeTag('h', 'e', 'a', 'd') TagHhea = MakeTag('h', 'h', 'e', 'a') TagHmtx = MakeTag('h', 'm', 't', 'x') TagMaxp = MakeTag('m', 'a', 'x', 'p') TagName = MakeTag('n', 'a', 'm', 'e') TagOS2 = MakeTag('O', 'S', '/', '2') TagPost = MakeTag('p', 'o', 's', 't') TagGlyf = MakeTag('g', 'l', 'y', 'f') TagLoca = MakeTag('l', 'o', 'c', 'a') TagGDEF = MakeTag('G', 'D', 'E', 'F') TagGSUB = MakeTag('G', 'S', 'U', 'B') TagGPOS = MakeTag('G', 'P', 'O', 'S') TagCvt = MakeTag('c', 'v', 't', ' ') TagFpgm = MakeTag('f', 'p', 'g', 'm') TagPrep = MakeTag('p', 'r', 'e', 'p') TagGasp = MakeTag('g', 'a', 's', 'p') )
Common OpenType tags
var TagCFF = MakeTag('C', 'F', 'F', ' ')
TagCFF is the table tag for CFF data.
Functions ¶
func BuildLoca ¶
BuildLoca builds a loca table from glyph offsets. If useShort is true, uses 16-bit format (offsets must be even and < 131072).
func ClearShaperCache ¶
func ClearShaperCache()
ClearShaperCache clears the internal shaper cache. Call this if fonts are being released to allow garbage collection.
func GetGlyphName ¶
GetGlyphName returns a debug name for a glyph (just the ID as string).
func RemapCharString ¶
func RemapCharString(cs []byte, globalMap, localMap map[int]int, oldGlobalBias, oldLocalBias, newGlobalBias, newLocalBias int) []byte
RemapCharString rewrites a CharString with remapped subroutine numbers.
func RemapComposite ¶
RemapComposite creates a new composite glyph with remapped component IDs.
Types ¶
type AlternateSubst ¶
type AlternateSubst struct {
// contains filtered or unexported fields
}
AlternateSubst represents an Alternate Substitution subtable (1 -> 1 from set). It allows choosing one glyph from a set of alternatives.
func (*AlternateSubst) Apply ¶
func (a *AlternateSubst) Apply(ctx *GSUBContext) int
Apply applies the alternate substitution. By default, it selects the first alternative (index 0). Use ApplyWithIndex to select a specific alternative.
func (*AlternateSubst) ApplyWithIndex ¶
func (a *AlternateSubst) ApplyWithIndex(ctx *GSUBContext, altIndex int) int
ApplyWithIndex applies the alternate substitution with a specific alternate index. altIndex is 0-based (0 = first alternate, 1 = second, etc.)
func (*AlternateSubst) GetAlternates ¶
func (a *AlternateSubst) GetAlternates(glyph GlyphID) []GlyphID
GetAlternates returns the available alternates for a glyph. Returns nil if the glyph is not covered.
func (*AlternateSubst) Mapping ¶
func (a *AlternateSubst) Mapping() map[GlyphID][]GlyphID
Mapping returns the input->alternates mapping for glyph closure computation.
type Anchor ¶
type Anchor struct {
Format uint16
X int16 // X coordinate in design units
Y int16 // Y coordinate in design units
// Format 2 adds: anchorPoint (contour point index)
AnchorPoint uint16
}
Anchor represents an anchor point for mark positioning. It stores x,y coordinates in design units.
type AttachList ¶
type AttachList struct {
// contains filtered or unexported fields
}
AttachList contains attachment points for glyphs.
type BaseArray ¶
type BaseArray struct {
Rows int
ClassCount int
Anchors [][]*Anchor // [row][class] -> Anchor (may be nil)
}
BaseArray contains anchors for base glyphs, organized as a matrix. Rows correspond to base glyphs (in BaseCoverage order). Columns correspond to mark classes (0 to classCount-1).
type Buffer ¶
type Buffer struct {
Info []GlyphInfo
Pos []GlyphPos
Direction Direction
Flags BufferFlags
// Script and Language for shaping (optional, can be auto-detected)
Script Tag
Language Tag
}
Buffer holds a sequence of glyphs being shaped.
func (*Buffer) AddCodepoints ¶
AddCodepoints adds Unicode codepoints to the buffer.
func (*Buffer) GuessSegmentProperties ¶
func (b *Buffer) GuessSegmentProperties()
GuessSegmentProperties guesses direction, script, and language from buffer content. This is similar to HarfBuzz's hb_buffer_guess_segment_properties().
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset clears the buffer and resets all properties to defaults.
func (*Buffer) SetDirection ¶
SetDirection sets the text direction.
type BufferFlags ¶
type BufferFlags uint32
BufferFlags controls buffer behavior during shaping. These match HarfBuzz's hb_buffer_flags_t.
const ( // BufferFlagDefault is the default buffer flag. BufferFlagDefault BufferFlags = 0 // BufferFlagBOT indicates beginning of text paragraph. BufferFlagBOT BufferFlags = 1 << iota // BufferFlagEOT indicates end of text paragraph. BufferFlagEOT // BufferFlagPreserveDefaultIgnorables keeps default ignorable characters visible. BufferFlagPreserveDefaultIgnorables // BufferFlagRemoveDefaultIgnorables removes default ignorable characters from output. BufferFlagRemoveDefaultIgnorables // BufferFlagDoNotInsertDottedCircle prevents dotted circle insertion for invalid sequences. BufferFlagDoNotInsertDottedCircle )
type CFF ¶
type CFF struct {
Name string
TopDict TopDict
Strings []string // Custom strings (SID 391+)
GlobalSubrs [][]byte // Global subroutines
CharStrings [][]byte // Per-glyph CharStrings
PrivateDict PrivateDict
LocalSubrs [][]byte // Local subroutines
Charset []GlyphID // Glyph ID to SID mapping
// CID fonts
IsCID bool
FDArray []FontDict
FDSelect []byte
// contains filtered or unexported fields
}
CFF represents a parsed CFF (Compact Font Format) table.
type CaretValue ¶
type CaretValue struct {
// contains filtered or unexported fields
}
CaretValue represents a caret position within a ligature.
func (*CaretValue) Coordinate ¶
func (cv *CaretValue) Coordinate() int16
Coordinate returns the coordinate value for a CaretValue (format 1 or 3).
func (*CaretValue) Format ¶
func (cv *CaretValue) Format() uint16
Format returns the CaretValue format (1, 2, or 3).
func (*CaretValue) PointIndex ¶
func (cv *CaretValue) PointIndex() uint16
PointIndex returns the contour point index for a CaretValue (format 2).
type ChainContextPos ¶
type ChainContextPos struct {
// contains filtered or unexported fields
}
ChainContextPos represents a Chaining Context Positioning subtable (GPOS Type 8). It matches backtrack, input, and lookahead sequences, then applies nested lookups.
func (*ChainContextPos) Apply ¶
func (ccp *ChainContextPos) Apply(ctx *GPOSContext) bool
Apply applies chaining context positioning.
type ChainContextSubst ¶
type ChainContextSubst struct {
// contains filtered or unexported fields
}
ChainContextSubst represents a Chaining Context Substitution subtable (GSUB Type 6). It enables substitution based on surrounding context (backtrack, input, lookahead).
func (*ChainContextSubst) Apply ¶
func (ccs *ChainContextSubst) Apply(ctx *GSUBContext) int
Apply applies the chaining context substitution.
type ChainRule ¶
type ChainRule struct {
Backtrack []GlyphID // Backtrack sequence (in reverse order)
Input []GlyphID // Input sequence (starting from second glyph)
Lookahead []GlyphID // Lookahead sequence
LookupRecords []LookupRecord // Lookups to apply
}
ChainRule represents a single chaining context rule.
type CharStringInterpreter ¶
type CharStringInterpreter struct {
// Closure tracking
UsedGlobalSubrs map[int]bool
UsedLocalSubrs map[int]bool
// contains filtered or unexported fields
}
CharStringInterpreter interprets CFF Type 2 CharStrings to find subroutine usage.
func NewCharStringInterpreter ¶
func NewCharStringInterpreter(globalSubrs, localSubrs [][]byte) *CharStringInterpreter
NewCharStringInterpreter creates a new interpreter for finding subroutine usage.
func (*CharStringInterpreter) FindUsedSubroutines ¶
func (i *CharStringInterpreter) FindUsedSubroutines(charstring []byte) error
FindUsedSubroutines executes a CharString to find all subroutine calls. This is a simplified interpreter that only tracks subr calls, not actual drawing.
type ClassDef ¶
type ClassDef struct {
// contains filtered or unexported fields
}
ClassDef maps glyph IDs to class values.
func ParseClassDef ¶
ParseClassDef parses a ClassDef table.
type Cmap ¶
type Cmap struct {
// contains filtered or unexported fields
}
Cmap provides Unicode to glyph ID mapping.
func (*Cmap) LookupVariation ¶
LookupVariation returns the glyph ID for a codepoint with variation selector. Returns the glyph ID and whether a specific variant was found. If no variant is found, falls back to the base codepoint lookup.
type CompositeComponent ¶
type CompositeComponent struct {
GlyphID GlyphID
Flags uint16
Arg1 int16
Arg2 int16
// Transform matrix components (optional)
Scale float32
ScaleX float32
ScaleY float32
Scale01 float32
Scale10 float32
}
CompositeComponent represents a component in a composite glyph.
type ContextPos ¶
type ContextPos struct {
// contains filtered or unexported fields
}
ContextPos represents a Context Positioning subtable (GPOS Type 7). It matches input sequences and applies nested positioning lookups.
func (*ContextPos) Apply ¶
func (cp *ContextPos) Apply(ctx *GPOSContext) bool
Apply applies context positioning.
type ContextRule ¶
type ContextRule struct {
Input []GlyphID // Input sequence (starting from second glyph)
LookupRecords []LookupRecord // Lookups to apply
}
ContextRule represents a single context rule.
type ContextSubst ¶
type ContextSubst struct {
// contains filtered or unexported fields
}
ContextSubst represents a Context Substitution subtable (GSUB Type 5). It matches input sequences and applies nested lookups.
func (*ContextSubst) Apply ¶
func (cs *ContextSubst) Apply(ctx *GSUBContext) int
Apply applies the context substitution.
type Coverage ¶
type Coverage struct {
// contains filtered or unexported fields
}
Coverage represents an OpenType Coverage table. It maps glyph IDs to coverage indices.
func ParseCoverage ¶
ParseCoverage parses a Coverage table from data at the given offset.
func (*Coverage) GetCoverage ¶
GetCoverage returns the coverage index for a glyph ID, or NotCovered if not found.
type CursivePos ¶
type CursivePos struct {
// contains filtered or unexported fields
}
CursivePos represents a Cursive Attachment subtable (GPOS Type 3). It connects glyphs in cursive scripts (like Arabic) by aligning exit anchors with entry anchors of adjacent glyphs.
func (*CursivePos) Apply ¶
func (cp *CursivePos) Apply(ctx *GPOSContext) bool
Apply applies cursive positioning. It connects the current glyph's entry anchor to the previous glyph's exit anchor.
func (*CursivePos) Coverage ¶
func (cp *CursivePos) Coverage() *Coverage
Coverage returns the coverage table for this subtable.
func (*CursivePos) EntryExitRecords ¶
func (cp *CursivePos) EntryExitRecords() []EntryExitRecord
EntryExitRecords returns the entry/exit anchor records.
type Direction ¶
type Direction int
Direction represents text direction.
func GuessDirection ¶
GuessDirection guesses text direction from the content.
func (Direction) IsHorizontal ¶
IsHorizontal returns true if the direction is horizontal (LTR or RTL).
type EntryExitRecord ¶
EntryExitRecord holds entry and exit anchors for cursive attachment.
type Face ¶
type Face struct {
Font *Font
// contains filtered or unexported fields
}
Face represents a font face with parsed tables for metrics. This is a higher-level abstraction that caches parsed tables.
func LoadFaceFromData ¶
LoadFaceFromData loads a font from byte data and returns a Face.
func (*Face) Descender ¶
Descender returns the typographic descender in font units (usually negative).
func (*Face) FamilyName ¶
FamilyName returns the font family name.
func (*Face) GetHExtents ¶
func (f *Face) GetHExtents() FontExtents
GetHExtents returns horizontal font extents.
func (*Face) HorizontalAdvance ¶
HorizontalAdvance returns the horizontal advance for a glyph in font units.
func (*Face) IsFixedPitch ¶
IsFixedPitch returns true if the font is monospaced.
func (*Face) ItalicAngle ¶
ItalicAngle returns the italic angle in degrees (fixed-point 16.16).
func (*Face) PostscriptName ¶
PostscriptName returns the PostScript name of the font.
func (*Face) WeightClass ¶
WeightClass returns the font weight class (100-900).
type Feature ¶
type Feature struct {
Tag Tag // Feature tag (e.g., TagKern, TagLiga)
Value uint32 // 0 = off, 1 = on, >1 for alternates
Start uint // Cluster start (inclusive), FeatureGlobalStart for beginning
End uint // Cluster end (exclusive), FeatureGlobalEnd for end
}
Feature represents an OpenType feature with optional range. This matches HarfBuzz's hb_feature_t structure.
func DefaultFeatures ¶
func DefaultFeatures() []Feature
DefaultFeatures returns the default features for shaping.
func FeatureFromString ¶
FeatureFromString parses a feature string like HarfBuzz. Supported formats:
- "kern" -> kern=1 (on)
- "kern=1" -> kern=1 (on)
- "kern=0" -> kern=0 (off)
- "-kern" -> kern=0 (off)
- "+kern" -> kern=1 (on)
- "aalt=2" -> aalt=2 (alternate #2)
- "kern[3:5]" -> kern=1 for clusters 3-5
- "kern[3:5]=0" -> kern=0 for clusters 3-5
- "kern[3:]" -> kern=1 from cluster 3 to end
- "kern[:5]" -> kern=1 from start to cluster 5
Returns false if the string cannot be parsed.
func NewFeature ¶
NewFeature creates a feature that applies globally (entire buffer).
func NewFeatureOff ¶
NewFeatureOff creates a feature that is disabled globally.
func NewFeatureOn ¶
NewFeatureOn creates a feature that is enabled globally.
func ParseFeatures ¶
ParseFeatures parses a comma-separated list of features.
type FeatureList ¶
type FeatureList struct {
// contains filtered or unexported fields
}
FeatureList represents a GSUB/GPOS FeatureList.
func (*FeatureList) FindFeature ¶
func (f *FeatureList) FindFeature(tag Tag) []uint16
FindFeature finds a feature by tag and returns its lookup indices.
func (*FeatureList) GetFeature ¶
func (f *FeatureList) GetFeature(index int) (*FeatureRecord, error)
GetFeature returns the feature record at the given index.
type FeatureRecord ¶
FeatureRecord represents a parsed feature record with its lookup indices. This is the internal representation from the font's FeatureList table.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents an OpenType font.
func ParseFont ¶
ParseFont parses an OpenType font from data. For TrueType Collections (.ttc), use index to select a font.
func (*Font) NumGlyphs ¶
NumGlyphs returns the number of glyphs in the font. Returns 0 if maxp table is missing or invalid.
type FontDict ¶
type FontDict struct {
Private [2]int // [size, offset]
}
FontDict contains per-font dictionary data (for CID fonts).
type FontExtents ¶
type FontExtents struct {
Ascender int16 // Typographic ascender
Descender int16 // Typographic descender (usually negative)
LineGap int16 // Line spacing gap
}
FontExtents contains font-wide extent values. This matches HarfBuzz's hb_font_extents_t.
type GDEF ¶
type GDEF struct {
// contains filtered or unexported fields
}
GDEF represents the Glyph Definition table.
func (*GDEF) GetAttachPoints ¶
GetAttachPoints returns the attachment point indices for a glyph. Returns nil if the glyph has no attachment points defined.
func (*GDEF) GetGlyphClass ¶
GetGlyphClass returns the glyph class for a glyph ID. Returns GlyphClassUnclassified (0) if no class is defined.
func (*GDEF) GetLigCaretCount ¶
GetLigCaretCount returns the number of caret positions for a ligature glyph. Returns 0 if the glyph has no caret positions defined.
func (*GDEF) GetLigCarets ¶
func (g *GDEF) GetLigCarets(glyph GlyphID) []CaretValue
GetLigCarets returns the caret values for a ligature glyph. Returns nil if the glyph has no caret positions defined.
func (*GDEF) GetMarkAttachClass ¶
GetMarkAttachClass returns the mark attachment class for a glyph ID. Returns 0 if no class is defined.
func (*GDEF) HasAttachList ¶
HasAttachList returns true if the GDEF table has an attachment point list.
func (*GDEF) HasGlyphClasses ¶
HasGlyphClasses returns true if the GDEF table has glyph class definitions.
func (*GDEF) HasLigCaretList ¶
HasLigCaretList returns true if the GDEF table has a ligature caret list.
func (*GDEF) HasMarkAttachClasses ¶
HasMarkAttachClasses returns true if the GDEF table has mark attachment class definitions.
func (*GDEF) HasMarkGlyphSets ¶
HasMarkGlyphSets returns true if the GDEF table has mark glyph sets (version >= 1.2).
func (*GDEF) IsBaseGlyph ¶
IsBaseGlyph returns true if the glyph is classified as a base glyph.
func (*GDEF) IsComponentGlyph ¶
IsComponentGlyph returns true if the glyph is classified as a component glyph.
func (*GDEF) IsInMarkGlyphSet ¶
IsInMarkGlyphSet returns true if the glyph is in the specified mark glyph set.
func (*GDEF) IsLigatureGlyph ¶
IsLigatureGlyph returns true if the glyph is classified as a ligature glyph.
func (*GDEF) IsMarkGlyph ¶
IsMarkGlyph returns true if the glyph is classified as a mark glyph.
func (*GDEF) MarkGlyphSetCount ¶
MarkGlyphSetCount returns the number of mark glyph sets.
type GPOS ¶
type GPOS struct {
// contains filtered or unexported fields
}
GPOS represents the Glyph Positioning table.
func (*GPOS) ApplyKerning ¶
func (g *GPOS) ApplyKerning(glyphs []GlyphID) []GlyphPosition
ApplyKerning is a convenience method to apply pair positioning (kerning). This version does not use GDEF for glyph filtering.
func (*GPOS) ApplyKerningWithGDEF ¶
func (g *GPOS) ApplyKerningWithGDEF(glyphs []GlyphID, gdef *GDEF) []GlyphPosition
ApplyKerningWithGDEF applies pair positioning with GDEF-based glyph filtering.
func (*GPOS) ApplyLookup ¶
func (g *GPOS) ApplyLookup(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition)
ApplyLookup applies a single lookup to the glyph/position arrays. This version does not use GDEF for glyph filtering.
func (*GPOS) ApplyLookupWithDirection ¶
func (g *GPOS) ApplyLookupWithDirection(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition, direction Direction)
ApplyLookupWithDirection applies a single lookup with the specified direction. This version does not use GDEF for glyph filtering.
func (*GPOS) ApplyLookupWithGDEF ¶
func (g *GPOS) ApplyLookupWithGDEF(lookupIndex int, glyphs []GlyphID, positions []GlyphPosition, direction Direction, gdef *GDEF)
ApplyLookupWithGDEF applies a single lookup with GDEF-based glyph filtering.
func (*GPOS) GetLookup ¶
func (g *GPOS) GetLookup(index int) *GPOSLookup
GetLookup returns the lookup at the given index.
func (*GPOS) ParseFeatureList ¶
func (g *GPOS) ParseFeatureList() (*FeatureList, error)
ParseFeatureList parses a FeatureList from a GPOS table.
type GPOSChainRule ¶
type GPOSChainRule struct {
Backtrack []GlyphID // Backtrack sequence (in reverse order)
Input []GlyphID // Input sequence (starting from second glyph)
Lookahead []GlyphID // Lookahead sequence
LookupRecords []GPOSLookupRecord // Lookups to apply
}
GPOSChainRule represents a single chaining context positioning rule.
type GPOSContext ¶
type GPOSContext struct {
Glyphs []GlyphID
Positions []GlyphPosition
Index int
Direction Direction
LookupFlag uint16 // Current lookup flag
GDEF *GDEF // GDEF table for glyph classification (may be nil)
MarkFilteringSet int // Mark filtering set index (-1 if not used)
}
GPOSContext provides context for GPOS application.
func (*GPOSContext) AdjustPosition ¶
func (ctx *GPOSContext) AdjustPosition(index int, vr *ValueRecord)
AdjustPosition adjusts the position at the given index.
func (*GPOSContext) NextGlyph ¶
func (ctx *GPOSContext) NextGlyph(startIndex int) int
NextGlyph returns the index of the next glyph that should not be skipped, starting from startIndex. Returns -1 if no such glyph exists.
func (*GPOSContext) PrevGlyph ¶
func (ctx *GPOSContext) PrevGlyph(startIndex int) int
PrevGlyph returns the index of the previous glyph that should not be skipped, starting from startIndex (exclusive). Returns -1 if no such glyph exists.
func (*GPOSContext) ShouldSkipGlyph ¶
func (ctx *GPOSContext) ShouldSkipGlyph(index int) bool
ShouldSkipGlyph returns true if the glyph at the given index should be skipped based on the current LookupFlag and GDEF glyph classification.
type GPOSContextRule ¶
type GPOSContextRule struct {
Input []GlyphID // Input sequence (starting from second glyph)
LookupRecords []GPOSLookupRecord // Lookups to apply
}
GPOSContextRule represents a single rule in a context positioning rule set.
type GPOSLookup ¶
type GPOSLookup struct {
Type uint16
Flag uint16
MarkFilter uint16
// contains filtered or unexported fields
}
GPOSLookup represents a GPOS lookup table.
func (*GPOSLookup) Subtables ¶
func (l *GPOSLookup) Subtables() []GPOSSubtable
Subtables returns the subtables for this lookup.
type GPOSLookupRecord ¶
type GPOSLookupRecord struct {
SequenceIndex uint16 // Index into current glyph sequence (0-based)
LookupIndex uint16 // Lookup to apply
}
GPOSLookupRecord represents a lookup to apply at a specific position in a context.
type GPOSSubtable ¶
type GPOSSubtable interface {
// Apply applies the positioning to the glyphs at the current position.
// Returns true if positioning was applied.
Apply(ctx *GPOSContext) bool
}
GPOSSubtable is the interface for GPOS lookup subtables.
type GSUB ¶
type GSUB struct {
// contains filtered or unexported fields
}
GSUB represents the Glyph Substitution table.
func (*GSUB) ApplyFeature ¶
ApplyFeature applies all lookups for a feature to the glyph sequence. This version does not use GDEF for glyph filtering.
func (*GSUB) ApplyFeatureWithGDEF ¶
ApplyFeatureWithGDEF applies all lookups for a feature with GDEF-based glyph filtering.
func (*GSUB) ApplyLookup ¶
ApplyLookup applies a single lookup to the glyph sequence. This version does not use GDEF for glyph filtering.
func (*GSUB) ApplyLookupReverse ¶
ApplyLookupReverse applies this lookup in reverse order through the glyph buffer. This is the intended way to use ReverseChainSingleSubst. This version does not use GDEF for glyph filtering.
func (*GSUB) ApplyLookupReverseWithGDEF ¶
ApplyLookupReverseWithGDEF applies this lookup in reverse order with GDEF-based glyph filtering.
func (*GSUB) ApplyLookupWithGDEF ¶
ApplyLookupWithGDEF applies a single lookup with GDEF-based glyph filtering.
func (*GSUB) GetLookup ¶
func (g *GSUB) GetLookup(index int) *GSUBLookup
GetLookup returns the lookup at the given index.
func (*GSUB) NumLookups ¶
NumLookups returns the number of lookups in the GSUB table.
func (*GSUB) ParseFeatureList ¶
func (g *GSUB) ParseFeatureList() (*FeatureList, error)
ParseFeatureList parses a FeatureList from a GSUB/GPOS table.
type GSUBContext ¶
type GSUBContext struct {
Glyphs []GlyphID // Current glyph sequence
Index int // Current position
// Lookup filtering
LookupFlag uint16 // Current lookup flag
GDEF *GDEF // GDEF table for glyph classification (may be nil)
MarkFilteringSet int // Mark filtering set index (-1 if not used)
// Output callbacks
OnReplace func(index int, newGlyph GlyphID)
OnReplaces func(index int, newGlyphs []GlyphID)
OnDelete func(index int)
OnLigate func(index int, ligGlyph GlyphID, numGlyphs int)
}
GSUBContext provides context for GSUB application.
func (*GSUBContext) DeleteGlyph ¶
func (ctx *GSUBContext) DeleteGlyph()
DeleteGlyph deletes the current glyph.
func (*GSUBContext) Ligate ¶
func (ctx *GSUBContext) Ligate(ligGlyph GlyphID, numGlyphs int)
Ligate replaces numGlyphs at current position with a ligature.
func (*GSUBContext) NextGlyph ¶
func (ctx *GSUBContext) NextGlyph(startIndex int) int
NextGlyph returns the index of the next glyph that should not be skipped, starting from startIndex. Returns -1 if no such glyph exists.
func (*GSUBContext) PrevGlyph ¶
func (ctx *GSUBContext) PrevGlyph(startIndex int) int
PrevGlyph returns the index of the previous glyph that should not be skipped, starting from startIndex (exclusive). Returns -1 if no such glyph exists.
func (*GSUBContext) ReplaceGlyph ¶
func (ctx *GSUBContext) ReplaceGlyph(newGlyph GlyphID)
ReplaceGlyph replaces the current glyph.
func (*GSUBContext) ReplaceGlyphs ¶
func (ctx *GSUBContext) ReplaceGlyphs(newGlyphs []GlyphID)
ReplaceGlyphs replaces the current glyph with multiple glyphs.
func (*GSUBContext) ShouldSkipGlyph ¶
func (ctx *GSUBContext) ShouldSkipGlyph(index int) bool
ShouldSkipGlyph returns true if the glyph at the given index should be skipped based on the current LookupFlag and GDEF glyph classification.
type GSUBLookup ¶
type GSUBLookup struct {
Type uint16
Flag uint16
MarkFilter uint16 // For flag & 0x10
// contains filtered or unexported fields
}
GSUBLookup represents a GSUB lookup table.
func (*GSUBLookup) Subtables ¶
func (l *GSUBLookup) Subtables() []GSUBSubtable
Subtables returns the lookup subtables.
type GSUBSubtable ¶
type GSUBSubtable interface {
// Apply applies the substitution to the glyph at the current position.
// Returns the number of glyphs consumed (0 if not applied).
Apply(ctx *GSUBContext) int
}
GSUBSubtable is the interface for GSUB lookup subtables.
type Glyf ¶
type Glyf struct {
// contains filtered or unexported fields
}
Glyf represents the parsed glyf table (glyph data).
func ParseGlyfFromFont ¶
ParseGlyfFromFont parses both glyf and loca tables from a font.
func (*Glyf) GetComponents ¶
GetComponents returns the component glyph IDs for a composite glyph. For simple glyphs, returns nil.
func (*Glyf) GetGlyphBytes ¶
GetGlyphBytes returns the raw bytes for a glyph.
type GlyphData ¶
GlyphData represents the raw data for a single glyph.
func (*GlyphData) IsComposite ¶
IsComposite returns true if the glyph is a composite glyph.
type GlyphExtents ¶
type GlyphExtents struct {
XBearing int16 // Left side of glyph from origin
YBearing int16 // Top side of glyph from origin
Width int16 // Width of glyph
Height int16 // Height of glyph (usually negative)
}
GlyphExtents contains glyph extent values.
type GlyphInfo ¶
type GlyphInfo struct {
Codepoint Codepoint // Original Unicode codepoint (0 if synthetic)
GlyphID GlyphID // Glyph index in the font
Cluster int // Cluster index (maps back to original text position)
GlyphClass int // GDEF glyph class (if available)
}
GlyphInfo holds information about a shaped glyph.
type GlyphPos ¶
type GlyphPos struct {
XAdvance int16 // Horizontal advance
YAdvance int16 // Vertical advance
XOffset int16 // Horizontal offset
YOffset int16 // Vertical offset
}
GlyphPos holds positioning information for a shaped glyph.
type GlyphPosition ¶
type GlyphPosition struct {
XPlacement int16
YPlacement int16
XAdvance int16
YAdvance int16
// For mark attachment
XOffset int16 // Additional X offset (for marks)
YOffset int16 // Additional Y offset (for marks)
AttachType uint8 // Type of attachment (0=none, 1=mark, 2=cursive)
AttachChain int16 // Offset to attached glyph (negative = before)
}
GlyphPosition holds positioning information for a glyph.
type Head ¶
type Head struct {
Version uint32
FontRevision uint32
CheckSumAdjustment uint32
MagicNumber uint32
Flags uint16
UnitsPerEm uint16
Created int64
Modified int64
XMin int16
YMin int16
XMax int16
YMax int16
MacStyle uint16
LowestRecPPEM uint16
FontDirectionHint int16
IndexToLocFormat int16
GlyphDataFormat int16
}
Head represents the font header table.
type Hhea ¶
type Hhea struct {
Version uint32
Ascender int16
Descender int16
LineGap int16
AdvanceWidthMax uint16
MinLeftSideBearing int16
MinRightSideBearing int16
XMaxExtent int16
CaretSlopeRise int16
CaretSlopeRun int16
CaretOffset int16
MetricDataFormat int16
NumberOfHMetrics uint16
}
Hhea represents the horizontal header table.
type Hmtx ¶
type Hmtx struct {
// contains filtered or unexported fields
}
Hmtx represents the horizontal metrics table.
func ParseHmtx ¶
ParseHmtx parses the hmtx table. It requires numberOfHMetrics from hhea and numGlyphs from maxp.
func ParseHmtxFromFont ¶
ParseHmtxFromFont is a convenience function that parses hmtx from a font, automatically reading hhea and maxp for required values.
func (*Hmtx) GetAdvanceWidth ¶
GetAdvanceWidth returns the advance width for a glyph.
type LigCaretList ¶
type LigCaretList struct {
// contains filtered or unexported fields
}
LigCaretList contains ligature caret positions.
type LigGlyph ¶
type LigGlyph struct {
// contains filtered or unexported fields
}
LigGlyph contains caret values for a ligature glyph.
type Ligature ¶
type Ligature struct {
LigGlyph GlyphID // The resulting ligature glyph
Components []GlyphID // Component glyphs (starting from second)
}
Ligature represents a single ligature rule.
type LigatureArray ¶
type LigatureArray struct {
Attachments []*LigatureAttach
}
LigatureArray contains LigatureAttach tables for multiple ligatures.
type LigatureAttach ¶
type LigatureAttach struct {
ComponentCount int // Number of ligature components
ClassCount int // Number of mark classes
Anchors [][]*Anchor // [component][class] -> Anchor (may be nil)
}
LigatureAttach contains anchors for one ligature glyph. It's organized as a matrix where: - Rows correspond to ligature components (in writing order) - Columns correspond to mark classes
func (*LigatureAttach) GetAnchor ¶
func (la *LigatureAttach) GetAnchor(componentIndex, markClass int) *Anchor
GetAnchor returns the anchor for a given component index and mark class.
type LigatureSubst ¶
type LigatureSubst struct {
// contains filtered or unexported fields
}
LigatureSubst represents a Ligature Substitution subtable.
func (*LigatureSubst) Apply ¶
func (l *LigatureSubst) Apply(ctx *GSUBContext) int
Apply applies the ligature substitution.
func (*LigatureSubst) Coverage ¶
func (l *LigatureSubst) Coverage() *Coverage
Coverage returns the coverage table.
func (*LigatureSubst) LigatureSets ¶
func (l *LigatureSubst) LigatureSets() [][]Ligature
LigatureSets returns the ligature sets.
type Loca ¶
type Loca struct {
// contains filtered or unexported fields
}
Loca represents the parsed loca table (index to location).
func ParseLoca ¶
ParseLoca parses the loca table. indexToLocFormat: 0 = short (16-bit), 1 = long (32-bit)
func (*Loca) GetOffset ¶
GetOffset returns the offset and length for a glyph. Returns (offset, length, ok)
type LongHorMetric ¶
LongHorMetric contains the advance width and left side bearing for a glyph.
type LookupRecord ¶
type LookupRecord struct {
SequenceIndex uint16 // Index into current glyph sequence (0-based)
LookupIndex uint16 // Lookup to apply
}
LookupRecord specifies a lookup to apply at a specific position.
type MarkArray ¶
type MarkArray struct {
Records []MarkRecord
}
MarkArray contains an array of MarkRecords.
type MarkBasePos ¶
type MarkBasePos struct {
// contains filtered or unexported fields
}
MarkBasePos represents a Mark-to-Base Attachment subtable (GPOS Type 4). It positions mark glyphs relative to base glyphs using anchor points.
func (*MarkBasePos) Apply ¶
func (m *MarkBasePos) Apply(ctx *GPOSContext) bool
Apply applies the mark-to-base positioning. It finds the preceding base glyph and positions the current mark relative to it.
func (*MarkBasePos) BaseArray ¶
func (m *MarkBasePos) BaseArray() *BaseArray
BaseArray returns the base array.
func (*MarkBasePos) BaseCoverage ¶
func (m *MarkBasePos) BaseCoverage() *Coverage
BaseCoverage returns the base coverage table.
func (*MarkBasePos) ClassCount ¶
func (m *MarkBasePos) ClassCount() uint16
ClassCount returns the number of mark classes.
func (*MarkBasePos) MarkArray ¶
func (m *MarkBasePos) MarkArray() *MarkArray
MarkArray returns the mark array.
func (*MarkBasePos) MarkCoverage ¶
func (m *MarkBasePos) MarkCoverage() *Coverage
MarkCoverage returns the mark coverage table.
type MarkGlyphSetsDef ¶
type MarkGlyphSetsDef struct {
// contains filtered or unexported fields
}
MarkGlyphSetsDef contains mark glyph set definitions.
type MarkLigPos ¶
type MarkLigPos struct {
// contains filtered or unexported fields
}
MarkLigPos represents a Mark-to-Ligature Attachment subtable (GPOS Type 5). It positions mark glyphs relative to ligature glyphs. Each ligature can have multiple components, and each component has its own anchor points.
func (*MarkLigPos) Apply ¶
func (m *MarkLigPos) Apply(ctx *GPOSContext) bool
Apply applies the mark-to-ligature positioning. It finds the preceding ligature glyph and positions the current mark relative to the appropriate ligature component.
func (*MarkLigPos) ApplyWithComponent ¶
func (m *MarkLigPos) ApplyWithComponent(ctx *GPOSContext, componentIndex int) bool
ApplyWithComponent applies the mark-to-ligature positioning with a specific component. If componentIndex is -1, it defaults to the last component.
func (*MarkLigPos) ClassCount ¶
func (m *MarkLigPos) ClassCount() uint16
ClassCount returns the number of mark classes.
func (*MarkLigPos) LigatureArray ¶
func (m *MarkLigPos) LigatureArray() *LigatureArray
LigatureArray returns the ligature array.
func (*MarkLigPos) LigatureCoverage ¶
func (m *MarkLigPos) LigatureCoverage() *Coverage
LigatureCoverage returns the ligature coverage table.
func (*MarkLigPos) MarkArray ¶
func (m *MarkLigPos) MarkArray() *MarkArray
MarkArray returns the mark array.
func (*MarkLigPos) MarkCoverage ¶
func (m *MarkLigPos) MarkCoverage() *Coverage
MarkCoverage returns the mark coverage table.
type MarkMarkPos ¶
type MarkMarkPos struct {
// contains filtered or unexported fields
}
MarkMarkPos represents a Mark-to-Mark Attachment subtable (GPOS Type 6). It positions mark glyphs (mark1) relative to preceding mark glyphs (mark2). This is used for stacking diacritics, e.g., placing an accent on top of another accent.
func (*MarkMarkPos) Apply ¶
func (m *MarkMarkPos) Apply(ctx *GPOSContext) bool
Apply applies the mark-to-mark positioning. It finds the preceding mark glyph (mark2) and positions the current mark (mark1) relative to it.
func (*MarkMarkPos) ClassCount ¶
func (m *MarkMarkPos) ClassCount() uint16
ClassCount returns the number of mark classes.
func (*MarkMarkPos) Mark1Array ¶
func (m *MarkMarkPos) Mark1Array() *MarkArray
Mark1Array returns the mark array for mark1 glyphs.
func (*MarkMarkPos) Mark1Coverage ¶
func (m *MarkMarkPos) Mark1Coverage() *Coverage
Mark1Coverage returns the coverage table for the attaching mark (mark1).
func (*MarkMarkPos) Mark2Array ¶
func (m *MarkMarkPos) Mark2Array() *BaseArray
Mark2Array returns the anchor array for mark2 glyphs.
func (*MarkMarkPos) Mark2Coverage ¶
func (m *MarkMarkPos) Mark2Coverage() *Coverage
Mark2Coverage returns the coverage table for the base mark (mark2).
type MarkRecord ¶
MarkRecord associates a mark glyph with a class and anchor.
type MultipleSubst ¶
type MultipleSubst struct {
// contains filtered or unexported fields
}
MultipleSubst represents a Multiple Substitution subtable (1 -> n).
func (*MultipleSubst) Apply ¶
func (m *MultipleSubst) Apply(ctx *GSUBContext) int
Apply applies the multiple substitution.
func (*MultipleSubst) Mapping ¶
func (m *MultipleSubst) Mapping() map[GlyphID][]GlyphID
Mapping returns the input->output mapping for glyph closure computation.
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name represents the name table.
func (*Name) FamilyName ¶
FamilyName returns the font family name (nameID 1).
func (*Name) PostScriptName ¶
PostScriptName returns the PostScript name (nameID 6).
type OS2 ¶
type OS2 struct {
Version uint16
XAvgCharWidth int16
UsWeightClass uint16
UsWidthClass uint16
FsType uint16
YSubscriptXSize int16
YSubscriptYSize int16
YSubscriptXOffset int16
YSubscriptYOffset int16
YSuperscriptXSize int16
YSuperscriptYSize int16
YSuperscriptXOffset int16
YSuperscriptYOffset int16
YStrikeoutSize int16
YStrikeoutPosition int16
SFamilyClass int16
Panose [10]byte
UlUnicodeRange1 uint32
UlUnicodeRange2 uint32
UlUnicodeRange3 uint32
UlUnicodeRange4 uint32
AchVendID [4]byte
FsSelection uint16
UsFirstCharIndex uint16
UsLastCharIndex uint16
STypoAscender int16
STypoDescender int16
STypoLineGap int16
UsWinAscent uint16
UsWinDescent uint16
// Version 1+
UlCodePageRange1 uint32
UlCodePageRange2 uint32
// Version 2+
SxHeight int16
SCapHeight int16
UsDefaultChar uint16
UsBreakChar uint16
UsMaxContext uint16
}
OS2 represents the OS/2 table.
type PairClassRecord ¶
type PairClassRecord struct {
Value1 ValueRecord
Value2 ValueRecord
}
PairClassRecord holds positioning values for a class pair.
type PairPos ¶
type PairPos struct {
// contains filtered or unexported fields
}
PairPos represents a Pair Positioning subtable.
func (*PairPos) Apply ¶
func (pp *PairPos) Apply(ctx *GPOSContext) bool
Apply applies pair positioning (kerning).
func (*PairPos) Class1Count ¶
Class1Count returns the number of classes for first glyphs (format 2 only).
func (*PairPos) Class2Count ¶
Class2Count returns the number of classes for second glyphs (format 2 only).
func (*PairPos) ClassDef1 ¶
ClassDef1 returns the class definition for first glyphs (format 2 only).
func (*PairPos) ClassDef2 ¶
ClassDef2 returns the class definition for second glyphs (format 2 only).
func (*PairPos) ClassMatrix ¶
func (pp *PairPos) ClassMatrix() [][]PairClassRecord
ClassMatrix returns the class matrix (format 2 only).
func (*PairPos) PairSets ¶
func (pp *PairPos) PairSets() [][]PairValueRecord
PairSets returns the pair sets (format 1 only).
func (*PairPos) ValueFormat1 ¶
ValueFormat1 returns the value format for the first glyph.
func (*PairPos) ValueFormat2 ¶
ValueFormat2 returns the value format for the second glyph.
type PairValueRecord ¶
type PairValueRecord struct {
SecondGlyph GlyphID
Value1 ValueRecord
Value2 ValueRecord
}
PairValueRecord holds a pair of glyphs and their positioning values.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser provides methods for reading binary OpenType data.
func (*Parser) SubParserFromOffset ¶
SubParserFromOffset returns a parser starting at off to end of data.
type Post ¶
type Post struct {
Version uint32
ItalicAngle int32 // Fixed-point 16.16
UnderlinePosition int16
UnderlineThickness int16
IsFixedPitch uint32
}
Post represents the post table.
func (*Post) ItalicAngleDegrees ¶
ItalicAngleDegrees returns the italic angle in degrees.
type PrivateDict ¶
type PrivateDict struct {
BlueValues []int
OtherBlues []int
FamilyBlues []int
FamilyOtherBlues []int
StdHW int
StdVW int
Subrs int // Offset to Local Subrs (relative to Private DICT)
DefaultWidthX int
NominalWidthX int
BlueScale float64
BlueShift int
BlueFuzz int
}
PrivateDict contains private dictionary data.
type ReverseChainSingleSubst ¶
type ReverseChainSingleSubst struct {
// contains filtered or unexported fields
}
ReverseChainSingleSubst represents a Reverse Chaining Context Single Substitution subtable (GSUB Type 8). It is designed to be applied in reverse (from end to beginning of buffer). Unlike ChainContextSubst, it only performs single glyph substitution (no nested lookups).
func (*ReverseChainSingleSubst) Apply ¶
func (r *ReverseChainSingleSubst) Apply(ctx *GSUBContext) int
Apply applies the reverse chaining context single substitution. This lookup is intended to be applied in reverse (from end to beginning of buffer). It replaces the current glyph if it matches the coverage and context.
type Shaper ¶
type Shaper struct {
// contains filtered or unexported fields
}
Shaper holds font data and performs text shaping.
func (*Shaper) GetDefaultFeatures ¶
DefaultFeatures returns the current default features.
func (*Shaper) SetDefaultFeatures ¶
SetDefaultFeatures sets the default features to apply when Shape is called with nil.
type SinglePos ¶
type SinglePos struct {
// contains filtered or unexported fields
}
SinglePos represents a Single Positioning subtable.
func (*SinglePos) Apply ¶
func (sp *SinglePos) Apply(ctx *GPOSContext) bool
Apply applies single positioning.
func (*SinglePos) ValueFormat ¶
ValueFormat returns the value format flags.
func (*SinglePos) ValueRecord ¶
func (sp *SinglePos) ValueRecord() ValueRecord
ValueRecord returns the value record (format 1 only).
func (*SinglePos) ValueRecords ¶
func (sp *SinglePos) ValueRecords() []ValueRecord
ValueRecords returns the per-glyph value records (format 2 only).
type SingleSubst ¶
type SingleSubst struct {
// contains filtered or unexported fields
}
SingleSubst represents a Single Substitution subtable.
func (*SingleSubst) Apply ¶
func (s *SingleSubst) Apply(ctx *GSUBContext) int
Apply applies the single substitution.
func (*SingleSubst) Mapping ¶
func (s *SingleSubst) Mapping() map[GlyphID]GlyphID
Mapping returns all input->output glyph mappings for this substitution.
type TopDict ¶
type TopDict struct {
Version int // SID
Notice int // SID
FullName int // SID
FamilyName int // SID
Weight int // SID
FontBBox [4]int
CharStrings int // Offset to CharStrings INDEX
Private [2]int // [size, offset]
Charset int // Offset to Charset
Encoding int // Offset to Encoding
// CID fonts
ROS [3]int // Registry, Ordering, Supplement (SIDs)
FDArray int
FDSelect int
IsCID bool
}
TopDict contains top-level font dictionary data.
type ValueRecord ¶
type ValueRecord struct {
XPlacement int16 // Horizontal adjustment for placement
YPlacement int16 // Vertical adjustment for placement
XAdvance int16 // Horizontal adjustment for advance
YAdvance int16 // Vertical adjustment for advance
}
ValueRecord holds positioning values.
func (*ValueRecord) IsZero ¶
func (vr *ValueRecord) IsZero() bool
IsZero returns true if all values are zero.