Created
November 18, 2014 08:16
-
-
Save typemytype/8a2bf5a7668ab3846b22 to your computer and use it in GitHub Desktop.
search for Descriptive Style Set Names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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