fonttools/Scripts/RoboFabUFO/ExportOneGlyphToGlif.py
Erik van Blokland 34ef397f91 Standardised script names on import or export.
git-svn-id: http://svn.robofab.com/trunk@82 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
2008-04-20 10:45:06 +00:00

39 lines
939 B
Python

#FLM: Glyph to Glif, not in UFO
"""
Dump the selected glyph to a Glif as a seperate, individual file.
This is not saved through a GlyphSet and any contents.plist in the
same directory will not be updated. If that's what you need use
DumpOneGlyphToUFO.py
"""
from robofab.glifLib import writeGlyphToString
from robofab.world import CurrentFont, CurrentGlyph
from robofab.interface.all.dialogs import PutFile
from robofab.tools.glyphNameSchemes import glyphNameToShortFileName
import os
f = CurrentFont()
g = CurrentGlyph()
if g is not None:
todo = [g.name]
else:
todo = f.selection
for c in todo:
g = f[c]
result = True
data = writeGlyphToString(g.name, g, g.drawPoints)
filename = glyphNameToShortFileName(g.name, None)
file = PutFile("Save this glif as:")
if file is not None:
path = os.path.join(os.path.dirname(file), filename)
print "saving to", path
f = open(path, "w")
f.write(data)
f.close()
print 'done'