diff --git a/Lib/robofab/objects/objectsFL.py b/Lib/robofab/objects/objectsFL.py index 2f5c55079..6b03d4fdc 100755 --- a/Lib/robofab/objects/objectsFL.py +++ b/Lib/robofab/objects/objectsFL.py @@ -659,11 +659,12 @@ class RFont(BaseFont): return self.newGlyph(glyphName) def newGlyph(self, glyphName, clear=True): - """Make a new glyph""" - #if generate: - # g = GenerateGlyph(self._object, glyphName, replace=clear) - #else: - g = NewGlyph(self._object, glyphName, clear) + """Make a new glyph.""" + # the old implementation always updated the font. + # that proved to be very slow. so, the updating is + # now left up to the caller where it can be more + # efficiently managed. + g = NewGlyph(self._object, glyphName, clear, updateFont=False) return RGlyph(g) def insertGlyph(self, glyph, name=None): @@ -1121,7 +1122,6 @@ class RFont(BaseFont): # there is no reason to keep the location in the lib. if glyph.lib.has_key(postScriptHintDataLibKey): del glyph.lib[postScriptHintDataLibKey] - glyph.update() if bar and not count % 10: bar.tick(count) count = count + 1 @@ -1162,6 +1162,8 @@ class RFont(BaseFont): self.lib.update(fontLib) if bar: bar.tick() + # update the font + self.update() # only blindly stop if the user says to except KeyboardInterrupt: bar.close() diff --git a/Lib/robofab/tools/toolsFL.py b/Lib/robofab/tools/toolsFL.py index be87c8dbc..c8aff19a1 100755 --- a/Lib/robofab/tools/toolsFL.py +++ b/Lib/robofab/tools/toolsFL.py @@ -201,9 +201,10 @@ def makePSFontName(name): # # -def NewGlyph(font, glyphName, clear=False): +def NewGlyph(font, glyphName, clear=False, updateFont=True): """Make a new glyph if it doesn't already exist, return the glyph. - font is either a FL Font or RF RFont object. + font is either a FL Font or RF RFont object. If updateFont is True + the (very slow) fl.UpdateFont function will be called. """ font = unwrapFont(font) if isinstance(glyphName, unicode): @@ -213,7 +214,8 @@ def NewGlyph(font, glyphName, clear=False): new = Glyph() new.name = glyphName font.glyphs.append(new) - fl.UpdateFont(FontIndex(font)) + if updateFont: + fl.UpdateFont(FontIndex(font)) glyph = font[glyphName] elif clear: glyph.Clear()