From 1e991d0eaddbd61a1546c2b606c8036d574eeedb Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 4 Nov 2016 18:23:18 +0000 Subject: [PATCH] flatten: in InputSegment, convert 'flat' curves to lines if both off-curves are aligned with on-curves Fixes https://github.com/googlei18n/fontmake/issues/180 --- Lib/booleanOperations/flatten.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/booleanOperations/flatten.py b/Lib/booleanOperations/flatten.py index 68e602e..6b5100f 100644 --- a/Lib/booleanOperations/flatten.py +++ b/Lib/booleanOperations/flatten.py @@ -147,7 +147,7 @@ def __init__(self, points=None, previousOnCurve=None, willBeReversed=False): self.scaledPreviousOnCurve = _scaleSinglePoint(previousOnCurve, scale=clipperScale) self.used = False self.flat = [] - # if the bcps are equal to the oncurves convert the segment to a line segment. + # if the bcps are equal to the oncurves, or are aligned with them, convert the segment to a line segment. # otherwise this causes an error when flattening. if self.segmentType == "curve": if previousOnCurve == points[0].coordinates and points[1].coordinates == points[-1].coordinates: @@ -162,6 +162,11 @@ def __init__(self, points=None, previousOnCurve=None, willBeReversed=False): oncurve = points[-1] oncurve.segmentType = "line" self.points = points = [oncurve] + elif (_pointOnLine(previousOnCurve, points[-1].coordinates, points[0].coordinates) and + _pointOnLine(previousOnCurve, points[-1].coordinates, points[1].coordinates)): + oncurve = points[-1] + oncurve.segmentType = "line" + self.points = points = [oncurve] # its a reversed segment the flat points will be set later on in the InputContour if willBeReversed: return