aboutsummaryrefslogtreecommitdiff
path: root/Tests/misc/bezierTools_test.py
diff options
context:
space:
mode:
authorRod S <rsheeter@google.com>2022-03-25 12:41:45 -0700
committerSeigo Nonaka <nona@google.com>2022-03-25 12:49:44 -0700
commit0b59a54a78ee22be83fe249c724c19ebd7d26ede (patch)
tree98d81cb66669c50af608fd8a844e22039a00f5ae /Tests/misc/bezierTools_test.py
parent7464785773cfc59c180c0dbd4b8f91dbe9d5c49f (diff)
downloadfonttools-0b59a54a78ee22be83fe249c724c19ebd7d26ede.tar.gz
Update FontTools to 4.31.2 to gain access to iterSubTables.
Needed to facilitate implementation of additional emoji font validation. Ran tools/external_updater/updater.sh update fonttools Bug: 226676748 Test: will run presubmit Test: m fontchain_lint Change-Id: I1207eea8394848bd2ef5040de9aebc8f940b1d96
Diffstat (limited to 'Tests/misc/bezierTools_test.py')
-rw-r--r--Tests/misc/bezierTools_test.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/Tests/misc/bezierTools_test.py b/Tests/misc/bezierTools_test.py
index c5cd1b73..da73375d 100644
--- a/Tests/misc/bezierTools_test.py
+++ b/Tests/misc/bezierTools_test.py
@@ -1,6 +1,8 @@
+import fontTools.misc.bezierTools as bezierTools
from fontTools.misc.bezierTools import (
- calcQuadraticBounds, calcCubicBounds, segmentPointAtT, splitLine, splitQuadratic,
- splitCubic, splitQuadraticAtT, splitCubicAtT, solveCubic)
+ calcQuadraticBounds, calcCubicBounds, curveLineIntersections,
+ segmentPointAtT, splitLine, splitQuadratic, splitCubic, splitQuadraticAtT,
+ splitCubicAtT, solveCubic)
import pytest
@@ -148,3 +150,17 @@ _segmentPointAtT_testData = [
def test_segmentPointAtT(segment, t, expectedPoint):
point = segmentPointAtT(segment, t)
assert expectedPoint == point
+
+
+def test_intersections_straight_line():
+ curve = ((548, 183), (548, 289), (450, 366), (315, 366))
+ line1 = ((330, 376), (330, 286))
+ pt = curveLineIntersections(curve, line1)[0][0]
+ assert pt[0] == 330
+ line = (pt, (330, 286))
+ pt2 = (330.0001018806911, 295.5635754579425)
+ assert bezierTools._line_t_of_pt(*line, pt2) > 0
+ s = (19, 0)
+ e = (110, 0)
+ pt = (109.05194805194802, 0.0)
+ assert bezierTools._line_t_of_pt(s, e, pt) == pytest.approx(0.98958184)