[name] Fix platform ID for names whose language code is in ltag table

https://github.com/fonttools/fonttools/issues/931
This commit is contained in:
Sascha Brawer 2017-04-20 11:08:11 +02:00
parent 656478fc6d
commit a5c8977dd3
2 changed files with 7 additions and 4 deletions

View File

@ -177,7 +177,10 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
ltag = ttFont.tables.get("ltag")
if ltag is None:
ltag = ttFont["ltag"] = newTable("ltag")
self.names.append(makeName(name, nameID, 2, 4, ltag.addTag(lang)))
# 0 = Unicode; 4 = “Unicode 2.0 or later semantics (non-BMP characters allowed)”
# “The preferred platform-specific code for Unicode would be 3 or 4.”
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
self.names.append(makeName(name, nameID, 0, 4, ltag.addTag(lang)))
# Add a Windows name.
windowsLang = _WINDOWS_LANGUAGE_CODES.get(lang.lower())
if windowsLang is not None:

View File

@ -83,14 +83,14 @@ class NameTableTest(unittest.TestCase):
for n in nameTable.names]
names.sort()
self.assertEqual(names, [
(256, 0, 4, 0, "Breite"),
(256, 0, 4, 1, "Bräiti"),
(256, 1, 0, 0, "Width"),
(256, 2, 4, 0, "Breite"),
(256, 2, 4, 1, "Bräiti"),
(256, 3, 1, 0x0409, "Width"),
(256, 3, 1, 0x0484, "Bräiti"),
(256, 3, 1, 0x0807, "Breite"),
(257, 0, 4, 1, "X-Hööchi"),
(257, 1, 0, 0, "X-Height"),
(257, 2, 4, 1, "X-Hööchi"),
(257, 3, 1, 0x0409, "X-Height"),
(257, 3, 1, 0x0484, "X-Hööchi"),
])