robotools / fontParts

The replacement for RoboFab
MIT License
135 stars 44 forks source link

insertSegment with open contour #601

Closed typemytype closed 3 years ago

typemytype commented 3 years ago

when inserting a segment with an open contour, the insert index is off by 1 and creates invalid contour structures.

(a PR is coming)

g = RGlyph()

pen = g.getPen()
pen.moveTo((0, 0))
pen.curveTo((0, 50), (50, 100), (100, 100))
pen.curveTo((150, 100), (200, 50), (200, 0))

pen.endPath()

c = g.contours[0]
c.insertSegment(1, "line", [(100, 200)])

for point in c.points:
    print(point)
<RPoint move (0, 0) at 4813159824>
<RPoint offcurve (0, 50) at 4813158864>
<RPoint line (100, 200) at 4813159888>
<RPoint offcurve (50, 100) at 4813158736>
<RPoint curve (100, 100) smooth=True at 4813159760>
<RPoint offcurve (150, 100) at 4813159120>
<RPoint offcurve (200, 50) at 4813160272>
<RPoint curve (200, 0) at 4813160080>