[interpolatable] Move tolerance calc into the test
This commit is contained in:
parent
7e92c6acf3
commit
96c9bd236f
@ -282,14 +282,8 @@ def test_gen(
|
|||||||
# "contour_order" check
|
# "contour_order" check
|
||||||
#
|
#
|
||||||
|
|
||||||
matching, matching_cost, identity_cost = test_contour_order(glyph0, glyph1)
|
this_tolerance, matching = test_contour_order(glyph0, glyph1)
|
||||||
if matching_cost < identity_cost * tolerance:
|
if this_tolerance < tolerance:
|
||||||
log.debug(
|
|
||||||
"matching_ratio %g",
|
|
||||||
matching_cost / identity_cost,
|
|
||||||
)
|
|
||||||
this_tolerance = matching_cost / identity_cost
|
|
||||||
log.debug("tolerance: %g", this_tolerance)
|
|
||||||
yield (
|
yield (
|
||||||
glyph_name,
|
glyph_name,
|
||||||
{
|
{
|
||||||
@ -352,14 +346,12 @@ def test_gen(
|
|||||||
# after reordering above.
|
# after reordering above.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
proposed_point, reverse, min_cost, first_cost = test_starting_point(
|
this_tolerance, proposed_point, reverse = test_starting_point(
|
||||||
glyph0, glyph1, ix, tolerance, matching
|
glyph0, glyph1, ix, tolerance, matching
|
||||||
)
|
)
|
||||||
|
|
||||||
if proposed_point or reverse:
|
if proposed_point or reverse:
|
||||||
this_tolerance = min_cost / first_cost
|
if this_tolerance < tolerance:
|
||||||
log.debug("tolerance: %g", this_tolerance)
|
|
||||||
if min_cost < first_cost * tolerance:
|
|
||||||
yield (
|
yield (
|
||||||
glyph_name,
|
glyph_name,
|
||||||
{
|
{
|
||||||
@ -381,7 +373,7 @@ def test_gen(
|
|||||||
# If contour could be mid-interpolated, and the two
|
# If contour could be mid-interpolated, and the two
|
||||||
# contours have the same area sign, proceeed.
|
# contours have the same area sign, proceeed.
|
||||||
#
|
#
|
||||||
# The sign difference can happen if it's a werido
|
# The sign difference can happen if it's a weirdo
|
||||||
# self-intersecting contour; ignore it.
|
# self-intersecting contour; ignore it.
|
||||||
contour = midRecording[ix]
|
contour = midRecording[ix]
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from .interpolatableHelpers import *
|
from .interpolatableHelpers import *
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log = logging.getLogger("fontTools.varLib.interpolatable")
|
||||||
|
|
||||||
|
|
||||||
def test_contour_order(glyph0, glyph1):
|
def test_contour_order(glyph0, glyph1):
|
||||||
@ -71,4 +74,9 @@ def test_contour_order(glyph0, glyph1):
|
|||||||
matching_cost = matching_cost_green
|
matching_cost = matching_cost_green
|
||||||
identity_cost = identity_cost_green
|
identity_cost = identity_cost_green
|
||||||
|
|
||||||
return matching, matching_cost, identity_cost
|
this_tolerance = matching_cost / identity_cost if identity_cost else 1
|
||||||
|
log.debug(
|
||||||
|
"test-contour-order: tolerance %g",
|
||||||
|
this_tolerance,
|
||||||
|
)
|
||||||
|
return this_tolerance, matching
|
||||||
|
@ -102,4 +102,9 @@ def test_starting_point(glyph0, glyph1, ix, tolerance, matching):
|
|||||||
# proposed_point = 0 # new_contour1[min_cost_idx][1]
|
# proposed_point = 0 # new_contour1[min_cost_idx][1]
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return proposed_point, reverse, min_cost, first_cost
|
this_tolerance = min_cost / first_cost if first_cost else 1
|
||||||
|
log.debug(
|
||||||
|
"test-starting-point: tolerance %g",
|
||||||
|
this_tolerance,
|
||||||
|
)
|
||||||
|
return this_tolerance, proposed_point, reverse
|
||||||
|
Loading…
x
Reference in New Issue
Block a user