From 983307d9cd005cd481f7a1664dc3b32e58950fd5 Mon Sep 17 00:00:00 2001 From: James Godfrey-Kittle Date: Mon, 4 Apr 2016 17:30:33 -0700 Subject: [PATCH] [ufo] Allow input fonts with quadratic curves --- Lib/cu2qu/ufo.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/cu2qu/ufo.py b/Lib/cu2qu/ufo.py index 87dd80e7c..c4d11d219 100644 --- a/Lib/cu2qu/ufo.py +++ b/Lib/cu2qu/ufo.py @@ -45,26 +45,32 @@ def zip(*args): class GetSegmentsPen(AbstractPen): - """Pen to collect segments into lists of points for conversion.""" + """Pen to collect segments into lists of points for conversion. + + Curves always include their initial on-curve point, so some points are + duplicated between segments. + """ def __init__(self): self._last_pt = None self.segments = [] def _add_segment(self, tag, *args): + if tag in ['move', 'line', 'qcurve', 'curve']: + self._last_pt = args[-1] self.segments.append((tag, args)) def moveTo(self, pt): self._add_segment('move', pt) - self._last_pt = pt def lineTo(self, pt): self._add_segment('line', pt) - self._last_pt = pt + + def qCurveTo(self, *points): + self._add_segment('qcurve', self._last_pt, *points) def curveTo(self, *points): self._add_segment('curve', self._last_pt, *points) - self._last_pt = points[-1] def closePath(self): self._add_segment('close')