Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
730 stars 72 forks source link

getSupportedCharCodes returns 0xFFFF as supported char #68

Closed RoelN closed 3 years ago

RoelN commented 4 years ago

As the last start/end combination, getSupportedCharCodes returns {start: 65535, end: 65535}. This appears to be the Unicode character for "not a Unicode character".

The fonts tested do not have a character defined at 0xffff.

Pomax commented 4 years ago

Good catch, all segment-based subtable formats should be checking to verify the segment doesn't simply mean "end of segments, nothing here".

Pomax commented 3 years ago

I feel like we solved this previously, can you test to see if this is still the case @RoelN ?

RoelN commented 3 years ago

Just tested, but 0xffff is still reported as a character, so at Wakamai Fondue we still need to account for that.

Pomax commented 3 years ago

if you have a reproducible case for it, I can add that as a test - if you want to drop some code in a comment, we can see if this happens on any of the Source Code or Open Sans fonts and get it added to the test set.

Pomax commented 3 years ago

fixed in https://github.com/Pomax/Font.js/commit/495ec044a6aa35d23961c136adad61e316a59929, specifically, by testing for surrogate and noncharacter codes: https://github.com/Pomax/Font.js/commit/495ec044a6aa35d23961c136adad61e316a59929#diff-1496abdd1291c189b17f8168f8363662ad0df7697af702539e98e3a1a3023178R91-R103