diff --git a/Lib/cu2qu/geometry.py b/Lib/cu2qu/geometry.py index 3b9497e5a..b6d8df883 100644 --- a/Lib/cu2qu/geometry.py +++ b/Lib/cu2qu/geometry.py @@ -146,13 +146,13 @@ def curve_to_quadratic(p, max_n, max_err): return spline -def curves_to_quadratic(curves, max_n, max_err): +def curves_to_quadratic(curves, max_n, max_errors): """Return quadratic splines approximating these cubic beziers.""" for n in range(1, max_n + 1): splines = [cubic_approx_spline(c, n) for c in curves] if (all(splines) and - max(curve_spline_dist(c, s) - for c, s in zip(curves, splines)) <= max_err): + all(curve_spline_dist(c, s) < max_err + for c, s, max_err in zip(curves, splines, max_errors))): break return splines diff --git a/Lib/cu2qu/rf.py b/Lib/cu2qu/rf.py index fb74a4f7f..c91073932 100644 --- a/Lib/cu2qu/rf.py +++ b/Lib/cu2qu/rf.py @@ -47,11 +47,12 @@ def fonts_to_quadratic(*fonts, **kwargs): """ max_n = kwargs.get('max_n', 10) - max_err = kwargs.get('max_err', 5) + max_err = kwargs.get('max_err', 0.0025) + max_errors = [f.info.unitsPerEm * max_err for f in fonts] report = {} for glyph in FontCollection(fonts): - glyph_to_quadratic(glyph, max_n, max_err, report) + glyph_to_quadratic(glyph, max_n, max_errors, report) spline_lengths = report.keys() spline_lengths.sort()