diff options
author | Haibo Huang <hhb@google.com> | 2019-05-13 16:38:42 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2019-05-13 16:38:42 -0700 |
commit | d648c2a4868c62db146c13f62b38d749db674ab2 (patch) | |
tree | cfeb5f4e886f8902407dc4c5bab3a88513d0fe55 /Lib/fontTools/ttLib | |
parent | 195ed3228f2e5c0f6a9cc31e9c0f081646eda9eb (diff) | |
download | fonttools-d648c2a4868c62db146c13f62b38d749db674ab2.tar.gz |
Upgrade fonttools to 3.41.2
Test: None
Change-Id: I5263a62cab851cde83c296124418c8e72afffe4e
Diffstat (limited to 'Lib/fontTools/ttLib')
-rw-r--r-- | Lib/fontTools/ttLib/tables/S__i_l_f.py | 12 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/S__i_l_l.py | 2 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/_g_l_y_f.py | 8 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/_g_v_a_r.py | 11 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/_h_e_a_d.py | 3 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/otBase.py | 1 | ||||
-rw-r--r-- | Lib/fontTools/ttLib/tables/otTables.py | 3 |
7 files changed, 30 insertions, 10 deletions
diff --git a/Lib/fontTools/ttLib/tables/S__i_l_f.py b/Lib/fontTools/ttLib/tables/S__i_l_f.py index e68b9b2e..00d5f616 100644 --- a/Lib/fontTools/ttLib/tables/S__i_l_f.py +++ b/Lib/fontTools/ttLib/tables/S__i_l_f.py @@ -82,6 +82,12 @@ Silf_pseudomap_format = ''' nPseudo: H ''' +Silf_pseudomap_format_h = ''' + > + unicode: H + nPseudo: H +''' + Silf_classmap_format = ''' > numClass: H @@ -219,7 +225,7 @@ def disassemble(aCode): pc += struct.calcsize(fmt) return res -instre = re.compile("^\s*([^(]+)\s*(?:\(([^)]+)\))?") +instre = re.compile(r"^\s*([^(]+)\s*(?:\(([^)]+)\))?") def assemble(instrs): res = b"" for inst in instrs: @@ -231,7 +237,7 @@ def assemble(instrs): if m.group(2): if parmfmt == 0: continue - parms = [int(x) for x in re.split(",\s*", m.group(2))] + parms = [int(x) for x in re.split(r",\s*", m.group(2))] if parmfmt == -1: l = len(parms) res += struct.pack(("%dB" % (l+1)), l, *parms) @@ -406,7 +412,7 @@ class Silf(object): if version >= 3.0: pseudo = sstruct.unpack(Silf_pseudomap_format, data[8+6*i:14+6*i], _Object()) else: - pseudo = struct.unpack('>HH', data[8+4*i:12+4*i], _Object()) + pseudo = sstruct.unpack(Silf_pseudomap_format_h, data[8+4*i:12+4*i], _Object()) self.pMap[pseudo.unicode] = ttFont.getGlyphName(pseudo.nPseudo) data = data[8 + 6 * numPseudo:] currpos = (sstruct.calcsize(Silf_part1_format) diff --git a/Lib/fontTools/ttLib/tables/S__i_l_l.py b/Lib/fontTools/ttLib/tables/S__i_l_l.py index 4671e137..bf9d83f5 100644 --- a/Lib/fontTools/ttLib/tables/S__i_l_l.py +++ b/Lib/fontTools/ttLib/tables/S__i_l_l.py @@ -28,7 +28,7 @@ class table_S__i_l_l(DefaultTable.DefaultTable): data[i * 8:(i+1) * 8]) offset = int(offset / 8) - (numLangs + 1) langcode = langcode.replace(b'\000', b'') - langinfo.append((langcode, numsettings, offset)) + langinfo.append((langcode.decode("utf-8"), numsettings, offset)) maxsetting = max(maxsetting, offset + numsettings) data = data[numLangs * 8:] finfo = [] diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index b8020ca7..83d5315b 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -917,8 +917,12 @@ class Glyph(object): expanding it.""" if not hasattr(self, "data"): if remove_hinting: - self.program = ttProgram.Program() - self.program.fromBytecode([]) + if self.isComposite(): + if hasattr(self, "program"): + del self.program + else: + self.program = ttProgram.Program() + self.program.fromBytecode([]) # No padding to trim. return if not self.data: diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r.py b/Lib/fontTools/ttLib/tables/_g_v_a_r.py index 608b6a2d..f9c9e528 100644 --- a/Lib/fontTools/ttLib/tables/_g_v_a_r.py +++ b/Lib/fontTools/ttLib/tables/_g_v_a_r.py @@ -107,8 +107,15 @@ class table__g_v_a_r(DefaultTable.DefaultTable): glyph = ttFont["glyf"][glyphName] numPointsInGlyph = self.getNumPoints_(glyph) gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]] - self.variations[glyphName] = decompileGlyph_( - numPointsInGlyph, sharedCoords, axisTags, gvarData) + try: + self.variations[glyphName] = decompileGlyph_( + numPointsInGlyph, sharedCoords, axisTags, gvarData) + except Exception: + log.error( + "Failed to decompile deltas for glyph '%s' (%d points)", + glyphName, numPointsInGlyph, + ) + raise @staticmethod def decompileOffsets_(data, tableFormat, glyphCount): diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py index 4235acf4..42fbb1d4 100644 --- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py +++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py @@ -4,6 +4,7 @@ from fontTools.misc import sstruct from fontTools.misc.textTools import safeEval, num2binary, binary2num from fontTools.misc.timeTools import timestampFromString, timestampToString, timestampNow from fontTools.misc.timeTools import epoch_diff as mac_epoch_diff # For backward compat +from fontTools.misc.arrayTools import intRect from . import DefaultTable import logging @@ -63,7 +64,7 @@ class table__h_e_a_d(DefaultTable.DefaultTable): # 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 + self.xMin, self.yMin, self.xMax, self.yMax = intRect(topDict.FontBBox) if ttFont.recalcTimestamp: self.modified = timestampNow() data = sstruct.pack(headFormat, self) diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index 81ab354e..816f1cd0 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -104,6 +104,7 @@ class BaseTTXConverter(DefaultTable): tableClass = getattr(otTables, self.tableTag) self.table = tableClass() self.table.fromXML(name, attrs, content, font) + self.table.populateDefaults() class OTTableReader(object): diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py index af2a7c6c..737e5615 100644 --- a/Lib/fontTools/ttLib/tables/otTables.py +++ b/Lib/fontTools/ttLib/tables/otTables.py @@ -1130,6 +1130,7 @@ class LigatureSubst(FormatSwitchingBaseTable): lig.LigGlyph = attrs["glyph"] components = attrs["components"] lig.Component = components.split(",") if components else [] + lig.CompCount = len(lig.Component) ligs.append(lig) @@ -1495,7 +1496,7 @@ def _buildClasses(): import re from .otData import otData - formatPat = re.compile("([A-Za-z0-9]+)Format(\d+)$") + formatPat = re.compile(r"([A-Za-z0-9]+)Format(\d+)$") namespace = globals() # populate module with classes |