harfbuzz / harfbuzz

HarfBuzz text shaping engine
http://harfbuzz.github.io/
Other
3.8k stars 601 forks source link

Better support for selecting AAT features #4728

Open khaledhosny opened 1 month ago

khaledhosny commented 1 month ago

When doing AAT shaping, we will made a selected set of OpenType feature tags to AAT features, and we also have aat-layout APIs to get AAT features and selectors from the font, but:

  1. We don’t expose an API that maps AAT features, to OpenType tags, so applications building a UI that presents features supported by the font has no way to map AAT features back to features tags to be enabled during shaping.
  2. We only map a subset of AAT features, so not all features supported by the fonts can be enabled this way.

For 1), may be we need the reverse of hb_aat_layout_find_feature_mapping() as a public API?

For 2), I’m thinking may be we can provide an escape hatch where a feature tag is treated as an AAT feature type, and the value as an AAT feature selector. A buffer flag? A special feature prefix e.g. features starting with AA the other two bytes would be AAT feature type? Fixing this will probably make fixing 1) unnecessary.

behdad commented 1 month ago

Just ' 19' to activate feature code 19 sounds fine with me.

khaledhosny commented 1 month ago

The largest feature type currently in https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html is 103, so this should work. (the feature type is uint16, so lets hope that Apple does not define more than 4-digit feature types in the future).