Merge pull request #2847 from fonttools/extrapolate-normalize
Allow extrapolation in normalization
This commit is contained in:
commit
f66ee05f71
@ -43,7 +43,7 @@ def subList(truth, lst):
|
||||
return [l for l, t in zip(lst, truth) if t]
|
||||
|
||||
|
||||
def normalizeValue(v, triple):
|
||||
def normalizeValue(v, triple, extrapolate=False):
|
||||
"""Normalizes value based on a min/default/max triple.
|
||||
|
||||
>>> normalizeValue(400, (100, 400, 900))
|
||||
@ -59,7 +59,8 @@ def normalizeValue(v, triple):
|
||||
f"Invalid axis values, must be minimum, default, maximum: "
|
||||
f"{lower:3.3f}, {default:3.3f}, {upper:3.3f}"
|
||||
)
|
||||
v = max(min(v, upper), lower)
|
||||
if not extrapolate:
|
||||
v = max(min(v, upper), lower)
|
||||
if v == default:
|
||||
v = 0.0
|
||||
elif v < default:
|
||||
@ -69,7 +70,7 @@ def normalizeValue(v, triple):
|
||||
return v
|
||||
|
||||
|
||||
def normalizeLocation(location, axes):
|
||||
def normalizeLocation(location, axes, extrapolate=False):
|
||||
"""Normalizes location based on axis min/default/max values from axes.
|
||||
|
||||
>>> axes = {"wght": (100, 400, 900)}
|
||||
@ -111,7 +112,7 @@ def normalizeLocation(location, axes):
|
||||
out = {}
|
||||
for tag, triple in axes.items():
|
||||
v = location.get(tag, triple[1])
|
||||
out[tag] = normalizeValue(v, triple)
|
||||
out[tag] = normalizeValue(v, triple, extrapolate=extrapolate)
|
||||
return out
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user