Advertisement
mekkablue

Check glyph names

Mar 1st, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. #MenuTitle: Check glyph names
  2. # encoding: utf-8
  3. """Goes through all glyph names and looks for illegal characters."""
  4.  
  5. import GlyphsApp
  6.  
  7. Font = Glyphs.font
  8. firstChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  9. restChars = "0123456789._-"
  10. legalChars = firstChars + restChars
  11.  
  12. def process( thisName ):
  13.     thisFirstChar = thisName[0]
  14.    
  15.     if thisFirstChar not in firstChars and thisName not in [".notdef", ".null"]:
  16.         if thisFirstChar in restChars:
  17.             print "'%s': potentially problematic first character" % thisName
  18.         else:
  19.             print "'%s': illegal first character" % thisName
  20.        
  21.     for thisChar in thisName[1:]:
  22.         if thisChar not in legalChars:
  23.             print "'%s': illegal character '%s'" % ( thisName, thisChar )
  24.  
  25. for thisGlyph in Font.glyphs:
  26.     process( thisGlyph.name.replace("\U","\u").decode('unicode-escape') )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement