Four optional tables from the early years of TrueType. kern adjusts the
space between pairs of glyphs; OpenType’s GPOS table does this better and
is required for CFF fonts, but many TrueType fonts still carry kern for older
software. The other three save a layout engine from running the hinting instructions
just to learn how wide or tall glyphs come out at a given size: hdmx
stores hinted widths, LTSH the size from which widths scale linearly, and
VDMX hinted heights. They are only worth including when hinting changes
widths, that is when bit 4 of the head flags is set.
kern: kerning
This is the OpenType (Microsoft) form. Apple’s kern has a different
header, a 32-bit version 0x00010000 and 32-bit subtable count, and more
subtable formats; OpenType does not support those.
| Type | Name | Description |
|---|---|---|
uint16 | version | 0. |
uint16 | nTables | The number of subtables, which follow directly. |
Each subtable starts with a 6-byte header:
| Type | Name | Description |
|---|---|---|
uint16 | version | 0. |
uint16 | length | The subtable’s length in bytes, header included. |
uint16 | coverage | Bit fields, below; the format is the high byte. |
| Bits | Name | Meaning |
|---|---|---|
| 0 | horizontal | 1 for horizontal text, 0 for vertical. |
| 1 | minimum | 1: the values are minimums that limit the total of kerning and tracking; 0: kerning values. Minimum subtables usually come last. |
| 2 | cross-stream | 1: kern across the line, up and down in horizontal text, left and right in vertical. A value of 0x8000 resets cross-stream kerning to 0. |
| 3 | override | 1: this subtable’s value replaces the total so far instead of adding to it. |
| 4 to 7 | reserved | 0. |
| 8 to 15 | format | 0 or 2; 1 and 3 to 255 are reserved. Windows supports only format 0. |
Format 0: pairs
| Type | Name | Description |
|---|---|---|
uint16 | nPairs | The number of pairs. |
uint16 | searchRange | The largest power of 2 not above nPairs, times 6. |
uint16 | entrySelector | log2 of that power of 2. |
uint16 | rangeShift | (nPairs − that power of 2) × 6. |
record × nPairs | kernPairs | 6 bytes each: left and right glyph IDs (uint16) and value (FWORD; positive moves the glyphs apart, negative closer). |
Pairs are sorted by left × 65,536 + right, as one unsigned 32-bit number. Because the
subtable’s length is 16-bit, it cannot describe a subtable longer than
65,535 bytes, which is about 10,920 pairs.
Format 2: class array
Glyphs are grouped into left-hand and right-hand classes, and a two-dimensional array gives a value for each pair of classes. Row 0 and column 0 are the classes of glyphs that do not kern, all zeros.
| Type | Name | Description |
|---|---|---|
uint16 | rowWidth | The width of one row of the array in bytes. |
Offset16 | leftClassOffset | The left-hand class table, from the start of the subtable. |
Offset16 | rightClassOffset | The right-hand class table. |
Offset16 | kerningArrayOffset | The array of FWORD values, stored by row. |
A class table is firstGlyph and nGlyphs (both
uint16), then one uint16 per glyph. The values are already
scaled: left classes are multiplied by the row width, right classes by 2, so the
value for a pair is found by adding the left and right class values to the address
of the array. Glyphs outside a class table’s range, or that do not kern, get class
0.
hdmx: horizontal device metrics
Hinted advance widths in whole pixels for chosen sizes, so text can be laid out without running the instructions.
| Type | Name | Description |
|---|---|---|
uint16 | version | 0. |
uint16 | numRecords | The number of device records. |
uint32 | sizeDeviceRecord | The size of each record, a multiple of 4. |
record × numRecords | records | Sorted by size. Each: pixelSize (uint8, pixels per em), maxWidth (uint8, the largest width), widths (uint8 × numGlyphs, each glyph’s width in pixels), then zeros to the next multiple of 4. |
Sizes are measured on the y axis; for non-square pixels the record for the em’s width in pixels is used, so a 12-point em at 72 × 96 dpi uses the 16-pixel record.
LTSH: linear threshold
| Type | Name | Description |
|---|---|---|
uint16 | version | 0. |
uint16 | numGlyphs | As in maxp. |
uint8 × numGlyphs | yPels | For each glyph, the size in pixels per em from which its advance width scales linearly. 1 for glyphs whose side bearings have no instructions. |
A width counts as linear when the hinted width equals the scaled width, or when the size is at least 50 ppem and they differ by at most 2%. From the threshold upwards it must stay linear at every size.
VDMX: vertical device metrics
Windows clips glyphs to usWinAscent and usWinDescent.
Hinting can push glyphs beyond the scaled values, so VDMX stores the
real hinted highest and lowest pixel for each size, and overrides the
OS/2 values where it has data.
| Type | Name | Description |
|---|---|---|
uint16 | version | 0 or 1; 1 is recommended. |
uint16 | numRecs | The number of groups. |
uint16 | numRatios | The number of aspect ratio ranges. |
record × numRatios | ratRange | 4 bytes each: bCharSet, xRatio, yStartRatio, yEndRatio (all uint8). |
Offset16 × numRatios | vdmxGroupOffsets | For each ratio range, its group, from the start of the table. |
A device matches a range when its x ratio equals xRatio and its y ratio
is from yStartRatio to yEndRatio: 1, 1, 1 is 1:1; 2, 1, 2
covers 1:1 to 2:1; 4, 3, 3 is 1.33:1. The first match is used. 0, 0, 0 matches every
ratio and must be last; with no match and no 0, 0, 0 range there is no data.
bCharSet | Version 0 | Version 1 |
|---|---|---|
| 0 | All glyphs; used for symbol fonts. | All glyphs; added alongside 1 when new character sets are added to an existing font. |
| 1 | Computed from the Windows ANSI glyphs only; Windows ignores other entries. | All glyphs; used for new Windows fonts. |
Each group is recs (uint16), startsz and
endsz (uint8, the first and last size), then
recs 6-byte entries of yPelHeight (uint16),
yMax and yMin (int16, in pixels), sorted by
size. Entries are needed only for sizes where the hinted values differ from the
scaled and rounded ones; above 255 ppem all sizes are assumed linear.
Tables not yet on these pages
A TrueType font may also hold vhea and vmtx (vertical
metrics), PCLT, DSIG, meta,
MERG, the embedded and colour bitmap tables, COLR and
CPAL, SVG , the OpenType layout tables
(GDEF, GSUB, GPOS, BASE,
JSTF, MATH) and the variation tables. This site does not yet
document their fields; see the OpenType specification.