[morx] Implement AATLookup.xmlRead
This commit is contained in:
parent
b40ba05f6f
commit
4b5b8ea53d
@ -620,6 +620,15 @@ class AATLookup(BaseConverter):
|
|||||||
data = reader.readUShortArray(count)
|
data = reader.readUShortArray(count)
|
||||||
return {(first + k):v for (k, v) in enumerate(data)}
|
return {(first + k):v for (k, v) in enumerate(data)}
|
||||||
|
|
||||||
|
def xmlRead(self, attrs, content, font):
|
||||||
|
value = {}
|
||||||
|
for element in content:
|
||||||
|
if isinstance(element, tuple):
|
||||||
|
name, a, eltContent = element
|
||||||
|
if name == "Substitution":
|
||||||
|
value[a["in"]] = a["out"]
|
||||||
|
return value
|
||||||
|
|
||||||
def xmlWrite(self, xmlWriter, font, value, name, attrs):
|
def xmlWrite(self, xmlWriter, font, value, name, attrs):
|
||||||
xmlWriter.begintag(name, attrs)
|
xmlWriter.begintag(name, attrs)
|
||||||
xmlWriter.newline()
|
xmlWriter.newline()
|
||||||
|
@ -175,7 +175,7 @@ class UInt8Test(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class AATLookupTest(unittest.TestCase):
|
class AATLookupTest(unittest.TestCase):
|
||||||
font = FakeFont(".notdef A B C D E F G H".split())
|
font = FakeFont(".notdef A B C D E F G H A.alt B.alt".split())
|
||||||
converter = otConverters.AATLookup("AATLookup", 0, None, None)
|
converter = otConverters.AATLookup("AATLookup", 0, None, None)
|
||||||
|
|
||||||
def __init__(self, methodName):
|
def __init__(self, methodName):
|
||||||
@ -250,15 +250,23 @@ class AATLookupTest(unittest.TestCase):
|
|||||||
"unsupported lookup format: 9",
|
"unsupported lookup format: 9",
|
||||||
self.converter.read, reader, self.font, None)
|
self.converter.read, reader, self.font, None)
|
||||||
|
|
||||||
|
def test_xmlRead(self):
|
||||||
|
value = self.converter.xmlRead({}, [
|
||||||
|
("Substitution", {"in": "A", "out": "A.alt"}, []),
|
||||||
|
("Substitution", {"in": "B", "out": "B.alt"}, []),
|
||||||
|
], self.font)
|
||||||
|
self.assertEqual(value, {"A": "A.alt", "B": "B.alt"})
|
||||||
|
|
||||||
def test_xmlWrite(self):
|
def test_xmlWrite(self):
|
||||||
writer = makeXMLWriter()
|
writer = makeXMLWriter()
|
||||||
self.converter.xmlWrite(writer, self.font, value={"A": "B", "C": "D"},
|
self.converter.xmlWrite(writer, self.font,
|
||||||
|
value={"A": "A.alt", "B": "B.alt"},
|
||||||
name="Foo", attrs=[("attr", "val")])
|
name="Foo", attrs=[("attr", "val")])
|
||||||
xml = writer.file.getvalue().decode("utf-8").splitlines()
|
xml = writer.file.getvalue().decode("utf-8").splitlines()
|
||||||
self.assertEqual(xml, [
|
self.assertEqual(xml, [
|
||||||
'<Foo attr="val">',
|
'<Foo attr="val">',
|
||||||
' <Substitution in="A" out="B"/>',
|
' <Substitution in="A" out="A.alt"/>',
|
||||||
' <Substitution in="C" out="D"/>',
|
' <Substitution in="B" out="B.alt"/>',
|
||||||
'</Foo>',
|
'</Foo>',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user