From d5b65a4ed12ba82e07fa0a2f507bb909d2065774 Mon Sep 17 00:00:00 2001 From: Just Date: Wed, 23 Aug 2000 12:34:19 +0000 Subject: [PATCH] made calculating bounding box handle empty coordinate arrays gracefully git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@117 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 610f3fda3..0b8d6e586 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -543,8 +543,11 @@ class Glyph: def recalcBounds(self, glyfTable): coordinates, endPts, flags = self.getCoordinates(glyfTable) - self.xMin, self.yMin = Numeric.minimum.reduce(coordinates) - self.xMax, self.yMax = Numeric.maximum.reduce(coordinates) + if len(coordinates) > 0: + self.xMin, self.yMin = Numeric.minimum.reduce(coordinates) + self.xMax, self.yMax = Numeric.maximum.reduce(coordinates) + else: + self.xMin, self.yMin, self.xMax, self.yMax = (0, 0, 0, 0) def isComposite(self): return self.numberOfContours == -1 @@ -660,7 +663,7 @@ class GlyphComponent: if self.flags & ARGS_ARE_XY_VALUES: self.x, self.y = struct.unpack(">bb", data[:2]) else: - x, y = struct.unpack(">BB", data[:4]) + x, y = struct.unpack(">BB", data[:2]) self.firstPt, self.secondPt = int(x), int(y) data = data[2:]