[AAT] Write AATLookups to XML in alphabetical order again

The XML output for other tables is also sorted alphabetically
by glyph name, not by glyph order.

This reverts commit c77e9fe12d5879aeb79c05f8ececebb3275524b7.
This commit is contained in:
Sascha Brawer 2017-09-01 15:56:21 +02:00
parent c77e9fe12d
commit 49fc88244b
8 changed files with 36 additions and 37 deletions

View File

@ -798,9 +798,9 @@ class AATLookup(BaseConverter):
def xmlWrite(self, xmlWriter, font, value, name, attrs):
xmlWriter.begintag(name, attrs)
xmlWriter.newline()
for glyph in sorted(value, key=font.getGlyphID):
for glyph, value in sorted(value.items()):
self.converter.xmlWrite(
xmlWriter, font, value=value[glyph],
xmlWriter, font, value=value,
name="Lookup", attrs=[("glyph", glyph)])
xmlWriter.endtag(name)
xmlWriter.newline()

View File

@ -140,7 +140,7 @@ class ANKRTest(unittest.TestCase):
def decompileToXML(self, data, xml):
table = newTable('ankr')
table.decompile(data, self.font)
self.assertEqual(getXML(table.toXML, self.font), xml)
self.assertEqual(getXML(table.toXML), xml)
def compileFromXML(self, xml, data):
table = newTable('ankr')

View File

@ -281,7 +281,7 @@ class BSLNTest(unittest.TestCase):
def decompileToXML(self, data, xml):
table = newTable('bsln')
table.decompile(data, self.font)
self.assertEqual(getXML(table.toXML, self.font), xml)
self.assertEqual(getXML(table.toXML), xml)
def compileFromXML(self, xml, data):
table = newTable('bsln')

View File

@ -25,15 +25,15 @@ LCAR_FORMAT_0_XML = [
'<Version value="0x00010000"/>',
'<LigatureCarets Format="0">',
' <Carets>',
' <Lookup glyph="f_r">',
' <!-- DivsionPointCount=1 -->',
' <DivisionPoint index="0" value="220"/>',
' </Lookup>',
' <Lookup glyph="f_f_l">',
' <!-- DivsionPointCount=2 -->',
' <DivisionPoint index="0" value="239"/>',
' <DivisionPoint index="1" value="472"/>',
' </Lookup>',
' <Lookup glyph="f_r">',
' <!-- DivsionPointCount=1 -->',
' <DivisionPoint index="0" value="220"/>',
' </Lookup>',
' </Carets>',
'</LigatureCarets>',
]
@ -58,15 +58,15 @@ LCAR_FORMAT_1_XML = [
'<Version value="0x00010000"/>',
'<LigatureCarets Format="1">',
' <Carets>',
' <Lookup glyph="f_r">',
' <!-- DivsionPointCount=1 -->',
' <DivisionPoint index="0" value="50"/>',
' </Lookup>',
' <Lookup glyph="f_f_l">',
' <!-- DivsionPointCount=2 -->',
' <DivisionPoint index="0" value="55"/>',
' <DivisionPoint index="1" value="75"/>',
' </Lookup>',
' <Lookup glyph="f_r">',
' <!-- DivsionPointCount=1 -->',
' <DivisionPoint index="0" value="50"/>',
' </Lookup>',
' </Carets>',
'</LigatureCarets>',
]
@ -82,7 +82,7 @@ class LCARTest(unittest.TestCase):
def test_decompile_toXML_format0(self):
table = newTable('lcar')
table.decompile(LCAR_FORMAT_0_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), LCAR_FORMAT_0_XML)
self.assertEqual(getXML(table.toXML), LCAR_FORMAT_0_XML)
def test_compile_fromXML_format0(self):
table = newTable('lcar')
@ -94,7 +94,7 @@ class LCARTest(unittest.TestCase):
def test_decompile_toXML_format1(self):
table = newTable('lcar')
table.decompile(LCAR_FORMAT_1_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), LCAR_FORMAT_1_XML)
self.assertEqual(getXML(table.toXML), LCAR_FORMAT_1_XML)
def test_compile_fromXML_format1(self):
table = newTable('lcar')

View File

@ -100,7 +100,7 @@ class MORTNoncontextualGlyphSubstitutionTest(unittest.TestCase):
def test_decompile_toXML(self):
table = newTable('mort')
table.decompile(MORT_NONCONTEXTUAL_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), MORT_NONCONTEXTUAL_XML)
self.assertEqual(getXML(table.toXML), MORT_NONCONTEXTUAL_XML)
def test_compile_fromXML(self):
table = newTable('mort')

View File

