Changeset 229

Show
Ignore:
Timestamp:
02/13/11 17:13:54 (1 year ago)
Author:
tal
Message:

Modified NewGlyph? to make the fl.UpdateFont? call optional, the newGlyph method of RFont no longer updates automatically and, most importantly, this makes importing UFOs into FontLab? faster by a factor of "a lot."

Thanks to Georg Seifert for prompting us to look into this.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Lib/robofab/objects/objectsFL.py

    r226 r229  
    660660 
    661661        def newGlyph(self, glyphName, clear=True): 
    662                 """Make a new glyph""" 
    663                 #if generate: 
    664                 #       g = GenerateGlyph(self._object, glyphName, replace=clear) 
    665                 #else: 
    666                 g = NewGlyph(self._object, glyphName, clear) 
     662                """Make a new glyph.""" 
     663                # the old implementation always updated the font. 
     664                # that proved to be very slow. so, the updating is 
     665                # now left up to the caller where it can be more 
     666                # efficiently managed. 
     667                g = NewGlyph(self._object, glyphName, clear, updateFont=False) 
    667668                return RGlyph(g) 
    668669         
     
    11221123                                        if glyph.lib.has_key(postScriptHintDataLibKey): 
    11231124                                                del glyph.lib[postScriptHintDataLibKey] 
    1124                                 glyph.update() 
    11251125                                if bar and not count % 10: 
    11261126                                        bar.tick(count) 
     
    11631163                                if bar: 
    11641164                                        bar.tick() 
     1165                        # update the font 
     1166                        self.update() 
    11651167                # only blindly stop if the user says to 
    11661168                except KeyboardInterrupt: 
  • trunk/Lib/robofab/tools/toolsFL.py

    r1 r229  
    202202# 
    203203 
    204 def NewGlyph(font, glyphName, clear=False): 
     204def NewGlyph(font, glyphName, clear=False, updateFont=True): 
    205205        """Make a new glyph if it doesn't already exist, return the glyph. 
    206         font  is either a FL Font or RF RFont object. 
     206        font is either a FL Font or RF RFont object. If updateFont is True 
     207        the (very slow) fl.UpdateFont function will be called. 
    207208        """ 
    208209        font = unwrapFont(font) 
     
    214215                new.name = glyphName 
    215216                font.glyphs.append(new) 
    216                 fl.UpdateFont(FontIndex(font)) 
     217                if updateFont: 
     218                        fl.UpdateFont(FontIndex(font)) 
    217219                glyph = font[glyphName] 
    218220        elif clear: