fonttools/Scripts/RoboFabUFO/DumpOneGlyphToGlif.py
Erik van Blokland 617945dcf1 The scripts folder for FontLab as they shipped with Fab 1.1.1.
git-svn-id: http://svn.robofab.com/trunk@22 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
2008-01-16 08:14:00 +00:00

36 lines
910 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:")
path = os.path.join(os.path.dirname(file), filename)
print "saving to", path
f = open(path, "w")
f.write(data)
f.close()
print 'done'