FontMetrics class

Typographic metrics for a loaded TTF/OTF font.

All values are in font design units (as stored in the font file). To convert to pixels at a given fontSize:

final scale = fontSize / metrics.unitsPerEm;
final ascenderPx = metrics.ascender * scale;

Constructors

FontMetrics({required int unitsPerEm, required int ascender, required int descender, required int lineGap, required int capHeight, required int xHeight})
const

Properties

ascender int
Distance from the baseline to the top of the em square, in font units.
final
capHeight int
Height of capital letters above the baseline, in font units.
final
descender int
Distance from the baseline to the bottom of the em square, in font units.
final
hashCode int
The hash code for this object.
no setterinherited
lineGap int
Additional line spacing recommended by the font designer, in font units.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unitsPerEm int
Number of font design units per em.
final
xHeight int
Height of lowercase 'x' above the baseline, in font units.
final

Methods

baselineOffsetAt(double fontSize) double
Distance from the top of the line box to the baseline, in pixels.
lineHeightAt(double fontSize) double
Line height recommended for this font at the given fontSize in pixels.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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