Documentation
¶
Index ¶
- func ComputeClosureGSUB(fontData []byte, initialGIDs map[int]bool) (map[int]bool, error)
- func ExtractTable(data []byte, table OpenTypeTable) ([]byte, error)
- func LoadOpenType(name string, data []byte) (*semantic.Font, error)
- func LoadTrueType(name string, data []byte) (*semantic.Font, error)
- func ParseOpenTypeTableDirectory(data []byte) (map[string]OpenTypeTable, error)
- func ParseType1(name string, pfbData []byte) (*semantic.Font, error)
- func SubsetTrueType(data []byte, usedGIDs map[int]bool) ([]byte, error)
- type Analyzer
- type CFF
- type CFFHeader
- type OpenTypeTable
- type Operand
- type Planner
- type ShapedGlyph
- type Subset
- type Subsetter
- type TextRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeClosureGSUB ¶
ComputeClosureGSUB computes the transitive closure of glyphs reachable via GSUB substitutions.
func ExtractTable ¶
func ExtractTable(data []byte, table OpenTypeTable) ([]byte, error)
ExtractTable returns the raw data of a specific table.
func LoadOpenType ¶
LoadOpenType parses an OpenType font (CFF or TrueType outlines). If it contains CFF outlines, it extracts the CFF table and embeds it as FontFile3.
func LoadTrueType ¶
LoadTrueType parses a TrueType/OpenType font, extracts basic metrics, and returns a semantic.Font configured for Type0 Identity-H usage with a FontFile2 stream. The full font is embedded (no subsetting).
func ParseOpenTypeTableDirectory ¶
func ParseOpenTypeTableDirectory(data []byte) (map[string]OpenTypeTable, error)
ParseOpenTypeTableDirectory parses the header and table directory of an OpenType/TrueType font.
func ParseType1 ¶
ParseType1 parses PFB (font data) and returns a semantic.Font. It extracts metrics from the ASCII segment of the PFB.
func SubsetTrueType ¶
SubsetTrueType subsets a TrueType font file, keeping only the specified GIDs. It performs a sparse subsetting: GIDs are preserved (Identity-H compatible), but unused glyph data is removed from the 'glyf' table.
Types ¶
type Analyzer ¶
type Analyzer struct {
// Map of font -> set of used CIDs/codes
UsedGlyphs map[*semantic.Font]map[int]bool
// TextRuns records per-font script-aware runs derived from ToUnicode mappings.
TextRuns map[*semantic.Font][]TextRun
}
Analyzer identifies used glyphs in a document.
func NewAnalyzer ¶
func NewAnalyzer() *Analyzer
type CFF ¶
type CFF struct {
Header CFFHeader
Names []string
TopDicts []map[int][]Operand // Key is operator, value is operands
Strings []string
}
CFF represents a parsed Compact Font Format structure.
type OpenTypeTable ¶
OpenTypeTable represents an entry in the OpenType table directory.
type Planner ¶
func NewPlanner ¶
func NewPlanner() *Planner
type ShapedGlyph ¶
type ShapedGlyph struct {
ID int
XAdvance float64 // In PDF text units (1/1000 em)
YAdvance float64
XOffset float64
YOffset float64
}
ShapedGlyph represents a single shaped glyph with positioning information.
type Subsetter ¶
type Subsetter struct{}
Subsetter applies the subsetting plan to the fonts.
func NewSubsetter ¶
func NewSubsetter() *Subsetter