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), fontindex.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 - bbox → ({int xMax, int xMin, int yMax, int yMin})?
-
The bounding box of all glyphs (
head), font units; null withouthead.latefinal - 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
MATHtable over this font's data (seeMathTable.empty).no setter - familyName → String?
-
Family name (name id 1), if present.
latefinal
- fsSelection → int?
-
OS/2font selection flags (fsSelection: italic, bold, regular,USE_TYPO_METRICS…), or null withoutOS/2.latefinal - fsType → int?
-
OS/2embedding permissions (fsType), or null withoutOS/2: 0 installable; bit 1 (0x2) restricted (no embedding), bit 2 (0x4) preview and print, bit 3 (0x8) editable; bit 8 (0x100) no subsetting; bit 9 (0x200) bitmap embedding only.latefinal - fullName → String?
-
Full name (name id 4), if present.
latefinal
- glyphCount → int
-
Number of glyphs.
latefinal
- gsub → GsubTable?
-
The
GSUBtable (script-size and mirrored forms), or null.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
- isFixedPitch → bool?
-
Whether
postsays the font is monospaced; null withoutpost.latefinal - 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 - lineGap → int?
-
hhealine gap, font units; null withouthhea.latefinal - macStyle → int?
-
headstyle bits (macStyle: 0x1 bold, 0x2 italic…); null withouthead.latefinal - math → MathTable?
-
The
MATHtable, or null for fonts without one. At an instance its values add their VariationIndex deltas from theGDEFitem variation store; it is the default's whenGDEFhas 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
- typoAscender → int?
-
OS/2typographic ascender (sTypoAscender), font units; null withoutOS/2.latefinal - typoDescender → int?
-
OS/2typographic descender (sTypoDescender, negative), font units; null withoutOS/2.latefinal - typoLineGap → int?
-
OS/2typographic line gap (sTypoLineGap), font units; null withoutOS/2.latefinal - underlinePosition → int?
-
postunderline position (top of the underline, negative below the baseline), font units; null withoutpost.latefinal - underlineThickness → int?
-
postunderline thickness, font units; null withoutpost.latefinal - unitsPerEm → int
-
Font units per em.
latefinal
- useTypoMetrics → bool?
-
Whether
OS/2asks for its typographic metrics to set line spacing (fsSelectionbit 7,USE_TYPO_METRICS); null withoutOS/2.no setter -
variations
→ Map<
String, double> -
The axis values of this instance, tag → value, for every axis.
no setter
- weightClass → int?
-
OS/2weight class (usWeightClass: 400 regular, 700 bold), or null withoutOS/2.latefinal - winAscent → int?
-
OS/2clipping ascent (usWinAscent, positive), font units; null withoutOS/2(or one too short to have it).latefinal - winDescent → int?
-
OS/2clipping descent (usWinDescent, positive below the baseline), font units; null withoutOS/2.latefinal - xHeight → int
-
x-height, font units (from
OS/2version ≥ 2, else the height ofx).latefinal
Methods
-
advance(
int glyph) → int -
Advance width of
glyph, font units: at an instance, with itsHVARdelta, or from its varied phantom points withoutHVAR. -
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). -
kernPair(
int left, int right) → int -
The kerning between glyphs
leftandrightfrom thekerntable's horizontal format 0 subtables (fonts without GPOS kerning), font units; 0 when there is none. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
outline(
int glyph) → GlyphPath -
The outline of
glyphin font units, y up. Cached. -
tableBytes(
String tag) → Uint8List? -
A view of table
tag's bytes, or null when absent (or out of the file's bounds). -
tableLength(
String tag) → int? -
The length in bytes of table
tag, or null when absent. -
tableOffset(
String tag) → int? -
The offset of table
tagin bytes, or null when absent. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited