Skip to content

Commit fef272d

Browse files
authored
Merge pull request #43 from moyogo/open-contour-error
Raise BooleanOperationsError on open contour
2 parents 35ccac1 + 8ddc497 commit fef272d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Lib/booleanOperations/exceptions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ class BooleanOperationsError(Exception):
66

77

88
class InvalidContourError(BooleanOperationsError):
9-
"""Rased when any input contour is invalid"""
9+
"""Raised when any input contour is invalid"""
1010

1111

1212
class InvalidSubjectContourError(InvalidContourError):
13-
"""Rased when a 'subject' contour is not valid"""
13+
"""Raised when a 'subject' contour is not valid"""
1414

1515

1616
class InvalidClippingContourError(InvalidContourError):
17-
"""Rased when a 'clipping' contour is not valid"""
17+
"""Raised when a 'clipping' contour is not valid"""
18+
19+
20+
class OpenContourError(BooleanOperationsError):
21+
"""Raised when any input contour is open"""
1822

1923

2024
class ExecutionError(BooleanOperationsError):

Lib/booleanOperations/flatten.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from fontTools.misc import bezierTools
44
from fontTools.pens.basePen import decomposeQuadraticSegment
55
import pyclipper
6+
from .exceptions import OpenContourError
67

78
"""
89
To Do:
@@ -339,7 +340,8 @@ def endPath(self):
339340
pass
340341

341342
def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs):
342-
assert segmentType != "move"
343+
if segmentType == "move":
344+
raise OpenContourError("Unhandled open contour")
343345
if not self._foundStartingPoint and segmentType is not None:
344346
kwargs['startingPoint'] = self._foundStartingPoint = True
345347
data = InputPoint(

0 commit comments

Comments
 (0)