Export font metadata (open type features)


I’m looking for a way to export metadata of all open type features in a font.

I wrote a script, which loops through all glyphs and outputs the information as JSON.
Example for a single glyph:

  "category": "Letter",
  "index": 302,
  "name": "Oslash",
  "features": "",
  "unicode": "00D8",
  "subCategory": "Uppercase"

So far so good, but what I want to achieve is:
Get the information, in which open type feature a particular glyph is used.


"features": ["ss01", "salt"]

The only possibility I see is looking in Glyphs.font.features.code and extract the information.
But… this feels terribly wrong and might lead to errors/bad data.

Is there ANY possibility to get these information?



That is rather complex. You could try to parse the compiled GSUB lookups but that is still quite difficult. the font object has a property tempOTFFont. You might need to initialise is by calling font.compileTempFontError_(None). Then use fonttools to parse the font and have a look at its lookups.