OpenTypeFont class final

An OpenType (or TrueType) font, parsed in pure Dart.

Reads the tables math layout needs: head, hhea, maxp, hmtx, cmap, OS/2, post, name, MATH, and outlines from CFF , CFF2 or glyf. Tables are parsed lazily; outlines are cached per glyph.

A variable font (fvar) is parsed at its default instance; instance gives it at other axis values (through avar 1 or 2), with gvar or blended CFF2 outlines, HVAR (or phantom-point) advances, MVAR metrics, the MATH table's device deltas and the layout tables' device deltas and feature variations at those values.

Constructors

OpenTypeFont.parse(Uint8List bytes, {int index = 0})
Parses bytes; from a TrueType collection (.ttc), font index.
factory

Properties

ascender → int
Typographic ascender (hhea), font units.
latefinal
axes → List<FontAxis>
The variation axes (fvar); empty when the font does not vary.
no setter
bytes → Uint8List
The font file.
final
capHeight → int
Cap height, font units.
latefinal
codePoints → Iterable<int>
All mapped code points.
no setter
descender → int
Typographic descender (hhea, negative), font units.
latefinal
emptyMath → MathTable
An empty MATH table over this font's data (see MathTable.empty).
no setter
familyName → String?
Family name (name id 1), if present.
latefinal
fullName → String?
Full name (name id 4), if present.
latefinal
glyphCount → int
Number of glyphs.
latefinal
gsub → GsubTable?
The GSUB table (script-size and mirrored forms), or null.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
italicAngle → double
Italic angle in degrees (negative leans right).
latefinal
layout → OtLayout
The text layout tables (GSUB, GPOS, GDEF) for shaping text, at this instance.
latefinal
math → MathTable?
The MATH table, or null for fonts without one. At an instance its values add their VariationIndex deltas from the GDEF item variation store; it is the default's when GDEF has none.
latefinal
namedInstances → List<NamedInstance>
The named instances (fvar): "Bold", "Condensed"… and their axis values, for instance.
no setter
normalizedCoordinates → List<double>
Normalized coordinates of this instance, one per axis (−1…1); empty for the default instance.
final
reader → FontReader
A reader over the font file (for tables read elsewhere).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tableTags → Iterable<String>
Tags of the tables present.
no setter
unitsPerEm → int
Font units per em.
latefinal
variations → Map<String, double>
The axis values of this instance, tag → value, for every axis.
no setter
xHeight → int
x-height, font units (from OS/2 version ≥ 2, else the height of x).
latefinal

Methods

advance(int glyph) → int
Advance width of glyph, font units: at an instance, with its HVAR delta, or from its varied phantom points without HVAR.
glyphForCodePoint(int codePoint) → int
The glyph for Unicode codePoint, or 0 (.notdef).
hasCodePoint(int codePoint) → bool
Whether the font maps codePoint.
instance(Map<String, double> values) → OpenTypeFont
This font at axis values (tag → value in the axis's own units, as in {'wght': 700, 'wdth': 75}), with its own outline and advance caches. Axes left out take their defaults; values are clamped to the axis range; tags the font has no axis for are ignored. Always made from the default instance, so values do not add up. Instances are cached, and one at the default coordinates is the default font itself (as is any instance of a font that does not vary).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outline(int glyph) → GlyphPath
The outline of glyph in font units, y up. Cached.
tableLength(String tag) → int?
The length in bytes of table tag, or null when absent.
tableOffset(String tag) → int?
The offset of table tag in bytes, or null when absent.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited