Merge pull request #1527 from anthrotype/tuplevar-ttx-ordered-attrs

TupleVariation.toXML: sort attrs min/value/max in TTX dump
This commit is contained in:
Cosimo Lupo 2019-03-04 17:02:08 -08:00 committed by GitHub
commit a15f94f0c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -71,7 +71,13 @@ class TupleVariation(object):
if minValue == defaultMinValue and maxValue == defaultMaxValue: if minValue == defaultMinValue and maxValue == defaultMaxValue:
writer.simpletag("coord", axis=axis, value=value) writer.simpletag("coord", axis=axis, value=value)
else: else:
writer.simpletag("coord", axis=axis, value=value, min=minValue, max=maxValue) attrs = [
("axis", axis),
("min", minValue),
("value", value),
("max", maxValue),
]
writer.simpletag("coord", attrs)
writer.newline() writer.newline()
wrote_any_deltas = False wrote_any_deltas = False
for i, delta in enumerate(self.coordinates): for i, delta in enumerate(self.coordinates):

View File

@ -107,7 +107,7 @@ class TupleVariationTest(unittest.TestCase):
self.assertIn("bad delta format", [r.msg for r in captor.records]) self.assertIn("bad delta format", [r.msg for r in captor.records])
self.assertEqual([ self.assertEqual([
'<tuple>', '<tuple>',
'<coord axis="wdth" max="0.5" min="0.3" value="0.4"/>', '<coord axis="wdth" min="0.3" value="0.4" max="0.5"/>',
'<!-- bad delta #0 -->', '<!-- bad delta #0 -->',
'</tuple>', '</tuple>',
], TupleVariationTest.xml_lines(writer)) ], TupleVariationTest.xml_lines(writer))
@ -118,7 +118,7 @@ class TupleVariationTest(unittest.TestCase):
g.toXML(writer, ["wdth", "wght", "opsz"]) g.toXML(writer, ["wdth", "wght", "opsz"])
self.assertEqual([ self.assertEqual([
'<tuple>', '<tuple>',
'<coord axis="wdth" max="0.5" min="0.3" value="0.4"/>', '<coord axis="wdth" min="0.3" value="0.4" max="0.5"/>',
'<coord axis="wght" value="1.0"/>', '<coord axis="wght" value="1.0"/>',
'<coord axis="opsz" value="-0.7"/>', '<coord axis="opsz" value="-0.7"/>',
'<delta cvt="0" value="42"/>', '<delta cvt="0" value="42"/>',
@ -134,7 +134,7 @@ class TupleVariationTest(unittest.TestCase):
g.toXML(writer, ["wdth", "wght", "opsz"]) g.toXML(writer, ["wdth", "wght", "opsz"])
self.assertEqual([ self.assertEqual([
'<tuple>', '<tuple>',
'<coord axis="wdth" max="0.5" min="0.3" value="0.4"/>', '<coord axis="wdth" min="0.3" value="0.4" max="0.5"/>',
'<coord axis="wght" value="1.0"/>', '<coord axis="wght" value="1.0"/>',
'<coord axis="opsz" value="-0.7"/>', '<coord axis="opsz" value="-0.7"/>',
'<delta pt="0" x="9" y="8"/>', '<delta pt="0" x="9" y="8"/>',

View File

@ -93,7 +93,7 @@ GVAR_XML = [
'</glyphVariations>', '</glyphVariations>',
'<glyphVariations glyph="I">', '<glyphVariations glyph="I">',
' <tuple>', ' <tuple>',
' <coord axis="wght" max="1.0" min="0.0" value="0.5"/>', ' <coord axis="wght" min="0.0" value="0.5" max="1.0"/>',
' <delta pt="0" x="3" y="3"/>', ' <delta pt="0" x="3" y="3"/>',
' <delta pt="1" x="1" y="1"/>', ' <delta pt="1" x="1" y="1"/>',
' <delta pt="2" x="4" y="4"/>', ' <delta pt="2" x="4" y="4"/>',

View File

@ -574,7 +574,7 @@
</glyphVariations> </glyphVariations>
<glyphVariations glyph="e"> <glyphVariations glyph="e">
<tuple> <tuple>
<coord axis="wght" max="1.0" min="0.0" value="0.36365"/> <coord axis="wght" min="0.0" value="0.36365" max="1.0"/>
<delta pt="0" x="-1" y="-25"/> <delta pt="0" x="-1" y="-25"/>
<delta pt="1" x="0" y="0"/> <delta pt="1" x="0" y="0"/>
<delta pt="2" x="-84" y="5"/> <delta pt="2" x="-84" y="5"/>
@ -594,7 +594,7 @@
<delta pt="16" x="0" y="0"/> <delta pt="16" x="0" y="0"/>
</tuple> </tuple>
<tuple> <tuple>
<coord axis="wght" max="1.0" min="0.36365" value="1.0"/> <coord axis="wght" min="0.36365" value="1.0" max="1.0"/>
<delta pt="0" x="70" y="1"/> <delta pt="0" x="70" y="1"/>
<delta pt="1" x="70" y="1"/> <delta pt="1" x="70" y="1"/>
<delta pt="2" x="-76" y="1"/> <delta pt="2" x="-76" y="1"/>