How to get registered OT features tags via code

Hi @GeorgSeifert,

is there a function within Glyphsapp to call/get all registered glyph name suffixes like .ss01, .tf, .otf, .sc, etc?

Something similar to Glyphs.scriptSuffixes?

Thanks,
Olli

I would like to do something like:

for g in font.glyphs:
	if any(True for part in g.name.split('.') if part in Glyphs.featureSuffixes):
		# do something

There is no direct API for this. But you can (miss-)use the localisation API.

frameworkBundle = NSBundle.bundleForClass_(GSFeature.class())
localizedName = frameworkBundle.localizedStringForKey_value_table_(featureTag, None, "FeatureNames")
if localizedName is not None:
    # do something. 

Thanks Georg, this is already a good direction, but it does not fit perfectly to my needs.

I tried the following:

from GlyphsApp import * 
from Foundation import NSBundle
fontObj = Glyphs.font

for g in fontObj.glyphs:
	if '.' not in g.name or g.name[0] in ('.', '_'):
		continue
	for namePart in g.name.split('.')[1:]:
		frameworkBundle = NSBundle.bundleForClass_(GSFeature.class__())
		localizedName = frameworkBundle.localizedStringForKey_value_table_(namePart, None, "FeatureNames")
		if localizedName is not None:
			print ('%s: %s = %s'%(g.name, namePart, localizedName))

Here is a summary of an output:
Q.ss01: ss01 = Stylistic Set 1
oslash.bold: bold = bold
n.sups: sups = Superscript
De-cy.loclBGR: loclBGR = loclBGR
n.subs: subs = Subscript
zero.dnom: dnom = Denominators
nine.numr: numr = Numerators
zero.osf: osf = osf
nine.tf: tf = tf
periodcentered.loclCAT: loclCAT = loclCAT
dieresiscomb.case: case = Case-Sensitive FormsQ.ss01: ss01 = Stylistic Set 1
oslash.bold: bold = bold
n.sups: sups = Superscript
De-cy.loclBGR: loclBGR = loclBGR
n.subs: subs = Subscript
zero.dnom: dnom = Denominators
nine.numr: numr = Numerators
zero.osf: osf = osf
nine.tf: tf = tf
periodcentered.loclCAT: loclCAT = loclCAT
dieresiscomb.case: case = Case-Sensitive Forms

This is not what I want to get. It should give me ‘None’ for ‘oslash.bold’, and ‘tf’ should be ‘Tabular Figures’ not ‘tf’.

This only checks for actual feature names. So ‘tf’ will need special treatment.

Maybe you parse the FeatureNames file yourself and add some overwrites/additions.