[Cu2QuMultiPen] Add tests and fix a but

Fixes https://github.com/fonttools/fonttools/issues/2926
This commit is contained in:
Behdad Esfahbod 2022-12-13 11:28:33 -07:00
parent d74cb8afe6
commit 78a939848f
2 changed files with 23 additions and 2 deletions

View File

@ -316,7 +316,7 @@ class Cu2QuMultiPen:
def qCurveTo(self, pointsList):
self._check_contour_is_open()
if len(pointsList[0]) == 1:
self.lineTo([points[0] for points in pointsList])
self.lineTo([(points[0],) for points in pointsList])
return
self._add_moveTo()
current_pts = []

View File

@ -15,7 +15,8 @@
import sys
import unittest
from fontTools.pens.cu2quPen import Cu2QuPen, Cu2QuPointPen
from fontTools.pens.cu2quPen import Cu2QuPen, Cu2QuPointPen, Cu2QuMultiPen
from fontTools.pens.recordingPen import RecordingPen
from . import CUBIC_GLYPHS, QUAD_GLYPHS
from .utils import DummyGlyph, DummyPointGlyph
from .utils import DummyPen, DummyPointPen
@ -390,6 +391,26 @@ pen.endPath()""".splitlines())
)
)
class TestCu2QuMultiPen(unittest.TestCase):
def test_multi_pen(self):
pens = [RecordingPen(), RecordingPen()]
pen = Cu2QuMultiPen(pens, .1)
pen.moveTo([((0,0),), ((0,0),)])
pen.lineTo([((0,1),), ((0,1),)])
pen.qCurveTo([((0,2),), ((0,2),)])
pen.qCurveTo([((0,3),(1,3)), ((0,3),(1,4))])
pen.curveTo([((2,3),(0,3),(0,0)), ((1.1,4),(0,4),(0,0))])
pen.closePath()
assert len(pens[0].value) == 6
assert len(pens[1].value) == 6
for op0,op1 in zip(pens[0].value, pens[1].value):
assert op0[0] == op0[0]
assert op0[0] != 'curveTo'
if __name__ == "__main__":
unittest.main()