One thing you can keep here is to add BMP guard to the `while (n < length && end + 1 == codes[n].unicode)` (https://github.com/vyv03354/pdf.js/blob/7144317ce6f189fb1d45480ba04c25a41366217c/src/fonts.js#L2571), e.g. at the end of the loop add `if (end === 0x10000) { break; }`