[reverseContourPen_test] fix expected result for ReverseContourPointPen

This test is not normally run. It is skipped when ufoLib is not importable,
as it's the case from the test runner's virtual environment.

The only reason it exists is so that I could check that the
ReverseContourPen I was writing behaves the same as using ufoLib's
ReverseContourPointPen when the latter is run through the
SegmentToPointPen and PointToSegmentPen converters.

The two methods for reversing contours now diverge since
https://github.com/fonttools/fonttools/pull/1080,
but only nominally because both produce effectively the same results.
The only difference is that, when using the point pens with
outputImpliedClosingLine=True, the closing lineTo is always there even
when it's redundant. In our implmentation, we only output the closing
lineTo when it is the same as moveTo (this was necessary in order to
fix https://github.com/googlei18n/cu2qu/issues/51)
Nevertheless, the total number of points is the same in both cases.

Maybe this test should not be here, as it's testing functionalities
from a different package.

Closes https://github.com/fonttools/fonttools/issues/1081
This commit is contained in:
Cosimo Lupo 2017-10-25 11:17:41 +01:00
parent 273ff46104
commit faedfacbae

View File

@ -305,4 +305,15 @@ def test_reverse_point_pen(contour, expected):
seg2pt = SegmentToPointPen(revpen)
for operator, operands in contour:
getattr(seg2pt, operator)(*operands)
# for closed contours that have a lineTo following the moveTo,
# and whose points don't overlap, our current implementation diverges
# from the ReverseContourPointPen as wrapped by ufoLib's pen converters.
# In the latter case, an extra lineTo is added because of
# outputImpliedClosingLine=True. This is redundant but not incorrect,
# as the number of points is the same in both.
if (contour and contour[-1][0] == "closePath" and
contour[1][0] == "lineTo" and contour[1][1] != contour[0][1]):
expected = expected[:-1] + [("lineTo", contour[0][1])] + expected[-1:]
assert recpen.value == expected