[varLib.featureVars] Fix region-merging code on Py3
We should clean up all the various "convert dict to tuple" duplicated code, but this fixes it for now. doctest updated. Fixes https://github.com/fonttools/fonttools/issues/1659
This commit is contained in:
parent
e1f0d1ae09
commit
84b9e9c387
@ -71,7 +71,7 @@ def overlayFeatureVariations(conditionalSubstitutions):
|
||||
and rules with the same Box merged. The more specific rules appear earlier
|
||||
in the resulting list. Moreover, instead of just a dictionary of substitutions,
|
||||
a list of dictionaries is returned for substitutions corresponding to each
|
||||
uniq space, with each dictionary being identical to one of the input
|
||||
unique space, with each dictionary being identical to one of the input
|
||||
substitution dictionaries. These dictionaries are not merged to allow data
|
||||
sharing when they are converted into font tables.
|
||||
|
||||
@ -79,6 +79,7 @@ def overlayFeatureVariations(conditionalSubstitutions):
|
||||
>>> condSubst = [
|
||||
... # A list of (Region, Substitution) tuples.
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wdth": (0.5, 1.0)}], {"cent": "cent.rvrn"}),
|
||||
... ]
|
||||
>>> from pprint import pprint
|
||||
@ -107,7 +108,8 @@ def overlayFeatureVariations(conditionalSubstitutions):
|
||||
# rules for the same region.
|
||||
merged = OrderedDict()
|
||||
for key,value in reversed(conditionalSubstitutions):
|
||||
key = tuple(sorted(hashdict(cleanupBox(k)) for k in key))
|
||||
key = tuple(sorted((hashdict(cleanupBox(k)) for k in key),
|
||||
key=lambda d: tuple(sorted(d.items()))))
|
||||
if key in merged:
|
||||
merged[key].update(value)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user