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.
This commit is contained in:
Behdad Esfahbod 2016-06-07 15:47:02 -07:00
parent d1424e9d5a
commit e53764a16d

View File

@ -21,13 +21,9 @@ def calcBounds(array):
def calcIntBounds(array): def calcIntBounds(array):
"""Return the integer bounding rectangle of a 2D points array as a """Return the integer bounding rectangle of a 2D points array as a
tuple: (xMin, yMin, xMax, yMax) tuple: (xMin, yMin, xMax, yMax)
Values are rounded to closest integer.
""" """
xMin, yMin, xMax, yMax = calcBounds(array) return tuple(int(round(v)) for v in 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
def updateBounds(bounds, p, min=min, max=max): def updateBounds(bounds, p, min=min, max=max):