foliojs/fontkit

Implementation question: availableFeatures

borriglione opened this issue · 1 comments

Hello,

thanks for this great engine/tool.

With:

  console.log('font.availableFeatures', font.availableFeatures)
  font.availableFeatures [
    'aalt', 'c2sc', 'case', 'dnom',
    'frac', 'lnum', 'mgrk', 'numr',
    'onum', 'ordn', 'pnum', 'rlig',
    'sinf', 'smcp', 'ss01', 'ss02',
    'ss03', 'ss04', 'ss05', 'ss10',
    'ss11', 'ss12', 'ss14', 'ss15',
    'ss16', 'ss17', 'ss18', 'ss19',
    'ss20', 'subs', 'sups', 'tnum',
    'cpsp', 'kern', 'mark', 'mkmk'
  ]

I get all available features for this font. Is there a way to determine which feature has which kind of unicode characters = alternative/available glyhps?

I would like to have an output:

[
  aalt: [['U+0040', 'U+0042'],
...
  ss11: ['U+0111'],
...
]

Not really. These things map to complicated state machines that may highly depend on context of the surrounding glyphs. Mapping this backward to generate all of the possible unicode characters that might be involved in a given feature would be quite complicated. I haven't thought deeply enough about it to say whether it's impossible, but it would definitely be hard.