Skip to content

Commit

Permalink
Small fix in setStartSegment behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
typesupply committed Oct 30, 2023
1 parent 74a38a5 commit 23da1e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Lib/fontParts/base/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@ def _setStartSegment(self, segmentIndex, **kwargs):
"""
Subclasses may override this method.
"""
# get the previous segment and set
# its on curve as the first point
# in the contour. this matches the
# iteration behavior of self.segments.
segmentIndex -= 1
segments = self.segments
segment = segments[segmentIndex]
self.setStartPoint(segment.points[-1])
Expand Down
6 changes: 3 additions & 3 deletions Lib/fontParts/test/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,16 @@ def test_setStartSegment(self):
contour.appendPoint((100, 25), "offcurve")
contour.appendPoint((100, 50), "curve")
contour.appendPoint((100, 75), "offcurve")
contour.appendPoint((100, 25), "offcurve")
contour.appendPoint((75, 100), "offcurve")
contour.appendPoint((50, 100), "curve")
contour.appendPoint((25, 100), "offcurve")
contour.appendPoint((0, 75), "offcurve")
contour.appendPoint((100, 25), "offcurve")
contour.appendPoint((0, 50), "curve")
contour.appendPoint((0, 25), "offcurve")
contour.appendPoint((25, 0), "offcurve")
contour.setStartSegment(1)
self.assertEqual(contour.points[0].type, "curve")
self.assertEqual((contour.points[0].x, contour.points[0].y), (50, 100))
self.assertEqual((contour.points[0].x, contour.points[0].y), (100, 50))

# ------
# points
Expand Down

0 comments on commit 23da1e9

Please sign in to comment.