aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/ttLib/tables/_n_a_m_e.py
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-01-08 14:14:22 -0800
committerHaibo Huang <hhb@google.com>2019-01-08 14:22:09 -0800
commit79019a0d336efb722a395ed2db4c5d638104494e (patch)
treec53dd801899ade2bca1472885cc513b49469348c /Lib/fontTools/ttLib/tables/_n_a_m_e.py
parent69c9acab6a81c7bce36329972332cdbd0d11f449 (diff)
downloadfonttools-79019a0d336efb722a395ed2db4c5d638104494e.tar.gz
Upgrade fonttools from 3.31.0 to 3.35.0
Ran `tools/external_updater/updater.sh update fonttools`. Test: builds Change-Id: I40f991612bf5a41fdd90fc298aef7b02e5a283ad
Diffstat (limited to 'Lib/fontTools/ttLib/tables/_n_a_m_e.py')
-rw-r--r--Lib/fontTools/ttLib/tables/_n_a_m_e.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
index a30291cc..488c4ea5 100644
--- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py
+++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
@@ -161,7 +161,8 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
raise ValueError("nameID must be less than 32768")
return nameID
- def addMultilingualName(self, names, ttFont=None, nameID=None):
+ def addMultilingualName(self, names, ttFont=None, nameID=None,
+ windows=True, mac=True):
"""Add a multilingual name, returning its name ID
'names' is a dictionary with the name in multiple languages,
@@ -176,6 +177,9 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
'nameID' is the name ID to be used, or None to let the library
pick an unused name ID.
+
+ If 'windows' is True, a platformID=3 name record will be added.
+ If 'mac' is True, a platformID=1 name record will be added.
"""
if not hasattr(self, 'names'):
self.names = []
@@ -184,15 +188,16 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
# TODO: Should minimize BCP 47 language codes.
# https://github.com/fonttools/fonttools/issues/930
for lang, name in sorted(names.items()):
- # Apple platforms have been recognizing Windows names
- # since early OSX (~2001), so we only add names
- # for the Macintosh platform when we cannot not make
- # a Windows name. This can happen for exotic BCP47
- # language tags that have no Windows language code.
- windowsName = _makeWindowsName(name, nameID, lang)
- if windowsName is not None:
- self.names.append(windowsName)
- else:
+ if windows:
+ windowsName = _makeWindowsName(name, nameID, lang)
+ if windowsName is not None:
+ self.names.append(windowsName)
+ else:
+ # We cannot not make a Windows name: make sure we add a
+ # Mac name as a fallback. This can happen for exotic
+ # BCP47 language tags that have no Windows language code.
+ mac = True
+ if mac:
macName = _makeMacName(name, nameID, lang, ttFont)
if macName is not None:
self.names.append(macName)