Advertisement
mekkablue

Export Glyph Info CSV

Feb 28th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #MenuTitle: Export Glyph Info CSV
  2. """Export a CSV to the Desktop containing info about the glyphs."""
  3.  
  4. import GlyphsApp
  5. import commands
  6. from types import *
  7.  
  8. Font = Glyphs.font
  9. Doc  = Glyphs.currentDocument
  10. selectedLayers = Doc.selectedLayers()
  11.  
  12. filename  = Font.familyName + ' metrics'  # filename without ending
  13. ending    = 'csv'       # txt|csv
  14. myDelim   = ";"         # use "\t" for tab
  15. myExportString = ""
  16.  
  17. def process( thisLayer ):
  18.     myExportList = []
  19.    
  20.     myExportList.append( str(thisLayer.parent.name) )
  21.     myExportList.append( str(thisLayer.name) )
  22.     myExportList.append( str(thisLayer.LSB) )
  23.     myExportList.append( str(thisLayer.RSB) )
  24.     myExportList.append( str(thisLayer.width) )
  25.    
  26.     return myExportList
  27.    
  28.  
  29. for thisLayer in selectedLayers:
  30.     print "Processing", thisLayer.parent.name
  31.     myExportString = myExportString + ( myDelim.join( process( thisLayer ) ) + '\n' )
  32.  
  33. directory = commands.getoutput('echo ~') + '/Desktop/'
  34. filepath  = directory + filename + '.' + ending
  35. f = open( filepath, 'w' )
  36. print "Exporting values to:", f.name
  37. f.write( myExportString )
  38. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement