d2lang/d2 · warning
unsupported kern table coverage 0x%04x
Error message
unsupported kern table coverage 0x%04x
What it means
The parser only supports kern subtables with coverage/format 0x0001 (format 0, horizontal kerning values). Any other coverage bitfield (vertical kerning, cross-stream, format 1/2/3, Apple format variants) is rejected.
Source
Thrown at lib/textmeasure/fontface.go:171
func parseLegacyKern(src []byte) ([]kernPair, error) {
table, err := sfntTable(src, "kern")
if err != nil || table == nil {
return nil, err
}
if len(table) < 18 {
return nil, fmt.Errorf("invalid kern table: too short")
}
if binary.BigEndian.Uint16(table[0:2]) != 0 {
return nil, fmt.Errorf("unsupported kern table version")
}
if binary.BigEndian.Uint16(table[2:4]) == 0 {
return nil, fmt.Errorf("invalid kern table: no subtables")
}
length := int(binary.BigEndian.Uint16(table[6:8]))
coverage := binary.BigEndian.Uint16(table[8:10])
if coverage != 0x0001 {
return nil, fmt.Errorf("unsupported kern table coverage 0x%04x", coverage)
}
n := int(binary.BigEndian.Uint16(table[10:12]))
if length < 14 || 6*n != length-14 || 4+length > len(table) {
return nil, fmt.Errorf("invalid kern table length")
}
pairs := make([]kernPair, n)
for i := range pairs {
offset := 18 + 6*i
pairs[i] = kernPair{
key: binary.BigEndian.Uint32(table[offset : offset+4]),
value: int16(binary.BigEndian.Uint16(table[offset+4 : offset+6])),
}
}
return pairs, nil
}
func sfntTable(src []byte, tag string) ([]byte, error) {View on GitHub (pinned to 0d69dca6f5)
Solutions
- Convert the font with fonttools/otf2ttf so kerning is stored as OpenType GPOS pairs or a format-0 kern subtable.
- Choose a different variant of the font that uses standard format-0 horizontal kerning.
- Accept the error as signaling reduced kerning: strip the kern table so the library proceeds without kerning.
Defensive patterns
Strategy: fallback
Validate before calling
// coverage := binary.BigEndian.Uint16(kern[8:10]); usable := coverage == 0x0001
Try / catch
pairs, err := parseLegacyKern(fontData)
if err != nil {
log.Printf("kerning unavailable (%v), continuing without", err)
pairs = nil
} Prevention
- Choose font variants whose kern tables use format 0 horizontal kerning (coverage 0x0001)
- Convert vertical/AAT kerned fonts with fonttools into GPOS or format-0 kern
- Accept degraded kerning for CJK/vertical fonts instead of treating it as fatal
- Document which bundled fonts support legacy kerning
When it happens
Trigger: parseFont encounters a font whose kern subtable coverage field (bytes 8–10) is not exactly 0x0001 — e.g. format 2 class-based kerning, vertical kerning, or Apple format 1 kerning lists.
Common situations: Apple system fonts using AAT format-1 kerning; fonts with vertical-writing kern tables (Japanese/CJK fonts); cross-stream kerning tables.
Related errors
- invalid kern table: too short
- unsupported kern table version
- invalid kern table: no subtables
- invalid kern table length
- checksum error in table: %v
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/08405dfa1e5406cb.
Report an issue: GitHub.