[ttLib] Fix warning when calling addMultilingualName() with "ar" name
I get warning from _makeMacName() because it does not have a TTFont, but the font is there, just not passed from addMultilingualName() -> findMultilingualName() -> _makeMacName().
This commit is contained in:
parent
57fb47de3a
commit
ae31d05605
@ -258,7 +258,9 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
raise ValueError("nameID must be less than 32768")
|
raise ValueError("nameID must be less than 32768")
|
||||||
return nameID
|
return nameID
|
||||||
|
|
||||||
def findMultilingualName(self, names, windows=True, mac=True, minNameID=0):
|
def findMultilingualName(
|
||||||
|
self, names, windows=True, mac=True, minNameID=0, ttFont=None
|
||||||
|
):
|
||||||
"""Return the name ID of an existing multilingual name that
|
"""Return the name ID of an existing multilingual name that
|
||||||
matches the 'names' dictionary, or None if not found.
|
matches the 'names' dictionary, or None if not found.
|
||||||
|
|
||||||
@ -293,7 +295,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if mac:
|
if mac:
|
||||||
macName = _makeMacName(name, None, lang)
|
macName = _makeMacName(name, None, lang, ttFont)
|
||||||
if macName is not None:
|
if macName is not None:
|
||||||
reqNameSet.add(
|
reqNameSet.add(
|
||||||
(
|
(
|
||||||
@ -352,7 +354,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
if nameID is None:
|
if nameID is None:
|
||||||
# Reuse nameID if possible
|
# Reuse nameID if possible
|
||||||
nameID = self.findMultilingualName(
|
nameID = self.findMultilingualName(
|
||||||
names, windows=windows, mac=mac, minNameID=minNameID
|
names, windows=windows, mac=mac, minNameID=minNameID, ttFont=ttFont
|
||||||
)
|
)
|
||||||
if nameID is not None:
|
if nameID is not None:
|
||||||
return nameID
|
return nameID
|
||||||
|
@ -324,6 +324,15 @@ class NameTableTest(unittest.TestCase):
|
|||||||
nameTable.addMultilingualName({"en": "A", "la": "ⱾƤℚⱤ"})
|
nameTable.addMultilingualName({"en": "A", "la": "ⱾƤℚⱤ"})
|
||||||
captor.assertRegex("cannot store language la into 'ltag' table")
|
captor.assertRegex("cannot store language la into 'ltag' table")
|
||||||
|
|
||||||
|
def test_addMultilingualName_TTFont(self):
|
||||||
|
# if ttFont argument is passed, it should not WARN about not being able
|
||||||
|
# to create ltag table.
|
||||||
|
font = FakeFont(glyphs=[".notdef", "A"])
|
||||||
|
nameTable = newTable("name")
|
||||||
|
with CapturingLogHandler(log, "WARNING") as captor:
|
||||||
|
nameTable.addMultilingualName({"en": "A", "ar": "ع"}, ttFont=font)
|
||||||
|
self.assertFalse(captor.records)
|
||||||
|
|
||||||
def test_addMultilingualName_minNameID(self):
|
def test_addMultilingualName_minNameID(self):
|
||||||
table = table__n_a_m_e()
|
table = table__n_a_m_e()
|
||||||
names, namesSubSet, namesSuperSet = self._get_test_names()
|
names, namesSubSet, namesSuperSet = self._get_test_names()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user