From 41445b8449733ade6117b3ae834da518e5623ef8 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 8 May 2017 10:51:39 +0100 Subject: [PATCH] t2CharStringPen: specializeCommands expects command args to be list, not tuples In the docstring of programToCommands, it says that: > Each command is a two-tuple of commandname,arg-list Previously the T2CharStringPen was passing command args as tuples instead of lists to the specializeCommands function with option generalizeFirst=False, which would only make a shallow copy of the input commands to modify them in place. The problem is that it attempted to call list-only methods, leading to errors like: File "fontTools/cffLib/specializer.py", line 432, in specializeCommands args.insert(pos, 0) AttributeError: 'tuple' object has no attribute 'insert' Since the expectation of the code here and elsewhere is that args is a list, it makes sense that the T2 pen passes lists instead of tuples to the specializeCommands function. --- Lib/fontTools/pens/t2CharStringPen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/fontTools/pens/t2CharStringPen.py b/Lib/fontTools/pens/t2CharStringPen.py index 924e51626..7023149d7 100644 --- a/Lib/fontTools/pens/t2CharStringPen.py +++ b/Lib/fontTools/pens/t2CharStringPen.py @@ -53,7 +53,7 @@ class T2CharStringPen(BasePen): def _p(self, pt): p0 = self._p0 pt = self._p0 = self.roundPoint(pt) - return (pt[0]-p0[0], pt[1]-p0[1]) + return [pt[0]-p0[0], pt[1]-p0[1]] def _moveTo(self, pt): self._commands.append(('rmoveto', self._p(pt)))