From 4c22d11aa714bf94cd61b6448448b5cd347f859c Mon Sep 17 00:00:00 2001 From: Takaaki Fuji Date: Fri, 25 Jun 2021 09:35:41 +0900 Subject: [PATCH] Keep GuessSmoothPointPen in sync with fontPens Imported 9b7ecb4 from fontPens, which is the version modified to accept a parameterized tolerance. Recent changes in fontTools such as 2831096, 186e461 and 7d5530e were considered so that the diff will be minimal. --- Lib/fontTools/pens/pointPen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/pens/pointPen.py b/Lib/fontTools/pens/pointPen.py index 2916a171c..9ae693f81 100644 --- a/Lib/fontTools/pens/pointPen.py +++ b/Lib/fontTools/pens/pointPen.py @@ -330,8 +330,9 @@ class GuessSmoothPointPen(AbstractPointPen): should be "smooth", ie. that it's a "tangent" point or a "curve" point. """ - def __init__(self, outPen): + def __init__(self, outPen, error=0.05): self._outPen = outPen + self._error = error self._points = None def _flushContour(self): @@ -368,7 +369,7 @@ class GuessSmoothPointPen(AbstractPointPen): dx2, dy2 = nextPt[0] - pt[0], nextPt[1] - pt[1] a1 = math.atan2(dx1, dy1) a2 = math.atan2(dx2, dy2) - if abs(a1 - a2) < 0.05: + if abs(a1 - a2) < self._error: points[i] = pt, segmentType, True, name, kwargs for pt, segmentType, smooth, name, kwargs in points: