Fix XML->ttf for fonts that have some missing anchors, etc

Eg. EBGaramond12-Regular.ttf.  It has a base anchor missing.
Dropping the empty table from XML changes the size of the base
anchor array, which will then result in an assertion because
all bases should have the same array length.

Fixes many other broken fonts too.
This commit is contained in:
Behdad Esfahbod 2013-11-26 18:55:23 -05:00
parent 2f2fd9ca7c
commit cb4adf6828

View File

@ -155,12 +155,21 @@ class Struct(BaseConverter):
def xmlWrite(self, xmlWriter, font, value, name, attrs):
if value is None:
pass # NULL table, ignore
if attrs:
# If there are attributes (probably index), then
# don't drop this even if it's NULL. It will mess
# up the array indices of the containing element.
xmlWriter.simpletag(name, attrs + [("empty", True)])
xmlWriter.newline()
else:
pass # NULL table, ignore
else:
value.toXML(xmlWriter, font, attrs)
def xmlRead(self, attrs, content, font):
table = self.tableClass()
if attrs.get("empty"):
return None
Format = attrs.get("Format")
if Format is not None:
table.Format = int(Format)