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.
This commit is contained in:
Cosimo Lupo 2017-05-08 10:51:39 +01:00
parent 30b804003e
commit 41445b8449
No known key found for this signature in database
GPG Key ID: B61AAAD0B53A6419

View File

@ -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)))