[pens] Improve error message if pen.moveTo() is omitted. (#1757)
Improve error message if pen.moveTo() is omitted. See also robotools/fontParts#470
This commit is contained in:
parent
5790f7f9af
commit
07140c12bd
@ -247,9 +247,11 @@ class SegmentToPointPen(AbstractPen):
|
|||||||
self.contour.append((pt, "move"))
|
self.contour.append((pt, "move"))
|
||||||
|
|
||||||
def lineTo(self, pt):
|
def lineTo(self, pt):
|
||||||
|
assert self.contour is not None, "contour missing required initial moveTo"
|
||||||
self.contour.append((pt, "line"))
|
self.contour.append((pt, "line"))
|
||||||
|
|
||||||
def curveTo(self, *pts):
|
def curveTo(self, *pts):
|
||||||
|
assert self.contour is not None, "contour missing required initial moveTo"
|
||||||
for pt in pts[:-1]:
|
for pt in pts[:-1]:
|
||||||
self.contour.append((pt, None))
|
self.contour.append((pt, None))
|
||||||
self.contour.append((pts[-1], "curve"))
|
self.contour.append((pts[-1], "curve"))
|
||||||
@ -257,12 +259,15 @@ class SegmentToPointPen(AbstractPen):
|
|||||||
def qCurveTo(self, *pts):
|
def qCurveTo(self, *pts):
|
||||||
if pts[-1] is None:
|
if pts[-1] is None:
|
||||||
self.contour = []
|
self.contour = []
|
||||||
|
else:
|
||||||
|
assert self.contour is not None, "contour missing required initial moveTo"
|
||||||
for pt in pts[:-1]:
|
for pt in pts[:-1]:
|
||||||
self.contour.append((pt, None))
|
self.contour.append((pt, None))
|
||||||
if pts[-1] is not None:
|
if pts[-1] is not None:
|
||||||
self.contour.append((pts[-1], "qcurve"))
|
self.contour.append((pts[-1], "qcurve"))
|
||||||
|
|
||||||
def closePath(self):
|
def closePath(self):
|
||||||
|
assert self.contour is not None, "contour missing required initial moveTo"
|
||||||
if len(self.contour) > 1 and self.contour[0][0] == self.contour[-1][0]:
|
if len(self.contour) > 1 and self.contour[0][0] == self.contour[-1][0]:
|
||||||
self.contour[0] = self.contour[-1]
|
self.contour[0] = self.contour[-1]
|
||||||
del self.contour[-1]
|
del self.contour[-1]
|
||||||
@ -276,6 +281,7 @@ class SegmentToPointPen(AbstractPen):
|
|||||||
self.contour = None
|
self.contour = None
|
||||||
|
|
||||||
def endPath(self):
|
def endPath(self):
|
||||||
|
assert self.contour is not None, "contour missing required initial moveTo"
|
||||||
self._flushContour()
|
self._flushContour()
|
||||||
self.contour = None
|
self.contour = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user