[cffLib] Use intRect() for FontBBox rounding

AFDKO seems to calculate bounds and side bearings in this manner.
This commit is contained in:
Masaya Nakamura 2017-05-19 16:55:10 +09:00
parent 5fd38a762e
commit b22b59f730
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.misc import sstruct
from fontTools.misc import psCharStrings
from fontTools.misc.arrayTools import unionRect
from fontTools.misc.arrayTools import unionRect, intRect
from fontTools.misc.textTools import safeEval
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.otBase import OTTableWriter
@ -2331,7 +2331,7 @@ class TopDict(BaseDict):
if bounds == initialBounds:
self.FontBBox = self.defaults['FontBBox'][:]
else:
self.FontBBox = [round(v) for v in bounds]
self.FontBBox = list(intRect(bounds))
class FontDict(BaseDict):

View File

@ -19,8 +19,8 @@ class TopDictTest(unittest.TestCase):
<CharString name="bar"><!-- [0, 0, 200, 200] -->
0 0 rmoveto 200 hlineto 200 vlineto -200 hlineto endchar
</CharString>
<CharString name="baz"><!-- [-55.5, -55.5, 55.5, 55.5] -->
-55.5 -55.5 rmoveto 111 hlineto 111 vlineto -111 hlineto endchar
<CharString name="baz"><!-- [-55.1, -55.1, 55.1, 55.1] -->
-55.1 -55.1 rmoveto 110.2 hlineto 110.2 vlineto -110.2 hlineto endchar
</CharString>
"""))