fonttools/Scripts/RoboFabUFO/ExportSelectedGlyphsToUFO.py
Erik van Blokland 77353dbc30 Tweak to export script.
git-svn-id: http://svn.robofab.com/trunk@218 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
2010-01-15 09:12:23 +00:00

41 lines
1.0 KiB
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()
todo = None
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'