varLib: use addMultilingualName method to support localized axes 'labelname'
now that addMultilingualName method also adds mac names by default, we can use it in varLib instead of addName. The language identifiers are expected to be minimized, i.e. not contain default script/region subtags -- until we implement the minimizeSubtags algorithm from ICU/CLDR: https://github.com/fonttools/fonttools/issues/930
This commit is contained in:
parent
b920b3b36f
commit
acbc65c1a9
@ -753,8 +753,7 @@ class BaseDocReader(LogMixin):
|
||||
# '{http://www.w3.org/XML/1998/namespace}lang'
|
||||
for key, lang in labelNameElement.items():
|
||||
if key == XML_LANG:
|
||||
labelName = labelNameElement.text
|
||||
axisObject.labelNames[lang] = labelName
|
||||
axisObject.labelNames[lang] = tounicode(labelNameElement.text)
|
||||
self.documentObject.axes.append(axisObject)
|
||||
self.axisDefaults[axisObject.name] = axisObject.default
|
||||
self.documentObject.defaultLoc = self.axisDefaults
|
||||
|
@ -76,12 +76,7 @@ def _add_fvar(font, axes, instances):
|
||||
axis.axisTag = Tag(a.tag)
|
||||
# TODO Skip axes that have no variation.
|
||||
axis.minValue, axis.defaultValue, axis.maxValue = a.minimum, a.default, a.maximum
|
||||
axis.axisNameID = nameTable.addName(tounicode(a.labelNames['en']))
|
||||
# TODO:
|
||||
# Replace previous line with the following when the following issues are resolved:
|
||||
# https://github.com/fonttools/fonttools/issues/930
|
||||
# https://github.com/fonttools/fonttools/issues/931
|
||||
# axis.axisNameID = nameTable.addMultilingualName(a.labelname, font)
|
||||
axis.axisNameID = nameTable.addMultilingualName(a.labelNames, font)
|
||||
fvar.axes.append(axis)
|
||||
|
||||
for instance in instances:
|
||||
@ -662,10 +657,10 @@ def load_designspace(designspace):
|
||||
instances = ds.instances
|
||||
|
||||
standard_axis_map = OrderedDict([
|
||||
('weight', ('wght', {'en':'Weight'})),
|
||||
('width', ('wdth', {'en':'Width'})),
|
||||
('slant', ('slnt', {'en':'Slant'})),
|
||||
('optical', ('opsz', {'en':'Optical Size'})),
|
||||
('weight', ('wght', {'en': u'Weight'})),
|
||||
('width', ('wdth', {'en': u'Width'})),
|
||||
('slant', ('slnt', {'en': u'Slant'})),
|
||||
('optical', ('opsz', {'en': u'Optical Size'})),
|
||||
])
|
||||
|
||||
# Setup axes
|
||||
@ -684,7 +679,7 @@ def load_designspace(designspace):
|
||||
else:
|
||||
assert axis.tag is not None
|
||||
if not axis.labelNames:
|
||||
axis.labelNames["en"] = axis_name
|
||||
axis.labelNames["en"] = tounicode(axis_name)
|
||||
|
||||
axes[axis_name] = axis
|
||||
log.info("Axes:\n%s", pformat([axis.asdict() for axis in axes.values()]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user