_g_l_y_f: expand glyphs inside compile if recalcBBoxes==True; delete empty self.data lingering around

Fixes https://github.com/behdad/fonttools/issues/410.

See also:
ecbe8f2c37 (commitcomment-14464893)
This commit is contained in:
Cosimo Lupo 2015-12-08 09:35:00 +00:00
parent c6ee46f299
commit 738866492d

View File

@ -313,6 +313,7 @@ class Glyph(object):
return return
if not self.data: if not self.data:
# empty char # empty char
del self.data
self.numberOfContours = 0 self.numberOfContours = 0
return return
dummy, data = sstruct.unpack2(glyphHeaderFormat, self.data, self) dummy, data = sstruct.unpack2(glyphHeaderFormat, self.data, self)
@ -329,7 +330,11 @@ class Glyph(object):
def compile(self, glyfTable, recalcBBoxes=True): def compile(self, glyfTable, recalcBBoxes=True):
if hasattr(self, "data"): if hasattr(self, "data"):
return self.data if recalcBBoxes:
# must unpack glyph in order to recalculate bounding box
self.expand(glyfTable)
else:
return self.data
if self.numberOfContours == 0: if self.numberOfContours == 0:
return "" return ""
if recalcBBoxes: if recalcBBoxes: