From 5fd38a762ee017aac4278179a760974054ea2f98 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Fri, 19 May 2017 11:37:01 +0900 Subject: [PATCH] [head] Recalc bounds when compiling CFF-flavored fonts --- Lib/fontTools/ttLib/tables/_h_e_a_d.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py index c6e2cae24..9275d4103 100644 --- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py +++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py @@ -33,7 +33,7 @@ headFormat = """ class table__h_e_a_d(DefaultTable.DefaultTable): - dependencies = ['maxp', 'loca'] + dependencies = ['maxp', 'loca', 'CFF '] def decompile(self, data, ttFont): dummy, rest = sstruct.unpack2(headFormat, data, self) @@ -59,6 +59,11 @@ class table__h_e_a_d(DefaultTable.DefaultTable): setattr(self, stamp, value) def compile(self, ttFont): + if ttFont.recalcBBoxes: + # For TT-flavored fonts, xMin, yMin, xMax and yMax are set in table__m_a_x_p.recalc(). + if 'CFF ' in ttFont: + topDict = ttFont['CFF '].cff.topDictIndex[0] + self.xMin, self.yMin, self.xMax, self.yMax = topDict.FontBBox if ttFont.recalcTimestamp: self.modified = timestampNow() data = sstruct.pack(headFormat, self)