{"record":{"id":"88a54b02a1511462","repo":"d2lang/d2","slug":"unsupported-kern-table-version","errorCode":null,"errorMessage":"unsupported kern table version","messagePattern":"unsupported kern table version","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/textmeasure/fontface.go","lineNumber":162,"sourceCode":"\tx := int64(scale) * int64(units)\n\tif x >= 0 {\n\t\tx += int64(unitsPerEm) / 2\n\t} else {\n\t\tx -= int64(unitsPerEm) / 2\n\t}\n\treturn fixed.Int26_6(x / int64(unitsPerEm))\n}\n\nfunc parseLegacyKern(src []byte) ([]kernPair, error) {\n\ttable, err := sfntTable(src, \"kern\")\n\tif err != nil || table == nil {\n\t\treturn nil, err\n\t}\n\tif len(table) < 18 {\n\t\treturn nil, fmt.Errorf(\"invalid kern table: too short\")\n\t}\n\tif binary.BigEndian.Uint16(table[0:2]) != 0 {\n\t\treturn nil, fmt.Errorf(\"unsupported kern table version\")\n\t}\n\tif binary.BigEndian.Uint16(table[2:4]) == 0 {\n\t\treturn nil, fmt.Errorf(\"invalid kern table: no subtables\")\n\t}\n\n\tlength := int(binary.BigEndian.Uint16(table[6:8]))\n\tcoverage := binary.BigEndian.Uint16(table[8:10])\n\tif coverage != 0x0001 {\n\t\treturn nil, fmt.Errorf(\"unsupported kern table coverage 0x%04x\", coverage)\n\t}\n\tn := int(binary.BigEndian.Uint16(table[10:12]))\n\tif length < 14 || 6*n != length-14 || 4+length > len(table) {\n\t\treturn nil, fmt.Errorf(\"invalid kern table length\")\n\t}\n\n\tpairs := make([]kernPair, n)\n\tfor i := range pairs {\n\t\toffset := 18 + 6*i","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/lib/textmeasure/fontface.go#L144-L180","documentation":"The legacy 'kern' table's first 16-bit field is a version number; only version 0 (legacy Apple/OpenType format) is supported. A non-zero version means the table uses an unrecognized format and parsing is refused.","triggerScenarios":"parseFont encounters a font whose kern table header version field (bytes 0–2 big-endian) is not 0 — e.g. some AAT/Apple-format kern tables or future/variant versions.","commonSituations":"Mac-only fonts using Apple's AAT kern format variants; unusual or very new font formats; fonts modified by tools that bump the version field.","solutions":["Convert the font with fonttools to a standard OpenType font (which stores kerning in GPOS instead, or a version-0 kern table).","Use a font known to be compatible with standard TrueType/OpenType kerning.","If kerning is non-essential, strip the kern table so the library proceeds without kerning data."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// check kern table version before parsing\n// version := binary.BigEndian.Uint16(kern[0:2]); usable := version == 0","typeGuard":null,"tryCatchPattern":"pairs, err := parseLegacyKern(fontData)\nif err != nil {\n    log.Printf(\"kerning unavailable (%v), continuing without\", err)\n    pairs = nil\n}","preventionTips":["Prefer fonts distributed as standard OpenType/TrueType with version-0 kern or GPOS tables","Convert Apple AAT fonts with fonttools before bundling","Treat kerning as optional: degrade gracefully instead of failing the whole render","Audit bundled fonts with fonttools to confirm kern table format"],"tags":["font","kern","unsupported-version"],"backgroundTag":"invalid-font-kern-table","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}