opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.38k stars 468 forks source link

Way to parse the CMAP table of a font #536

Closed BenRacicot closed 1 year ago

BenRacicot commented 1 year ago

Hello, this is more of a question for opentypejs and a common issue developers have when using fonts for icons.

With icon fonts we use ligatures to map icons to text. But when a ligature doesnt exist for some text there doesnt seem to be any mechanisms for us to fallback to handle this "missing ligature" problem.

One poor solution I used was to copy out all the ligatures to create an array and then was testing a string for inclusion. But someone from Icomoon recommended comparing my text against the font's CMAP table instead.

Is this possible with OpentypeJS or perhaps some other JavaScript mechanism that I cannot find online.

Thanks for your time and help.

https://stackoverflow.com/q/75008236/1440240

ILOVEPIE commented 1 year ago

Yes, this is possible with opentype.js. Try searching the code for cmap.

Connum commented 1 year ago

close because already answered and no further activity