TtfParser class
Low-level binary parser for TrueType (glyf-based) font files.
Parses the TTF table structure and provides access to font metrics, the character-to-glyph mapping (cmap), glyph outlines (glyf), horizontal metrics (hmtx), and pair-kerning (kern).
Usage — prefer the higher-level TtfFont wrapper which adds caching and a friendlier API:
final parser = TtfParser(bytes); // parses table directory + head/hhea/maxp
final metrics = parser.parseFontMetrics();
final cmap = parser.parseCmap();
Supported tables: head, hhea, maxp, OS/2, cmap (format 4 &
12), loca, glyf (simple + composite), hmtx, kern (format 0).
Not supported: CFF/CFF2 (CFF table), GPOS kerning, vertical metrics.
Properties
-
availableTables
→ Set<
String> -
The set of table tags present in this font.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isTrueType → bool
-
Whether the font uses a
glyftable (TrueType) vsCFF(OpenType/CFF).no setter - numGlyphs → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unitsPerEm → int
-
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseCmap(
) → Map< int, int> - Returns a map from Unicode code point to glyph ID.
-
parseFontMetrics(
) → FontMetrics - Parses and returns the font-level typographic metrics.
-
parseGlyphContours(
int glyphId) → List< GlyphContour> ? -
Parses the contours for
glyphId. -
parseHmtx(
) → List< ({int advanceWidth, int lsb})> -
Returns
(advanceWidth, lsb)pairs in font units for each glyph. -
parseKern(
) → Map< (int, int), int> - Returns pair-kerning values in font units.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited