fonttools/Scripts/RoboFabUFO/ExportOneGlyphToUFO.py
Erik van Blokland 2dcd36633c moving changes from robofab trunk rev 202 into the ufo3 branch
git-svn-id: http://svn.robofab.com/trunk@203 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
2010-01-05 12:40:15 +00:00

40 lines
1012 B
Python

#FLM: Export Selected or Current Glyph to UFO
"""
Dump the selected glyph to a .glif as part of a UFO.
It saves the .glif through a GlyphSet and updates the contents.plist.
Updated for UFO2
"""
from robofab.glifLib import GlyphSet
from robofab.world import CurrentFont, CurrentGlyph
from robofab.interface.all.dialogs import Message, GetFolder
import os
f = CurrentFont()
g = CurrentGlyph()
ufoPath = f.path.replace(".vfb", ".ufo")
if not os.path.exists(ufoPath):
from robofab.interface.all.dialogs import Message
Message("No UFO found for this font. I'm looking for \"%s\"."%(os.path.basename(ufoPath) ))
if g is not None:
todo = [g.name]
else:
todo = f.selection
if todo:
Message("Exporting %s to \"%s\"."%(", ".join(todo), os.path.basename(ufoPath) ))
f.writeUFO(doHints=False, doInfo=False, doKerning=False,
doGroups=False, doLib=False, doFeatures=False, glyphs=todo)
else:
from robofab.interface.all.dialogs import Message
Message("No glyphs selected for export.")
print 'done'