Table
hhea— Horizontal Header (OT §6.4.3), 36 bytes.
Module tableHhea | Source packages/front/office/fonts/src/table/hhea.js | Deps fontErrors, fontReader, fontWriter | Worker-safe yes
Drives how advance widths are interpreted in hmtx via numberOfHMetrics, which decides how many full records precede the lsb-only tail.
Resolve
const { parseHhea, encodeHhea } = runtime.resolve('tableHhea');
API
| Method | Signature | Returns |
|---|---|---|
parseHhea |
(bytes: Uint8Array) => HheaTable |
Throws if < 36 bytes. |
encodeHhea |
(hhea: HheaTable) => Uint8Array |
Exactly 36 bytes. |
HheaTable
| Field | Type |
|---|---|
majorVersion, minorVersion |
uint16 |
ascender, descender, lineGap |
int16 |
advanceWidthMax |
uint16 |
minLeftSideBearing, minRightSideBearing, xMaxExtent |
int16 |
caretSlopeRise, caretSlopeRun, caretOffset |
int16 |
metricDataFormat |
int16 |
numberOfHMetrics |
uint16 |
Examples
const { parseHhea } = runtime.resolve('tableHhea');
const hhea = parseHhea(sfnt.tables.hhea.bytes);
console.log(hhea.ascender, hhea.numberOfHMetrics);
Notes
- 4 reserved
int16records (betweencaretOffsetandmetricDataFormat) are read then discarded at parse time, written as zero at encode. numberOfHMetricsmust be ≥ 1 and ≤maxp.numGlyphs— validated on thehmtxside.