This reverts commit fe2e897d13aab383d03b7759a15787ed2db99c77.
ufo2ft tests are failing with fonttools master with this error:
fontTools/cffLib/specializer.py:497:
> commands[i-1] = (new_op, args1+args2)
TypeError: can only concatenate list (not "tuple") to list
Previously, for closed paths, we were always dropping a lineTo segment
that followed moveTo, because after reversing the contour this lineTo
would become the last segment, and in the Pen protocol a closePath
always implies a line to the fist point.
This is OK when the move point and the following lineTo oncurve point
(which becomes last after reversal) don't overlap.
However, if they do, we ended up dropping the duplicate point.
This cu2qu issue exemplify the problem (cu2qu actually uses the
ReverseContourPointPen wrapped by ufoLib's converter pens, but
fontTools' ReverseContourPen does exactly the same):
https://github.com/googlei18n/cu2qu/issues/51
With this patch, the ReverseContourPen now emits the last lineTo
when it is the same as moveTo.
A filter pen that passes outline data to another pen, but reversing
the winding direction of all contours.
Like ufoLib's ReverseContourPointPen, but using segment-wise pen
interface, without additional point/segment converters, and without
ufoLib.
627f997ddb/Lib/ufoLib/pointPen.py (L327-L406)
A filter pen that accumulates contour data, passes it through a
`filterContour` method as the contour is closed or ended, and
draws the result with the output pen.
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.
Tests are failing now, as cffLib.specializer combines operations whereas
previous pen didn't. I checked all failures and they all look like the
expectation needs to be updated to me.
Fixes https://github.com/fonttools/fonttools/issues/403
This is so we can reuse addComponent with the recording pen, without having to
inherit from the BasePen (which also splits curveTo and qCurveTo commands).
Log warning message on missing glyphs by default, optionally raise KeyError
if skipMissingComponents = False