Complete OpenType feature code via API?

Hi there!

I see in the documentation that Glyphs stores the OpenType feature code modularly as individual features and prefixes.

Is there a way via the API to poll a Glyphs file and get the complete ‘compiled’ OT code that is collated from these various modular pieces?


The feature file is only put together on export. So you can simulate an export like this:

from Foundation import NSTemporaryDirectory
from GlyphsApp import GSOutlineFormatTrueType
font = Font
instance = font.instances[0]
exportInstanceOperation = NSClassFromString("GSExportInstanceOperation").alloc().initWithFont_instance_outlineFormat_containers_(font, instance, GSOutlineFormatTrueType, None)

tempFile = NSTemporaryDirectory().stringByAppendingPathComponent_("feature.fea")

result = exportInstanceOperation.writeFeaFile_error_(tempFile, None)

feaCode = NSString.stringWithContentsOfFile_(tempFile)

This will get you all GPOS. You need to pay attention to what instance you use as that changes the pos values.

If you only like the manually GSUB that is visible in the features panel, you can do this:

for Class in Font.classes:
	print("@%s = [%s];\n" % (, Class.saveCode()))
for prefix in Font.featurePrefixes:
	print(prefix.saveCode(), "\n")

for feature in Font.features:
	print("feature %s = {\n%s\n} %s;\n" % (, feature.saveCodeError_(None),

There as some details missing, e.g. you don’t get automatic languagesystems and the stylistic set names.

Thanks for this!