Fixed subtle bug in curve intersection logic: due to floating point errors,
sometimes a legitimate solution is ever so slightly over 1.0. Those used to be filtered out; now checking for 1.0 + 1e-10. git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@460 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
parent
8e1d75b1a3
commit
05e2541b49
@ -9,6 +9,12 @@ from fontTools.misc.bezierTools import solveQuadratic, solveCubic
|
||||
__all__ = ["PointInsidePen"]
|
||||
|
||||
|
||||
# working around floating point errors
|
||||
EPSILON = 1e-10
|
||||
ONE_PLUS_EPSILON = 1 + EPSILON
|
||||
ZERO_MINUS_EPSILON = 0 - EPSILON
|
||||
|
||||
|
||||
class PointInsidePen(BasePen):
|
||||
|
||||
"""This pen implements "point inside" testing: to test whether
|
||||
@ -116,7 +122,7 @@ class PointInsidePen(BasePen):
|
||||
ay = y4 - dy - cy - by
|
||||
solutions = solveCubic(ay, by, cy, dy - y)
|
||||
solutions.sort()
|
||||
solutions = [t for t in solutions if 0 <= t <= 1]
|
||||
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
||||
if not solutions:
|
||||
return
|
||||
|
||||
@ -172,7 +178,7 @@ class PointInsidePen(BasePen):
|
||||
a = y3 - c - b
|
||||
solutions = solveQuadratic(a, b, c - y)
|
||||
solutions.sort()
|
||||
solutions = [t for t in solutions if 0 <= t <= 1]
|
||||
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
||||
if not solutions:
|
||||
return
|
||||
XXX
|
||||
|
Loading…
x
Reference in New Issue
Block a user