Last active
November 18, 2016 12:16
-
-
Save m4rc1e/731d4a5f3b5b3425edcb4bfcae80302e to your computer and use it in GitHub Desktop.
In Glyphsapp, find the ymin and ymax in all layers
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
#MenuTitle: Find Family ymin and ymax | |
def shortest_tallest_glyphs(font, *args): | |
'''find the tallest and shortest glyphs in all masters from a list. | |
If no list is given, search all glyphs.''' | |
lowest = 0.0 | |
highest = 0.0 | |
highest_name = '' | |
lowest_name = '' | |
masters_count = len(font.masters) | |
if args: | |
glyphs = [font.glyphs[i] for i in args] | |
else: | |
glyphs = font.glyphs | |
for glyph in glyphs: | |
for i in range(masters_count): | |
glyph_ymin = glyph.layers[i].bounds[0][-1] | |
glyph_ymax = glyph.layers[i].bounds[-1][-1] + glyph.layers[i].bounds[0][-1] | |
if glyph_ymin < lowest: | |
lowest = glyph_ymin | |
lowest_name = glyph.name | |
if glyph_ymax > highest: | |
highest = glyph_ymax | |
highest_name = glyph.name | |
return (lowest_name, lowest, highest_name, highest) | |
def main(): | |
local_font = Glyphs.font | |
print shortest_tallest_glyphs(local_font) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment