Skip to content

Instantly share code, notes, and snippets.

@typemytype
Created November 18, 2014 08:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typemytype/8a2bf5a7668ab3846b22 to your computer and use it in GitHub Desktop.
Save typemytype/8a2bf5a7668ab3846b22 to your computer and use it in GitHub Desktop.
search for Descriptive Style Set Names
from fontTools.ttLib import TTFont
from robofab.interface.all.dialogs import GetFolder
from lib.tools.misc import walkDirectoryForFile
root = GetFolder("Folder with .otf / .ttf files...")
found = {}
if root:
binaryFiles = walkDirectoryForFile(root, ".otf")
binaryFiles += walkDirectoryForFile(root, ".ttf")
for fontFile in binaryFiles:
font = TTFont(fontFile)
descriptiveNames = {}
for nameRecord in font["name"].names:
if nameRecord.platformID == 1:
if 256 < nameRecord.nameID < 256 + 19:
feaTag = "ss%02d" % (nameRecord.nameID - 256)
descriptiveNames[feaTag] = nameRecord.string
if descriptiveNames:
found[fontFile] = descriptiveNames
o = []
for path, ss in found.items():
o.append(path)
feaTags = ss.keys()
feaTags.sort()
for feaTag in feaTags:
o.append("\t%s: %s" % (feaTag, ss[feaTag]))
print "\n".join(o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment