Appearance
Function: parseFontMetrics() ​
parseFontMetrics(
data,opts?):Promise<FontMetrics>
Parse a font file into a FontMetrics. Lazily imports opentype.js.
Reads plain TTF/OTF and font collections (.ttc/.otc); for a collection, pass font to say which member, since a collection has no single answer. The underlying parser does not read the ttcf wrapper, so the selected member is unwrapped into a standalone sfnt first (see measure/font-collection.ts).
Parameters ​
| Parameter | Type | Description |
|---|---|---|
data | Uint8Array | the font file's bytes |
opts? | ParseFontMetricsOptions | which font, for a file holding several |
Returns ​
Promise<FontMetrics>
advance widths and cmap coverage for that font
Examples ​
ts
await parseFontMetrics(bytes) // a plain .ttfts
await parseFontMetrics(ttcBytes, { font: 'MS PGothic' })