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. git-svn-id: http://svn.robofab.com/trunk@229 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
This commit is contained in:
parent
3c175fbe3b
commit
88e3e8df0f
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user