Documentation
¶
Index ¶
- func SerializeTTC(fonts []TrueTypeFont) ([]byte, error)
- type BigEndian
- func (b *BigEndian) Append(bytes []byte)
- func (b *BigEndian) Bytes(n int) []byte
- func (b *BigEndian) Fixed16_16() (f Fixed16_16)
- func (b *BigEndian) I8() (i8 int8)
- func (b *BigEndian) I16() (i16 int16)
- func (b *BigEndian) I32() (i32 int32)
- func (b *BigEndian) I64() (i64 int64)
- func (b *BigEndian) Offset() int
- func (b *BigEndian) PutFixed16_16(f Fixed16_16)
- func (b *BigEndian) PutU8(u8 uint8)
- func (b *BigEndian) PutU16(u16 uint16)
- func (b *BigEndian) PutU32(u32 uint32)
- func (b *BigEndian) PutU64(u64 uint64)
- func (b *BigEndian) Read(n int) []byte
- func (l *BigEndian) Slice(n int) Binary
- func (b *BigEndian) U8() (u8 uint8)
- func (b *BigEndian) U16() (u16 uint16)
- func (b *BigEndian) U32() (u32 uint32)
- func (b *BigEndian) U64() (u64 uint64)
- type Binary
- type CFF
- type CFFCharset
- type CFFHeader
- type CFFINDEX
- type CFFOutline
- type CFFPathOp
- type CFFPathSegment
- type CFFPrivateDict
- type CFFTopDict
- type CMap
- type CMapFormat0
- type CMapFormat4
- type CMapFormat6
- type CMapFormat12
- type CMapSubtable
- type ClassDef
- type ClassRangeRecord
- type CompositeGlyph
- type Coverage
- type CoverageRange
- type Cvt
- type FeatureList
- type FeatureRecord
- type FeatureTable
- type Fixed2_14
- type Fixed16_16
- type Font
- type Fpgm
- type GPOS
- type GSUB
- type Glyph
- type GlyphComponent
- type GlyphHeader
- type GlyphPath
- type Head
- type Hhea
- type Hmtx
- type Kern
- type KernPair
- type KernSubtable
- type LangSys
- type LangSysRecord
- type LangTagRecord
- type LittleEndian
- func (l *LittleEndian) Append(bytes []byte)
- func (l *LittleEndian) Bytes(n int) []byte
- func (l *LittleEndian) Fixed16_16() (f Fixed16_16)
- func (l *LittleEndian) I8() (i8 int8)
- func (l *LittleEndian) I16() (i16 int16)
- func (l *LittleEndian) I32() (i32 int32)
- func (l *LittleEndian) I64() (i64 int64)
- func (l *LittleEndian) Offset() int
- func (l *LittleEndian) PutFixed16_16(f Fixed16_16)
- func (l *LittleEndian) PutU8(u8 uint8)
- func (l *LittleEndian) PutU16(u16 uint16)
- func (l *LittleEndian) PutU32(u32 uint32)
- func (l *LittleEndian) PutU64(u64 uint64)
- func (l *LittleEndian) Read(n int) []byte
- func (l *LittleEndian) Slice(n int) Binary
- func (l *LittleEndian) U8() (u8 uint8)
- func (l *LittleEndian) U16() (u16 uint16)
- func (l *LittleEndian) U32() (u32 uint32)
- func (l *LittleEndian) U64() (u64 uint64)
- type Loca
- type LongHorMetric
- type MacStyle
- type Maxp
- type Name
- type NameRecord
- type OS2
- type OTLookup
- type OTLookupList
- type PathOp
- type PathSegment
- type Post
- type Prep
- type ScriptList
- type ScriptRecord
- type ScriptTable
- type SequentialMapGroup
- type SimpleGlyph
- type Table
- type TableDirectory
- type TrueTypeFont
- func (ttf *TrueTypeFont) AdvanceWidth(glyphID uint16) uint16
- func (ttf *TrueTypeFont) AdvanceWidthForRune(r rune) uint16
- func (ttf *TrueTypeFont) AppendGlyph(g *Glyph) (int, error)
- func (ttf *TrueTypeFont) Ascent() int16
- func (ttf *TrueTypeFont) CFFFontName() string
- func (ttf *TrueTypeFont) CFFGlyphName(glyphID int) string
- func (ttf *TrueTypeFont) CFFOutlineAt(index int) *CFFOutline
- func (ttf *TrueTypeFont) CFFOutlineForRune(r rune) *CFFOutline
- func (ttf *TrueTypeFont) CapHeight() int16
- func (ttf *TrueTypeFont) CaretSlope() (run, rise int16)
- func (ttf *TrueTypeFont) ContourCount(index int) int
- func (ttf *TrueTypeFont) CopyGlyph(srcIndex, dstIndex int) error
- func (ttf *TrueTypeFont) Descent() int16
- func (ttf *TrueTypeFont) FontBBox() (xMin, yMin, xMax, yMax int16)
- func (ttf *TrueTypeFont) FontFamily() string
- func (ttf *TrueTypeFont) FontFullName() string
- func (ttf *TrueTypeFont) GlyphAt(index int) *Glyph
- func (ttf *TrueTypeFont) GlyphBBox(index int) (xMin, yMin, xMax, yMax int16, ok bool)
- func (ttf *TrueTypeFont) GlyphForRune(r rune) *Glyph
- func (f *TrueTypeFont) GlyphPath(glyphIndex int) (*GlyphPath, error)
- func (ttf *TrueTypeFont) IsCFF() bool
- func (ttf *TrueTypeFont) IsCompositeGlyph(index int) bool
- func (ttf *TrueTypeFont) IsSimpleGlyph(index int) bool
- func (ttf *TrueTypeFont) KernPair(left, right uint16) int16
- func (ttf *TrueTypeFont) LeftSideBearing(glyphID uint16) int16
- func (ttf *TrueTypeFont) LineGap() int16
- func (ttf *TrueTypeFont) MappedRunes() []rune
- func (ttf *TrueTypeFont) NumGlyphs() int
- func (ttf *TrueTypeFont) PointCount(index int) int
- func (ttf *TrueTypeFont) RemoveGlyphs(indices []int) (remap map[int]int, err error)
- func (ttf *TrueTypeFont) RemoveRuneMapping(r rune)
- func (ttf *TrueTypeFont) RuneMappings() []struct{ ... }
- func (ttf *TrueTypeFont) RuneToGlyphID(r rune) uint16
- func (ttf *TrueTypeFont) ScaleGlyph(index int, sx, sy float64) error
- func (ttf *TrueTypeFont) Serialize() ([]byte, error)
- func (ttf *TrueTypeFont) SerializeEOT() ([]byte, error)
- func (ttf *TrueTypeFont) SerializeWOFF() ([]byte, error)
- func (ttf *TrueTypeFont) SerializeWOFF2() ([]byte, error)
- func (ttf *TrueTypeFont) SetAdvanceWidth(glyphID uint16, width uint16) error
- func (ttf *TrueTypeFont) SetFontFamily(name string)
- func (ttf *TrueTypeFont) SetFontFullName(name string)
- func (ttf *TrueTypeFont) SetGlyphAt(index int, g *Glyph) error
- func (ttf *TrueTypeFont) SetLeftSideBearing(glyphID uint16, lsb int16) error
- func (ttf *TrueTypeFont) SetRuneMapping(r rune, glyphID uint16) error
- func (ttf *TrueTypeFont) SetRuneMappings(mappings map[rune]uint16) error
- func (ttf *TrueTypeFont) Subset(keepRunes []rune) error
- func (ttf *TrueTypeFont) TranslateGlyph(index int, dx, dy int16) error
- func (ttf *TrueTypeFont) UnitsPerEm() uint16
- func (ttf *TrueTypeFont) XHeight() int16
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SerializeTTC ¶
func SerializeTTC(fonts []TrueTypeFont) ([]byte, error)
SerializeTTC serializes multiple TrueTypeFont objects into a TTC file.
Types ¶
type BigEndian ¶
type BigEndian struct {
// contains filtered or unexported fields
}
func (*BigEndian) Fixed16_16 ¶
func (b *BigEndian) Fixed16_16() (f Fixed16_16)
func (*BigEndian) PutFixed16_16 ¶
func (b *BigEndian) PutFixed16_16(f Fixed16_16)
type Binary ¶
type Binary interface {
U8() uint8
I8() int8
U16() uint16
I16() int16
Fixed16_16() Fixed16_16
U32() uint32
I32() int32
U64() uint64
I64() int64
PutU8(uint8)
PutU16(uint16)
PutFixed16_16(Fixed16_16)
PutU32(uint32)
PutU64(uint64)
Offset() int
Bytes(int) []uint8
Read(int) []uint8
Slice(int) Binary
Append([]byte)
}
func BinaryFrom ¶
type CFF ¶
type CFF struct {
// contains filtered or unexported fields
}
CFF holds parsed data from a CFF (Compact Font Format) table.
func (*CFF) CharStringData ¶
CharStringData returns the raw charstring data for the given glyph ID.
func (*CFF) DecodeOutlines ¶
func (cff *CFF) DecodeOutlines() ([]*CFFOutline, error)
DecodeOutlines decodes all charstring outlines in the CFF font.
type CFFCharset ¶
type CFFCharset struct {
// contains filtered or unexported fields
}
CFFCharset maps glyph IDs to SIDs.
type CFFHeader ¶
type CFFHeader struct {
// contains filtered or unexported fields
}
CFFHeader is the CFF table header.
type CFFINDEX ¶
type CFFINDEX struct {
// contains filtered or unexported fields
}
CFFINDEX represents a CFF INDEX structure. An INDEX stores a count of items, with offsets into a data region. Element i is data[offsets[i]-1 : offsets[i+1]-1] (1-based offsets).
type CFFOutline ¶
type CFFOutline struct {
// contains filtered or unexported fields
}
CFFOutline holds the parsed outline data for a single CFF glyph.
func (*CFFOutline) BBox ¶
func (o *CFFOutline) BBox() (xMin, yMin, xMax, yMax int16)
BBox returns the computed bounding box.
func (*CFFOutline) NumSegments ¶
func (o *CFFOutline) NumSegments() int
NumSegments returns the number of path segments.
func (*CFFOutline) Segments ¶
func (o *CFFOutline) Segments() []CFFPathSegment
Segments returns all path segments.
func (*CFFOutline) Width ¶
func (o *CFFOutline) Width() (width int32, ok bool)
Width returns the glyph width. ok is true if width was specified in charstring.
type CFFPathOp ¶
type CFFPathOp uint8
CFFPathOp represents a path operation in a CFF charstring outline.
type CFFPathSegment ¶
type CFFPathSegment struct {
Op CFFPathOp
Args [6]int32 // relative coordinates; at most 6 for CurveTo
}
CFFPathSegment represents one path drawing segment in a CFF outline.
type CFFPrivateDict ¶
type CFFPrivateDict struct {
// contains filtered or unexported fields
}
CFFPrivateDict holds Private DICT values.
type CFFTopDict ¶
type CFFTopDict struct {
// contains filtered or unexported fields
}
CFFTopDict holds key values parsed from the Top DICT.
type CMapFormat0 ¶
type CMapFormat0 struct {
// contains filtered or unexported fields
}
Format 0: byte encoding table
func (*CMapFormat0) Enumerate ¶
func (f *CMapFormat0) Enumerate(fn func(rune, uint16))
func (*CMapFormat0) Format ¶
func (f *CMapFormat0) Format() uint16
func (*CMapFormat0) Map ¶
func (f *CMapFormat0) Map(r rune) uint16
type CMapFormat4 ¶
type CMapFormat4 struct {
// contains filtered or unexported fields
}
Format 4: segment mapping to delta values
func (*CMapFormat4) Enumerate ¶
func (f *CMapFormat4) Enumerate(fn func(rune, uint16))
func (*CMapFormat4) Format ¶
func (f *CMapFormat4) Format() uint16
func (*CMapFormat4) Map ¶
func (f *CMapFormat4) Map(r rune) uint16
type CMapFormat6 ¶
type CMapFormat6 struct {
// contains filtered or unexported fields
}
Format 6: trimmed table mapping
func (*CMapFormat6) Enumerate ¶
func (f *CMapFormat6) Enumerate(fn func(rune, uint16))
func (*CMapFormat6) Format ¶
func (f *CMapFormat6) Format() uint16
func (*CMapFormat6) Map ¶
func (f *CMapFormat6) Map(r rune) uint16
type CMapFormat12 ¶
type CMapFormat12 struct {
// contains filtered or unexported fields
}
func (*CMapFormat12) Enumerate ¶
func (f *CMapFormat12) Enumerate(fn func(rune, uint16))
func (*CMapFormat12) Format ¶
func (f *CMapFormat12) Format() uint16
func (*CMapFormat12) Map ¶
func (f *CMapFormat12) Map(r rune) uint16
type CMapSubtable ¶
type ClassDef ¶
type ClassDef struct {
Format uint16 // 1 = sequential, 2 = ranges
StartGlyph uint16 // Format 1
ClassValues []uint16 // Format 1
Ranges []ClassRangeRecord // Format 2
}
ClassDef represents a class definition table (format 1 or 2).
type ClassRangeRecord ¶
type ClassRangeRecord struct {
Start uint16 // startGlyphID
End uint16 // endGlyphID
Class uint16 // classValue
}
ClassRangeRecord represents a range record in ClassDef format 2.
type CompositeGlyph ¶
type CompositeGlyph struct {
// contains filtered or unexported fields
}
type Coverage ¶
type Coverage struct {
Format uint16 // 1 = glyph list, 2 = ranges
Glyphs []uint16 // Format 1
Ranges []CoverageRange // Format 2
}
Coverage represents a glyph coverage table (format 1 or 2).
type CoverageRange ¶
type CoverageRange struct {
Start uint16 // startGlyphID
End uint16 // endGlyphID
Index uint16 // startCoverageIndex
}
CoverageRange represents a range record in Coverage format 2.
type Cvt ¶
type Cvt struct {
// contains filtered or unexported fields
}
Cvt holds the cvt (Control Value Table) data. It contains an array of FWord (int16) values used by the TrueType interpreter.
type FeatureList ¶
type FeatureList struct {
Records []FeatureRecord
}
FeatureList represents the list of features in an OpenType Layout table.
type FeatureRecord ¶
type FeatureRecord struct {
Tag [4]byte
Feature FeatureTable
}
FeatureRecord maps a feature tag to its feature table.
type FeatureTable ¶
FeatureTable represents a feature table.
type Fixed2_14 ¶
type Fixed2_14 int16
16-bit signed fixed number with the low 14 bits representing fraction.
type Fixed16_16 ¶
Fixed is a 16.16 fixed-point number.
func (Fixed16_16) Float ¶
func (f Fixed16_16) Float() float64
func (Fixed16_16) String ¶
func (f Fixed16_16) String() string
type Fpgm ¶
type Fpgm struct {
// contains filtered or unexported fields
}
Fpgm holds the fpgm (Font Program) table data. This TrueType bytecode is executed once when the font is first loaded.
type GPOS ¶
type GPOS struct {
MajorVersion uint16
MinorVersion uint16
ScriptList ScriptList
FeatureList FeatureList
LookupList OTLookupList
}
GPOS represents the Glyph Positioning table.
type GSUB ¶
type GSUB struct {
MajorVersion uint16
MinorVersion uint16
ScriptList ScriptList
FeatureList FeatureList
LookupList OTLookupList
}
GSUB represents the Glyph Substitution table.
type GlyphComponent ¶
type GlyphComponent struct {
// contains filtered or unexported fields
}
type GlyphHeader ¶
type GlyphHeader struct {
// contains filtered or unexported fields
}
type GlyphPath ¶
type GlyphPath struct {
Segments []PathSegment
XMin, YMin, XMax, YMax float32
}
GlyphPath holds the outline path data for a single glyph. Coordinates are absolute, in font design units, Y-up.
type Kern ¶
type Kern struct {
// contains filtered or unexported fields
}
Kern represents the kerning table.
type KernSubtable ¶
type KernSubtable struct {
// contains filtered or unexported fields
}
KernSubtable represents a single subtable within the kern table.
type LangSysRecord ¶
LangSysRecord maps a language tag to its LangSys table.
type LangTagRecord ¶
type LangTagRecord struct {
// contains filtered or unexported fields
}
type LittleEndian ¶
type LittleEndian struct {
// contains filtered or unexported fields
}
func (*LittleEndian) Append ¶
func (l *LittleEndian) Append(bytes []byte)
func (*LittleEndian) Bytes ¶
func (l *LittleEndian) Bytes(n int) []byte
func (*LittleEndian) Fixed16_16 ¶
func (l *LittleEndian) Fixed16_16() (f Fixed16_16)
func (*LittleEndian) I8 ¶
func (l *LittleEndian) I8() (i8 int8)
func (*LittleEndian) I16 ¶
func (l *LittleEndian) I16() (i16 int16)
func (*LittleEndian) I32 ¶
func (l *LittleEndian) I32() (i32 int32)
func (*LittleEndian) I64 ¶
func (l *LittleEndian) I64() (i64 int64)
func (*LittleEndian) Offset ¶
func (l *LittleEndian) Offset() int
func (*LittleEndian) PutFixed16_16 ¶
func (l *LittleEndian) PutFixed16_16(f Fixed16_16)
func (*LittleEndian) PutU8 ¶
func (l *LittleEndian) PutU8(u8 uint8)
func (*LittleEndian) PutU16 ¶
func (l *LittleEndian) PutU16(u16 uint16)
func (*LittleEndian) PutU32 ¶
func (l *LittleEndian) PutU32(u32 uint32)
func (*LittleEndian) PutU64 ¶
func (l *LittleEndian) PutU64(u64 uint64)
func (*LittleEndian) Read ¶
func (l *LittleEndian) Read(n int) []byte
func (*LittleEndian) Slice ¶
func (l *LittleEndian) Slice(n int) Binary
func (*LittleEndian) U8 ¶
func (l *LittleEndian) U8() (u8 uint8)
func (*LittleEndian) U16 ¶
func (l *LittleEndian) U16() (u16 uint16)
func (*LittleEndian) U32 ¶
func (l *LittleEndian) U32() (u32 uint32)
func (*LittleEndian) U64 ¶
func (l *LittleEndian) U64() (u64 uint64)
type LongHorMetric ¶
type LongHorMetric struct {
// contains filtered or unexported fields
}
type NameRecord ¶
type NameRecord struct {
// contains filtered or unexported fields
}
type OTLookup ¶
type OTLookup struct {
LookupType uint16
LookupFlag uint16
MarkFilteringSet uint16
SubTables [][]byte // raw subtable data
}
OTLookup represents a single lookup table.
type OTLookupList ¶
type OTLookupList struct {
Lookups []OTLookup
}
OTLookupList represents the list of lookups in an OpenType Layout table.
type PathSegment ¶
PathSegment represents one path drawing command with absolute coordinates in font design units (Y-axis points up, per OpenType convention).
type Prep ¶
type Prep struct {
// contains filtered or unexported fields
}
Prep holds the prep (Control Value Program) table data. This TrueType bytecode is executed whenever the font size or transformation changes.
type ScriptList ¶
type ScriptList struct {
Records []ScriptRecord
}
ScriptList represents the list of scripts in an OpenType Layout table.
type ScriptRecord ¶
type ScriptRecord struct {
Tag [4]byte
Script ScriptTable
}
ScriptRecord maps a script tag to its script table.
type ScriptTable ¶
type ScriptTable struct {
DefaultLangSys *LangSys
LangSysRecords []LangSysRecord
}
ScriptTable represents a script table with optional default LangSys and language-specific records.
type SequentialMapGroup ¶
type SequentialMapGroup struct {
// contains filtered or unexported fields
}
Format 12: segmented coverage (32-bit)
type SimpleGlyph ¶
type SimpleGlyph struct {
// contains filtered or unexported fields
}
type TableDirectory ¶
type TableDirectory struct {
// contains filtered or unexported fields
}
type TrueTypeFont ¶
type TrueTypeFont struct {
// contains filtered or unexported fields
}
func Parse ¶
func Parse(data []byte) (TrueTypeFont, error)
Parse parses TTF binary data and returns a TrueTypeFont.
func ParseEOT ¶
func ParseEOT(data []byte) (TrueTypeFont, error)
ParseEOT parses an EOT (Embedded OpenType) file and returns a TrueTypeFont.
func ParseTTC ¶
func ParseTTC(data []byte) ([]TrueTypeFont, error)
ParseTTC parses a TTC (TrueType Collection) file and returns all fonts within it.
func ParseWOFF ¶
func ParseWOFF(data []byte) (TrueTypeFont, error)
ParseWOFF parses a WOFF (Web Open Font Format) file and returns a TrueTypeFont. It decompresses the WOFF table data and delegates to the standard TTF parser.
func ParseWOFF2 ¶
func ParseWOFF2(data []byte) (TrueTypeFont, error)
ParseWOFF2 parses a WOFF2 (Web Open Font Format 2) file and returns a TrueTypeFont.
func (*TrueTypeFont) AdvanceWidth ¶
func (ttf *TrueTypeFont) AdvanceWidth(glyphID uint16) uint16
AdvanceWidth returns the advance width for the given glyph ID.
func (*TrueTypeFont) AdvanceWidthForRune ¶
func (ttf *TrueTypeFont) AdvanceWidthForRune(r rune) uint16
AdvanceWidthForRune returns the advance width for the glyph mapped to the given rune.
func (*TrueTypeFont) AppendGlyph ¶
func (ttf *TrueTypeFont) AppendGlyph(g *Glyph) (int, error)
AppendGlyph adds a new glyph to the font and returns its index.
func (*TrueTypeFont) Ascent ¶
func (ttf *TrueTypeFont) Ascent() int16
Ascent returns the font ascent value from hhea table.
func (*TrueTypeFont) CFFFontName ¶
func (ttf *TrueTypeFont) CFFFontName() string
CFFFontName returns the CFF font name. Returns "" for non-CFF fonts.
func (*TrueTypeFont) CFFGlyphName ¶
func (ttf *TrueTypeFont) CFFGlyphName(glyphID int) string
CFFGlyphName returns the glyph name for the given glyph ID. Works for both CFF (via charset) and TrueType (via post table) fonts.
func (*TrueTypeFont) CFFOutlineAt ¶
func (ttf *TrueTypeFont) CFFOutlineAt(index int) *CFFOutline
CFFOutlineAt decodes and returns the CFF outline for the glyph at index. Returns nil for non-CFF fonts or out-of-range indices.
func (*TrueTypeFont) CFFOutlineForRune ¶
func (ttf *TrueTypeFont) CFFOutlineForRune(r rune) *CFFOutline
CFFOutlineForRune decodes and returns the CFF outline for the glyph mapped to r. Returns nil for non-CFF fonts or unmapped runes.
func (*TrueTypeFont) CapHeight ¶
func (ttf *TrueTypeFont) CapHeight() int16
CapHeight returns the cap height from OS/2 table.
func (*TrueTypeFont) CaretSlope ¶
func (ttf *TrueTypeFont) CaretSlope() (run, rise int16)
CaretSlope returns the caret slope (run, rise) from hhea table.
func (*TrueTypeFont) ContourCount ¶
func (ttf *TrueTypeFont) ContourCount(index int) int
ContourCount returns the number of contours in the glyph at index. Returns 0 for composite glyphs or out-of-range indices.
func (*TrueTypeFont) CopyGlyph ¶
func (ttf *TrueTypeFont) CopyGlyph(srcIndex, dstIndex int) error
CopyGlyph copies the glyph data from srcIndex to dstIndex.
func (*TrueTypeFont) Descent ¶
func (ttf *TrueTypeFont) Descent() int16
Descent returns the font descent value from hhea table.
func (*TrueTypeFont) FontBBox ¶
func (ttf *TrueTypeFont) FontBBox() (xMin, yMin, xMax, yMax int16)
FontBBox returns the global font bounding box (min/max across all glyphs).
func (*TrueTypeFont) FontFamily ¶
func (ttf *TrueTypeFont) FontFamily() string
FontFamily returns the font family name (nameID 1).
func (*TrueTypeFont) FontFullName ¶
func (ttf *TrueTypeFont) FontFullName() string
FontFullName returns the full font name (nameID 4).
func (*TrueTypeFont) GlyphAt ¶
func (ttf *TrueTypeFont) GlyphAt(index int) *Glyph
GlyphAt returns the glyph at the given index, or nil if out of range.
func (*TrueTypeFont) GlyphBBox ¶
func (ttf *TrueTypeFont) GlyphBBox(index int) (xMin, yMin, xMax, yMax int16, ok bool)
GlyphBBox returns the bounding box of the glyph at index. Returns ok=false if the index is out of range.
func (*TrueTypeFont) GlyphForRune ¶
func (ttf *TrueTypeFont) GlyphForRune(r rune) *Glyph
GlyphForRune returns the glyph data for a Unicode code point, or nil if not mapped.
func (*TrueTypeFont) GlyphPath ¶
func (f *TrueTypeFont) GlyphPath(glyphIndex int) (*GlyphPath, error)
GlyphPath returns the outline path for the glyph at the given index. Works for both TrueType (quadratic beziers) and CFF/OpenType (cubic beziers) fonts. Returns an empty path (no segments) for glyphs with no outline (e.g. space, .notdef).
func (*TrueTypeFont) IsCFF ¶
func (ttf *TrueTypeFont) IsCFF() bool
IsCFF reports whether the font uses CFF outlines (OpenType/CFF, version "OTTO").
func (*TrueTypeFont) IsCompositeGlyph ¶
func (ttf *TrueTypeFont) IsCompositeGlyph(index int) bool
IsCompositeGlyph reports whether the glyph at index is a composite glyph.
func (*TrueTypeFont) IsSimpleGlyph ¶
func (ttf *TrueTypeFont) IsSimpleGlyph(index int) bool
IsSimpleGlyph reports whether the glyph at index is a simple glyph.
func (*TrueTypeFont) KernPair ¶
func (ttf *TrueTypeFont) KernPair(left, right uint16) int16
KernPair returns the kerning value between two glyph IDs. Returns 0 if no kerning pair exists or the kern table is not present.
func (*TrueTypeFont) LeftSideBearing ¶
func (ttf *TrueTypeFont) LeftSideBearing(glyphID uint16) int16
LeftSideBearing returns the left side bearing for the given glyph ID.
func (*TrueTypeFont) LineGap ¶
func (ttf *TrueTypeFont) LineGap() int16
LineGap returns the font line gap value from hhea table.
func (*TrueTypeFont) MappedRunes ¶
func (ttf *TrueTypeFont) MappedRunes() []rune
MappedRunes returns all Unicode code points that have a glyph mapping.
func (*TrueTypeFont) NumGlyphs ¶
func (ttf *TrueTypeFont) NumGlyphs() int
NumGlyphs returns the number of glyphs in the font.
func (*TrueTypeFont) PointCount ¶
func (ttf *TrueTypeFont) PointCount(index int) int
PointCount returns the number of points in the glyph at index. Returns 0 for composite glyphs or out-of-range indices.
func (*TrueTypeFont) RemoveGlyphs ¶
func (ttf *TrueTypeFont) RemoveGlyphs(indices []int) (remap map[int]int, err error)
RemoveGlyphs removes glyphs at the given indices and compacts all related tables. Returns a remap table: old index → new index. Indices not in the map were removed. Glyph 0 (.notdef) cannot be removed.
func (*TrueTypeFont) RemoveRuneMapping ¶
func (ttf *TrueTypeFont) RemoveRuneMapping(r rune)
RemoveRuneMapping removes the mapping for a Unicode code point.
func (*TrueTypeFont) RuneMappings ¶
func (ttf *TrueTypeFont) RuneMappings() []struct { Rune rune GlyphID uint16 }
RuneMappings returns all rune-to-glyph mappings sorted by rune value.
func (*TrueTypeFont) RuneToGlyphID ¶
func (ttf *TrueTypeFont) RuneToGlyphID(r rune) uint16
RuneToGlyphID returns the glyph ID for a Unicode code point, or 0 if not mapped.
func (*TrueTypeFont) ScaleGlyph ¶
func (ttf *TrueTypeFont) ScaleGlyph(index int, sx, sy float64) error
ScaleGlyph scales all coordinates of the glyph at index by factors sx and sy. Coordinates are rounded to nearest integer after scaling.
func (*TrueTypeFont) Serialize ¶
func (ttf *TrueTypeFont) Serialize() ([]byte, error)
func (*TrueTypeFont) SerializeEOT ¶
func (ttf *TrueTypeFont) SerializeEOT() ([]byte, error)
SerializeEOT serializes the font as an EOT (Embedded OpenType) file.
func (*TrueTypeFont) SerializeWOFF ¶
func (ttf *TrueTypeFont) SerializeWOFF() ([]byte, error)
SerializeWOFF serializes the font as a WOFF (Web Open Font Format) file.
func (*TrueTypeFont) SerializeWOFF2 ¶
func (ttf *TrueTypeFont) SerializeWOFF2() ([]byte, error)
SerializeWOFF2 serializes the font as a WOFF2 file. No table transforms are applied (all tables stored raw).
func (*TrueTypeFont) SetAdvanceWidth ¶
func (ttf *TrueTypeFont) SetAdvanceWidth(glyphID uint16, width uint16) error
SetAdvanceWidth sets the advance width for the given glyph ID.
func (*TrueTypeFont) SetFontFamily ¶
func (ttf *TrueTypeFont) SetFontFamily(name string)
SetFontFamily sets the font family name (nameID 1).
func (*TrueTypeFont) SetFontFullName ¶
func (ttf *TrueTypeFont) SetFontFullName(name string)
SetFontFullName sets the full font name (nameID 4).
func (*TrueTypeFont) SetGlyphAt ¶
func (ttf *TrueTypeFont) SetGlyphAt(index int, g *Glyph) error
SetGlyphAt replaces the glyph data at the given index. Returns an error if the index is out of range.
func (*TrueTypeFont) SetLeftSideBearing ¶
func (ttf *TrueTypeFont) SetLeftSideBearing(glyphID uint16, lsb int16) error
SetLeftSideBearing sets the left side bearing for the given glyph ID.
func (*TrueTypeFont) SetRuneMapping ¶
func (ttf *TrueTypeFont) SetRuneMapping(r rune, glyphID uint16) error
SetRuneMapping maps a Unicode code point to the given glyph ID. Returns an error if glyphID is out of range.
func (*TrueTypeFont) SetRuneMappings ¶
func (ttf *TrueTypeFont) SetRuneMappings(mappings map[rune]uint16) error
SetRuneMappings sets multiple rune-to-glyph mappings at once.
func (*TrueTypeFont) Subset ¶
func (ttf *TrueTypeFont) Subset(keepRunes []rune) error
Subset removes all glyphs that are not needed by the specified runes. Glyph 0 (.notdef) is always kept. Glyphs not referenced by any rune in keepRunes are removed. Composite glyph dependencies are automatically preserved.
func (*TrueTypeFont) TranslateGlyph ¶
func (ttf *TrueTypeFont) TranslateGlyph(index int, dx, dy int16) error
TranslateGlyph shifts all coordinates of the glyph at index by (dx, dy).
func (*TrueTypeFont) UnitsPerEm ¶
func (ttf *TrueTypeFont) UnitsPerEm() uint16
UnitsPerEm returns the font's units per em value (design space size).
func (*TrueTypeFont) XHeight ¶
func (ttf *TrueTypeFont) XHeight() int16
XHeight returns the x-height from OS/2 table.