@ -98,7 +98,7 @@ class MORXNoncontextualGlyphSubstitutionTest(unittest.TestCase):
def test_decompile_toXML(self):
table = newTable('morx')
table.decompile(MORX_NONCONTEXTUAL_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), MORX_NONCONTEXTUAL_XML)
self.assertEqual(getXML(table.toXML), MORX_NONCONTEXTUAL_XML)
def test_compile_fromXML(self):
table = newTable('morx')

View File

@ -25,18 +25,18 @@ OPBD_FORMAT_0_XML = [
'<Version value="0x00010000"/>',
'<OpticalBounds Format="0">',
' <OpticalBoundsDeltas>',
' <Lookup glyph="C">', # GlyphID 10
' <Left value="-50"/>',
' <Top value="5"/>',
' <Right value="55"/>',
' <Bottom value="-5"/>',
' </Lookup>',
' <Lookup glyph="A">', # GlyphID 43
' <Lookup glyph="A">',
' <Left value="-10"/>',
' <Top value="15"/>',
' <Right value="0"/>',
' <Bottom value="0"/>',
' </Lookup>',
' <Lookup glyph="C">',
' <Left value="-50"/>',
' <Top value="5"/>',
' <Right value="55"/>',
' <Bottom value="-5"/>',
' </Lookup>',
' </OpticalBoundsDeltas>',
'</OpticalBounds>',
]
@ -61,18 +61,18 @@ OPBD_FORMAT_1_XML = [
'<Version value="0x00010000"/>',
'<OpticalBounds Format="1">',
' <OpticalBoundsPoints>',
' <Lookup glyph="C">', # GlyphID 10
' <Left value="36"/>',
' <Top value="37"/>',
' <Right value="38"/>',
' <Bottom value="39"/>',
' </Lookup>',
' <Lookup glyph="A">', # GlyphID 43
' <Lookup glyph="A">',
' <Left value="32"/>',
' <Top value="41"/>',
' <Right value="-1"/>',
' <Bottom value="-1"/>',
' </Lookup>',
' <Lookup glyph="C">',
' <Left value="36"/>',
' <Top value="37"/>',
' <Right value="38"/>',
' <Bottom value="39"/>',
' </Lookup>',
' </OpticalBoundsPoints>',
'</OpticalBounds>',
]
@ -149,7 +149,7 @@ class OPBDTest(unittest.TestCase):
def test_decompile_toXML_format0(self):
table = newTable('opbd')
table.decompile(OPBD_FORMAT_0_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), OPBD_FORMAT_0_XML)
self.assertEqual(getXML(table.toXML), OPBD_FORMAT_0_XML)
def test_compile_fromXML_format0(self):
table = newTable('opbd')
@ -161,7 +161,7 @@ class OPBDTest(unittest.TestCase):
def test_decompile_toXML_format1(self):
table = newTable('opbd')
table.decompile(OPBD_FORMAT_1_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), OPBD_FORMAT_1_XML)
self.assertEqual(getXML(table.toXML), OPBD_FORMAT_1_XML)
def test_compile_fromXML_format1(self):
table = newTable('opbd')
@ -174,9 +174,8 @@ class OPBDTest(unittest.TestCase):
# Make sure we do not crash when decompiling the 'opbd' table of
# AppleChancery.ttf. https://github.com/fonttools/fonttools/issues/1031
table = newTable('opbd')
font = FakeFont([".notdef"] + ['G.alt%d' % i for i in range(1, 600)])
table.decompile(OPBD_APPLE_CHANCERY_DATA, font)
self.assertIn('<OpticalBounds Format="0">', getXML(table.toXML, font))
table.decompile(OPBD_APPLE_CHANCERY_DATA, self.font)
self.assertIn('<OpticalBounds Format="0">', getXML(table.toXML))
if __name__ == '__main__':

View File

@ -57,7 +57,7 @@ class PROPTest(unittest.TestCase):
def test_decompile_toXML_format0(self):
table = newTable('prop')
table.decompile(PROP_FORMAT_0_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), PROP_FORMAT_0_XML)
self.assertEqual(getXML(table.toXML), PROP_FORMAT_0_XML)
def test_compile_fromXML_format0(self):
table = newTable('prop')
@ -69,7 +69,7 @@ class PROPTest(unittest.TestCase):
def test_decompile_toXML_format1(self):
table = newTable('prop')
table.decompile(PROP_FORMAT_1_DATA, self.font)
self.assertEqual(getXML(table.toXML, self.font), PROP_FORMAT_1_XML)
self.assertEqual(getXML(table.toXML), PROP_FORMAT_1_XML)
def test_compile_fromXML_format1(self):
table = newTable('prop')