Skip to content

Commit 5429f02

Browse files
authored
Merge branch 'main' into test-segment
2 parents 83e6915 + c2508a4 commit 5429f02

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/fontParts/base/segment.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,16 @@ def _set_type(self, newType: str) -> None:
303303
Subclasses may override this method.
304304
305305
"""
306+
contour = self.contour
307+
if contour is None:
308+
raise FontPartsError("The segment does not belong to a contour.")
306309
oldType = self.type
307310
if oldType == newType:
308311
return
309312
if self.onCurve is None:
310313
# special case with a single qcurve segment
311314
# and only offcurves, don't convert
312315
return
313-
contour = self.contour
314-
if contour is None:
315-
raise FontPartsError("The segment does not belong to a contour.")
316316
# converting line <-> move
317317
if newType in ("move", "line") and oldType in ("move", "line"):
318318
pass
@@ -547,7 +547,10 @@ def _get_onCurve(self) -> BasePoint | None:
547547
Subclasses may override this method.
548548
549549
"""
550-
value = self.points[-1]
550+
points = self.points
551+
if not points:
552+
return None
553+
value = points[-1]
551554
if value.type == "offcurve":
552555
return None
553556
return value

0 commit comments

Comments
 (0)