[varLib] Check all master and instance locations are valid
Ie. they don't specify any unknown axes, and location is within axis minimum/maximum. We also allow master / instance locations to not specify some axes, and we fill in the axis default for those.
This commit is contained in:
parent
9034f4f3f1
commit
0fa41c14b9
@ -426,8 +426,18 @@ def build(designspace_filename, master_finder=lambda s:s):
|
||||
axis_supports[axis.name] = (axis.minimum, axis.default, axis.maximum)
|
||||
log.info("Axis supports:\n%s", pformat(axis_supports))
|
||||
|
||||
# TODO
|
||||
# check all masters and instances locations are valid and fill in default items
|
||||
# Check all master and instance locations are valid and fill in defaults
|
||||
for obj in masters+instances:
|
||||
obj_name = obj.get('name', obj.get('stylename', ''))
|
||||
loc = obj['location']
|
||||
for name in loc.keys():
|
||||
assert name in axes, "Location axis '%s' unknown for '%s'." % (name, obj_name)
|
||||
for axis_name,axis in axes.items():
|
||||
if axis_name not in loc:
|
||||
loc[axis_name] = axis.default
|
||||
else:
|
||||
v = loc[axis_name]
|
||||
assert axis.minimum <= v <= axis.maximum, "Location for axis '%s' (%s) out of range for '%s'" % (name, v, obj_name)
|
||||
|
||||
master_locs = [o['location'] for o in masters]
|
||||
log.info("Master locations:\n%s", pformat(master_locs))
|
||||
|
@ -4,7 +4,6 @@
|
||||
<source familyname="Test Family" filename="master_ufo/TestFamily-Master0.ufo" name="master_0" stylename="Master0">
|
||||
<location>
|
||||
<dimension name="weight" xvalue="0" />
|
||||
<dimension name="contrast" xvalue="0" />
|
||||
</location>
|
||||
</source>
|
||||
<source familyname="Test Family" filename="master_ufo/TestFamily-Master1.ufo" name="master_1" stylename="Master1">
|
||||
|
Loading…
x
Reference in New Issue
Block a user