[varLib] default to using "name" attribute if "labelname" is missing

Instead of raising AssertionError when users define custom axes
without explicit `<labelname xml:lang="en">ZZZZ</labelname>` element,
it's better to use the axis' name attribute, and treat it as "en"
language.

For example, if users generate the designspace from SuperPolator,
they can't edit the axis labelname attribute from the UI (or maybe
it's just me that couldn't figure out how to do it).
This commit is contained in:
Cosimo Lupo 2017-09-15 16:49:16 -04:00
parent 556508b0e9
commit 588f5246c0

View File

@ -734,8 +734,10 @@ def load_designspace(designspace_filename):
axis_dict['labelname'] = standard_axis_map[axis_name][1].copy()
axis = DesignspaceAxis()
for item in ['name', 'tag', 'labelname', 'minimum', 'default', 'maximum', 'map']:
for item in ['name', 'tag', 'minimum', 'default', 'maximum', 'map']:
assert item in axis_dict, 'Axis does not have "%s"' % item
if 'labelname' not in axis_dict:
axis_dict['labelname'] = {'en': axis_name}
axis.__dict__ = axis_dict
axis_objects[axis_name] = axis
else: