From e53764a16d45b1762c1a9b854f7eadaf8616e83b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 7 Jun 2016 15:47:02 -0700 Subject: [PATCH] In calcIntBounds(), round values The glyph coordinates in glyf table are going to be rounded when writing out, so we should use the same mode of conversion to integers. Otherwise the xMin of a glyph might end up being different from its actual minimum X. --- Lib/fontTools/misc/arrayTools.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py index e68cea2b3..93651ae55 100644 --- a/Lib/fontTools/misc/arrayTools.py +++ b/Lib/fontTools/misc/arrayTools.py @@ -21,13 +21,9 @@ def calcBounds(array): def calcIntBounds(array): """Return the integer bounding rectangle of a 2D points array as a tuple: (xMin, yMin, xMax, yMax) + Values are rounded to closest integer. """ - xMin, yMin, xMax, yMax = calcBounds(array) - xMin = int(math.floor(xMin)) - xMax = int(math.ceil(xMax)) - yMin = int(math.floor(yMin)) - yMax = int(math.ceil(yMax)) - return xMin, yMin, xMax, yMax + return tuple(int(round(v)) for v in calcBounds(array)) def updateBounds(bounds, p, min=min, max=max):