Localize instance subfamily name too.

This commit is contained in:
Simon Cozens 2021-02-11 16:05:02 +00:00
parent d470ea4870
commit 285f861e45

View File

@ -670,6 +670,8 @@ class FontBuilder(object):
The instances should be a list of dicts; each instance should be supplied The instances should be a list of dicts; each instance should be supplied
as a dict with keys ``location`` (mapping of axis tags to float values), as a dict with keys ``location`` (mapping of axis tags to float values),
``stylename`` and (optionally) ``postscriptfontname``. ``stylename`` and (optionally) ``postscriptfontname``.
The ``stylename`` is either a string, or a dict, mapping language codes
to strings, to allow localized name table entries.
""" """
addFvar(self.font, axes, instances) addFvar(self.font, axes, instances)
@ -928,9 +930,11 @@ def addFvar(font, axes, instances):
coordinates = instance["location"] coordinates = instance["location"]
name = instance["stylename"] name = instance["stylename"]
psname = instance.get("postscriptfontname") psname = instance.get("postscriptfontname")
if isinstance(name, str):
name = dict(en=name)
inst = NamedInstance() inst = NamedInstance()
inst.subfamilyNameID = nameTable.addName(name) inst.subfamilyNameID = nameTable.addMultilingualName(name, ttFont=font)
if psname is not None: if psname is not None:
psname = psname psname = psname
inst.postscriptNameID = nameTable.addName(psname) inst.postscriptNameID = nameTable.addName(psname)