From 21dea1e18d5e329c47cb7329880c9aca774894dd Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 6 Oct 2023 10:10:46 +0100 Subject: [PATCH] fix incorrectly typed cython local variable Fixes https://github.com/fonttools/fonttools/issues/3287 --- Lib/fontTools/misc/bezierTools.py | 2 +- Tests/misc/bezierTools_test.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/misc/bezierTools.py b/Lib/fontTools/misc/bezierTools.py index 7772a4bf8..21ab0a5d0 100644 --- a/Lib/fontTools/misc/bezierTools.py +++ b/Lib/fontTools/misc/bezierTools.py @@ -141,7 +141,7 @@ def _dot(v1, v2): @cython.cfunc @cython.inline @cython.returns(cython.double) -@cython.locals(x=cython.complex) +@cython.locals(x=cython.double) def _intSecAtan(x): # In : sympy.integrate(sp.sec(sp.atan(x))) # Out: x*sqrt(x**2 + 1)/2 + asinh(x)/2 diff --git a/Tests/misc/bezierTools_test.py b/Tests/misc/bezierTools_test.py index 3e4c28ee7..8a3e2ecda 100644 --- a/Tests/misc/bezierTools_test.py +++ b/Tests/misc/bezierTools_test.py @@ -1,6 +1,7 @@ import fontTools.misc.bezierTools as bezierTools from fontTools.misc.bezierTools import ( calcQuadraticBounds, + calcQuadraticArcLength, calcCubicBounds, curveLineIntersections, segmentPointAtT, @@ -181,3 +182,10 @@ def test_intersections_straight_line(): e = (110, 0) pt = (109.05194805194802, 0.0) assert bezierTools._line_t_of_pt(s, e, pt) == pytest.approx(0.98958184) + + +def test_calcQuadraticArcLength(): + # https://github.com/fonttools/fonttools/issues/3287 + assert calcQuadraticArcLength( + (210, 333), (289, 333), (326.5, 290.5) + ) == pytest.approx(127.9225)