[Cu2QuMultiPen] Add tests and fix a but
Fixes https://github.com/fonttools/fonttools/issues/2926
This commit is contained in:
parent
d74cb8afe6
commit
78a939848f
@ -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 = []
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user