diff --git a/src/CmapProcessor.js b/src/CmapProcessor.js index 23843c66..35d712d1 100644 --- a/src/CmapProcessor.js +++ b/src/CmapProcessor.js @@ -159,13 +159,16 @@ export default class CmapProcessor { let sel = selectors[i]; if (i !== -1 && sel.defaultUVS) { - i = binarySearch(sel.defaultUVS, x => + let i = binarySearch(sel.defaultUVS, x => codepoint < x.startUnicodeValue ? -1 : codepoint > x.startUnicodeValue + x.additionalCount ? +1 : 0 ); + if (i !== -1) { + return 0; + } } if (i !== -1 && sel.nonDefaultUVS) { - i = binarySearch(sel.nonDefaultUVS, x => codepoint - x.unicodeValue); + let i = binarySearch(sel.nonDefaultUVS, x => codepoint - x.unicodeValue); if (i !== -1) { return sel.nonDefaultUVS[i].glyphID; }