parseFontMetrics method
Parses and returns the font-level typographic metrics.
Implementation
FontMetrics parseFontMetrics() {
// hhea: ascender @ +4, descender @ +6, lineGap @ +8
int ascender = 0, descender = 0, lineGap = 0;
final hhea = _tableOffsets['hhea'];
if (hhea != null) {
ascender = _data.getInt16(hhea + 4);
descender = _data.getInt16(hhea + 6);
lineGap = _data.getInt16(hhea + 8);
}
// OS/2: capHeight @ +88, xHeight @ +86 (version ≥ 2 only)
int capHeight = 0, xHeight = 0;
final os2 = _tableOffsets['OS/2'];
if (os2 != null) {
final version = _data.getUint16(os2);
if (version >= 2) {
xHeight = _data.getInt16(os2 + 86);
capHeight = _data.getInt16(os2 + 88);
}
}
return FontMetrics(
unitsPerEm: _unitsPerEm,
ascender: ascender,
descender: descender,
lineGap: lineGap,
capHeight: capHeight,
xHeight: xHeight,
);
}