Created
June 17, 2016 13:05
-
-
Save rbmntjs/1d89fe9cf7dcfd2bbe6a24562f41a286 to your computer and use it in GitHub Desktop.
This script runs through your glyphs and outputs two classes for use in your GDEF table. Open for suggestions.
This file contains 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
# Find glyphs with anchors and _anchors, | |
# to properly populate a GDEF table. | |
f = CurrentFont() | |
# Sort alphabetically for easier scanning | |
names = f.keys() | |
names.sort() | |
gdef_base = '@BASE = [ ' | |
gdef_combining = '@COMBINING_MARKS = [ ' | |
for n in names: | |
g = f[n] # Reset glyph object | |
anchors = [] # If it’s an array, it’s easier to do logic | |
for a in g.anchors: | |
anchors.append(a.name) | |
for a in g.anchors: | |
if a.name.startswith("_"): | |
# If any of the anchors start with an underscore, | |
# it’s a combining mark | |
gdef_combining += g.name + ' ' | |
break | |
if g.anchors: | |
# If a glyph has anchors, AND | |
for a in g.anchors: | |
if not a.name.startswith("_"): | |
# it has NO anchors starting with an underscore, | |
# then it’s a base glyph | |
gdef_base += g.name + ' ' | |
break | |
print gdef_base + '];' | |
print gdef_combining + '];' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment