Changeset 203

Show
Ignore:
Timestamp:
01/05/10 06:40:15 (2 years ago)
Author:
erik
Message:

moving changes from robofab trunk rev 202 into the ufo3 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Scripts/RoboFabUFO/ExportOneGlyphToGlif.py

    r82 r203  
    2323else: 
    2424        todo = f.selection 
     25 
    2526for c in todo: 
    2627        g = f[c] 
  • trunk/Scripts/RoboFabUFO/ExportOneGlyphToUFO.py

    r82 r203  
    1 #FLM: Export Selected Glyph to UFO 
     1#FLM: Export Selected or Current Glyph to UFO 
    22 
    33 
     
    55        Dump the selected glyph to a .glif as part of a UFO. 
    66        It saves the .glif through a GlyphSet and updates the contents.plist. 
    7  
     7         
     8        Updated for UFO2 
    89""" 
    910 
     
    1213from robofab.world import CurrentFont, CurrentGlyph 
    1314from robofab.interface.all.dialogs import Message, GetFolder 
    14 from robofab.tools.glyphNameSchemes import glyphNameToShortFileName 
    1515import os 
    16  
    17  
    18 if os.name == "mac": 
    19         LOCAL_ENCODING = "macroman" 
    20 else: 
    21         LOCAL_ENCODING = "latin-1" 
    2216 
    2317 
     
    2519g = CurrentGlyph() 
    2620 
     21ufoPath = f.path.replace(".vfb", ".ufo") 
     22if 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 
    2726if g is not None: 
    2827        todo = [g.name] 
    2928else: 
    3029        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         
     31if 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                 
     36else: 
     37        from robofab.interface.all.dialogs import Message 
     38        Message("No glyphs selected for export.") 
     39         
    4840print 'done' 
  • trunk/Scripts/RoboFabUFO/ExportSelectedGlyphsToUFO.py

    r82 r203  
    1 #FLM: Export selected glyphs to UFO 
     1#FLM: Export Selected or Current Glyph to UFO 
    22 
    33 
     
    66        It saves the .glif through a GlyphSet and updates the contents.plist. 
    77         
    8         EvB 08 
     8        Updated for UFO2 
    99""" 
    1010 
     
    1313from robofab.world import CurrentFont, CurrentGlyph 
    1414from robofab.interface.all.dialogs import Message, GetFolder 
    15 from robofab.tools.glyphNameSchemes import glyphNameToShortFileName 
    1615import os 
     16 
    1717 
    1818f = CurrentFont() 
    1919g = CurrentGlyph() 
    2020 
    21 f.save() 
    22  
    23 ufoPath = None 
    2421ufoPath = f.path.replace(".vfb", ".ufo") 
    2522if 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) )) 
    3025 
    31 if ufoPath is not None: 
     26if g is not None: 
     27        todo = [g.name] 
     28else: 
    3229        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         
     31if 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                 
     36else: 
     37        from robofab.interface.all.dialogs import Message 
     38        Message("No glyphs selected for export.") 
     39         
    4440print 'done'