This commit fixes an issue where a point suddenly disappears during merging.
The problem was caused by an off-by-one error in the clipping coordinates.
The problem was fixed by including t = 1 when looking for a t-value during curve fitting in _tValueForPointOnCubicCurve.
Looking at the merge point in detail, there was an offset by 1 (an error of 1 / 2 ^ 17).
One of the points, the point on 47, was removed by pyclipper so the output contour was smooth.
However this difference caused the curve to go into the condition on line 806 in OutputContour.reCurveSubSegments where it thinks the end of flatSegment is different from inputSegment.flat[0].
In that condition, we search for the tValue for a point 1 (in 2^17) off the end point. The solver from inputSegment.tValueForPoint(searchPoint) returns 1.0 which gets filtered out by line 968:
solutions = [t for t in solutions if 0 <= t < 1]
The result of this is tValues = [] and in turn this skips the condition on line 853 thus a point gets omitted/deleted.
Allowing the t-value solver to include the end point fixes the issue.
Overview
This commit fixes an issue where a point suddenly disappears during merging. The problem was caused by an off-by-one error in the clipping coordinates. The problem was fixed by including t = 1 when looking for a t-value during curve fitting in
_tValueForPointOnCubicCurve
.Details
Test file: thin.ufo.zip
Here's the outline before merging.
And the output after merging.
Looking at the merge point in detail, there was an offset by 1 (an error of 1 / 2 ^ 17).
One of the points, the point on 47, was removed by
pyclipper
so the output contour was smooth. However this difference caused the curve to go into the condition on line 806 inOutputContour.reCurveSubSegments
where it thinks the end offlatSegment
is different frominputSegment.flat[0]
. In that condition, we search for the tValue for a point 1 (in 2^17) off the end point. The solver frominputSegment.tValueForPoint(searchPoint)
returns 1.0 which gets filtered out by line 968:The result of this is
tValues = []
and in turn this skips the condition on line 853 thus a point gets omitted/deleted.Allowing the t-value solver to include the end point fixes the issue.