diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py index d5be5ca7a..9558addbb 100644 --- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py +++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py @@ -311,16 +311,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable): if nameID is not None: return nameID nameID = self._findUnusedNameID() - - nameID_win = self.findMultilingualName(names, windows=True, mac=False) - nameID_mac = self.findMultilingualName(names, windows=False, mac=True) - if nameID_win and nameID_mac is None: - nameID = nameID_win - windows = False - if nameID_mac and nameID_win is None: - nameID = nameID_mac - mac = False - # TODO: Should minimize BCP 47 language codes. # https://github.com/fonttools/fonttools/issues/930 for lang, name in sorted(names.items()): diff --git a/Tests/otlLib/builder_test.py b/Tests/otlLib/builder_test.py index 3d891dd94..877229a55 100644 --- a/Tests/otlLib/builder_test.py +++ b/Tests/otlLib/builder_test.py @@ -1462,15 +1462,16 @@ def test_buildStatTable_name_duplicates(): builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=True) actual_names = [x.string for x in font_obj["name"].names] - expected_names = ['Weight', 'Weight', - 'ExtraLight', 'ExtraLight', - 'Light', 'Light', - 'Regular', 'Regular', - 'Medium', 'Medium', - 'Bold', 'Bold', - 'ExtraBold', 'ExtraBold', - 'Black', 'Black'] - # Multiple name records were added by buildStatTable + expected_names = ['Weight', 'Weight', 'Weight', + 'ExtraLight', 'ExtraLight', 'ExtraLight', + 'Light', 'Light', 'Light', + 'Regular', 'Regular', 'Regular', + 'Medium', 'Medium', 'Medium', + 'Bold', 'Bold', 'Bold', + 'ExtraBold', 'ExtraBold', 'ExtraBold', + 'Black', 'Black', 'Black'] + # Because there is an inconsistency in the names add new name IDs + # for each platform -> windowsNames=True, macNames=True assert sorted(expected_names) == sorted(actual_names) diff --git a/Tests/ttLib/tables/_n_a_m_e_test.py b/Tests/ttLib/tables/_n_a_m_e_test.py index 268870a6b..e1e971351 100644 --- a/Tests/ttLib/tables/_n_a_m_e_test.py +++ b/Tests/ttLib/tables/_n_a_m_e_test.py @@ -317,11 +317,24 @@ class NameTableTest(unittest.TestCase): font_obj["name"].names = [] font_obj["name"].setName('Weight', 270, 3, 1, 0x409) + font_obj["name"].setName('Weight', 270, 1, 0, 0) names = {'en': 'Weight', } nameID = font_obj["name"].addMultilingualName(names, minNameID=256) - self.assertEqual(270, nameID) + font_obj["name"].removeNames(nameID=270, platformID=1) # remove Mac name + nameID = font_obj["name"].addMultilingualName(names, minNameID=256) + # Because there is an inconsistency in the names add a new name ID + self.assertEqual(271, nameID) + + font_obj["name"].removeNames(platformID=3) # remove all Windows names + font_obj["name"].removeNames(platformID=1) # remove all Mac names + nameID = font_obj["name"].addMultilingualName(names, minNameID=256) + #Because there is no name ID with the name 'Weight', + # take the next available name ID -> minNameID=256 + self.assertEqual(256, nameID) + + def test_decompile_badOffset(self): # https://github.com/fonttools/fonttools/issues/525