Surrogate & grapheme
JS
open
opentype.js does not clamp cmap format 12/13 codes to U+10FFFF
fix(cmap): clamp format 12/13 character codes to the Unicode maximum
opentype.js · opentypejs/opentype.js
Symptom
opentype.js does not clamp cmap format 12/13 character codes to U+10FFFF; malformed fonts with out-of-range codes cause incorrect glyph lookups for supplementary characters.
Minimal repro
Load a font with a cmap subtable containing entries beyond U+10FFFF; glyph lookup for supplementary characters (emoji, CJK Extension B+) returns wrong glyph.
Fix
Clamp all format 12/13 startCharCode/endCharCode values to 0x10FFFF during parsing.