From e3f7154a9db2abeca9a780a0614b658eb399d2ca Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Feb 2023 14:15:30 -0700 Subject: [PATCH] [qu2cuPen] Keep quadratics if more economical Perhaps the pen should have a setting for this. --- Lib/fontTools/pens/qu2cuPen.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/pens/qu2cuPen.py b/Lib/fontTools/pens/qu2cuPen.py index b5950af35..9cccc2790 100644 --- a/Lib/fontTools/pens/qu2cuPen.py +++ b/Lib/fontTools/pens/qu2cuPen.py @@ -51,12 +51,15 @@ class Qu2CuPen(FilterPen): if self.stats is not None: n = str(len(curves)) self.stats[n] = self.stats.get(n, 0) + 1 - for curve in curves: - self.curveTo(*curve[1:]) + if len(quadratics) <= len(curves) * 3: + super().qCurveTo(*quadratics) + else: + for curve in curves: + self.curveTo(*curve[1:]) def qCurveTo(self, *points): n = len(points) - if n < 2: - self.lineTo(*points) + if n <= 3: + super().qCurveTo(*points) else: self._quadratic_to_curve(points)