Changeset 203
- Timestamp:
- 01/05/10 06:40:15 (2 years ago)
- Files:
-
- trunk/Scripts/RoboFabUFO/ExportOneGlyphToGlif.py (modified) (1 diff)
- trunk/Scripts/RoboFabUFO/ExportOneGlyphToUFO.py (modified) (4 diffs)
- trunk/Scripts/RoboFabUFO/ExportSelectedGlyphsToUFO.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Scripts/RoboFabUFO/ExportOneGlyphToGlif.py
r82 r203 23 23 else: 24 24 todo = f.selection 25 25 26 for c in todo: 26 27 g = f[c] trunk/Scripts/RoboFabUFO/ExportOneGlyphToUFO.py
r82 r203 1 #FLM: Export Selected Glyph to UFO1 #FLM: Export Selected or Current Glyph to UFO 2 2 3 3 … … 5 5 Dump the selected glyph to a .glif as part of a UFO. 6 6 It saves the .glif through a GlyphSet and updates the contents.plist. 7 7 8 Updated for UFO2 8 9 """ 9 10 … … 12 13 from robofab.world import CurrentFont, CurrentGlyph 13 14 from robofab.interface.all.dialogs import Message, GetFolder 14 from robofab.tools.glyphNameSchemes import glyphNameToShortFileName15 15 import os 16 17 18 if os.name == "mac":19 LOCAL_ENCODING = "macroman"20 else:21 LOCAL_ENCODING = "latin-1"22 16 23 17 … … 25 19 g = CurrentGlyph() 26 20 21 ufoPath = f.path.replace(".vfb", ".ufo") 22 if not os.path.exists(ufoPath): 23 from robofab.interface.all.dialogs import Message 24 Message("No UFO found for this font. I'm looking for \"%s\"."%(os.path.basename(ufoPath) )) 25 27 26 if g is not None: 28 27 todo = [g.name] 29 28 else: 30 29 todo = f.selection 31 for c in todo: 32 if f is None: 33 continue 34 g = f[c] 35 result = True 36 file = GetFolder("Select a UFO to save the GLIF in:") 37 if file is None: 38 continue 39 if file.find(".ufo") == -1: 40 Message("You need to select an UFO. Quitting.") 41 else: 42 path = os.path.join(os.path.dirname(file), os.path.basename(file), "glyphs") 43 print "saving glyph %s in %s"%(g.name.encode(LOCAL_ENCODING), path) 44 gs = GlyphSet(path, glyphNameToFileNameFunc=glyphNameToShortFileName) 45 gs.writeGlyph(g.name, g, g.drawPoints) 46 gs.writeContents() 47 30 31 if todo: 32 Message("Exporting %s to \"%s\"."%(", ".join(todo), os.path.basename(ufoPath) )) 33 f.writeUFO(doHints=False, doInfo=False, doKerning=False, 34 doGroups=False, doLib=False, doFeatures=False, glyphs=todo) 35 36 else: 37 from robofab.interface.all.dialogs import Message 38 Message("No glyphs selected for export.") 39 48 40 print 'done' trunk/Scripts/RoboFabUFO/ExportSelectedGlyphsToUFO.py
r82 r203 1 #FLM: Export selected glyphsto UFO1 #FLM: Export Selected or Current Glyph to UFO 2 2 3 3 … … 6 6 It saves the .glif through a GlyphSet and updates the contents.plist. 7 7 8 EvB 088 Updated for UFO2 9 9 """ 10 10 … … 13 13 from robofab.world import CurrentFont, CurrentGlyph 14 14 from robofab.interface.all.dialogs import Message, GetFolder 15 from robofab.tools.glyphNameSchemes import glyphNameToShortFileName16 15 import os 16 17 17 18 18 f = CurrentFont() 19 19 g = CurrentGlyph() 20 20 21 f.save()22 23 ufoPath = None24 21 ufoPath = f.path.replace(".vfb", ".ufo") 25 22 if not os.path.exists(ufoPath): 26 ufoPath = GetFolder("Select a UFO to save the GLIF in:") 27 if ufoPath.find(".ufo") == -1: 28 Message("You need to select an UFO. Quitting.") 29 ufoPath = None 23 from robofab.interface.all.dialogs import Message 24 Message("No UFO found for this font. I'm looking for \"%s\"."%(os.path.basename(ufoPath) )) 30 25 31 if ufoPath is not None: 26 if g is not None: 27 todo = [g.name] 28 else: 32 29 todo = f.selection 33 print "selection", todo 34 if g is not None: 35 todo.append(g.name) 36 for c in todo: 37 g = f[c] 38 path = os.path.join(os.path.dirname(ufoPath), os.path.basename(ufoPath), "glyphs") 39 print "saving glyph %s in %s"%(g.name, path) 40 gs = GlyphSet(path, glyphNameToFileNameFunc=glyphNameToShortFileName) 41 gs.writeGlyph(g.name, g, g.drawPoints) 42 gs.writeContents() 43 30 31 if todo: 32 Message("Exporting %s to \"%s\"."%(", ".join(todo), os.path.basename(ufoPath) )) 33 f.writeUFO(doHints=False, doInfo=False, doKerning=False, 34 doGroups=False, doLib=False, doFeatures=False, glyphs=todo) 35 36 else: 37 from robofab.interface.all.dialogs import Message 38 Message("No glyphs selected for export.") 39 44 40 print 'done'
