diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2013-12-01 13:36:09 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2013-12-01 13:36:09 -0500 |
commit | f2c2b4d38bd7bba23db71936262db984e4b7aebb (patch) | |
tree | 97cc4ac5397824c225513b56ebc32a23f7178c34 /Lib/fontTools/misc/arrayTools.py | |
parent | 81acddadbd0384e105becc1eac292e50e21084a5 (diff) | |
download | fonttools-f2c2b4d38bd7bba23db71936262db984e4b7aebb.tar.gz |
Improve composite glyph bounds calculation
Extend GlyphCoordinates to transparently support float coordinates.
As a result, transformed glyph components now don't have their
coordinates rounded anymore. This slightly changes bounding box
calculations.
There's also code added, but disabled, to calculate exact glyph
bounding box, but we don't seem to actually want that.
Diffstat (limited to 'Lib/fontTools/misc/arrayTools.py')
-rw-r--r-- | Lib/fontTools/misc/arrayTools.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py index acbb02fb..8ed5d6df 100644 --- a/Lib/fontTools/misc/arrayTools.py +++ b/Lib/fontTools/misc/arrayTools.py @@ -18,6 +18,18 @@ def calcBounds(array): ys = [y for x, y in array] return min(xs), min(ys), max(xs), max(ys) +def calcIntBounds(array): + """Return the integer bounding rectangle of a 2D points array as a + tuple: (xMin, yMin, xMax, yMax) + """ + 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 + + def updateBounds(bounds, p, min=min, max=max): """Return the bounding recangle of rectangle bounds and point (x, y).""" (x, y) = p |