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)
|
return self.newGlyph(glyphName)
|
||||||
|
|
||||||
def newGlyph(self, glyphName, clear=True):
|
def newGlyph(self, glyphName, clear=True):
|
||||||
"""Make a new glyph"""
|
"""Make a new glyph."""
|
||||||
#if generate:
|
# the old implementation always updated the font.
|
||||||
# g = GenerateGlyph(self._object, glyphName, replace=clear)
|
# that proved to be very slow. so, the updating is
|
||||||
#else:
|
# now left up to the caller where it can be more
|
||||||
g = NewGlyph(self._object, glyphName, clear)
|
# efficiently managed.
|
||||||
|
g = NewGlyph(self._object, glyphName, clear, updateFont=False)
|
||||||
return RGlyph(g)
|
return RGlyph(g)
|
||||||
|
|
||||||
def insertGlyph(self, glyph, name=None):
|
def insertGlyph(self, glyph, name=None):
|
||||||
@ -1121,7 +1122,6 @@ class RFont(BaseFont):
|
|||||||
# there is no reason to keep the location in the lib.
|
# there is no reason to keep the location in the lib.
|
||||||
if glyph.lib.has_key(postScriptHintDataLibKey):
|
if glyph.lib.has_key(postScriptHintDataLibKey):
|
||||||
del glyph.lib[postScriptHintDataLibKey]
|
del glyph.lib[postScriptHintDataLibKey]
|
||||||
glyph.update()
|
|
||||||
if bar and not count % 10:
|
if bar and not count % 10:
|
||||||
bar.tick(count)
|
bar.tick(count)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
@ -1162,6 +1162,8 @@ class RFont(BaseFont):
|
|||||||
self.lib.update(fontLib)
|
self.lib.update(fontLib)
|
||||||
if bar:
|
if bar:
|
||||||
bar.tick()
|
bar.tick()
|
||||||
|
# update the font
|
||||||
|
self.update()
|
||||||
# only blindly stop if the user says to
|
# only blindly stop if the user says to
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
bar.close()
|
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.
|
"""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)
|
font = unwrapFont(font)
|
||||||
if isinstance(glyphName, unicode):
|
if isinstance(glyphName, unicode):
|
||||||
@ -213,7 +214,8 @@ def NewGlyph(font, glyphName, clear=False):
|
|||||||
new = Glyph()
|
new = Glyph()
|
||||||
new.name = glyphName
|
new.name = glyphName
|
||||||
font.glyphs.append(new)
|
font.glyphs.append(new)
|
||||||
fl.UpdateFont(FontIndex(font))
|
if updateFont:
|
||||||
|
fl.UpdateFont(FontIndex(font))
|
||||||
glyph = font[glyphName]
|
glyph = font[glyphName]
|
||||||
elif clear:
|
elif clear:
|
||||||
glyph.Clear()
|
glyph.Clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user