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:
parent
2f2fd9ca7c
commit
cb4adf6828
@ -155,12 +155,21 @@ class Struct(BaseConverter):
|
|||||||
|
|
||||||
def xmlWrite(self, xmlWriter, font, value, name, attrs):
|
def xmlWrite(self, xmlWriter, font, value, name, attrs):
|
||||||
if value is None:
|
if value is None:
|
||||||
|
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
|
pass # NULL table, ignore
|
||||||
else:
|
else:
|
||||||
value.toXML(xmlWriter, font, attrs)
|
value.toXML(xmlWriter, font, attrs)
|
||||||
|
|
||||||
def xmlRead(self, attrs, content, font):
|
def xmlRead(self, attrs, content, font):
|
||||||
table = self.tableClass()
|
table = self.tableClass()
|
||||||
|
if attrs.get("empty"):
|
||||||
|
return None
|
||||||
Format = attrs.get("Format")
|
Format = attrs.get("Format")
|
||||||
if Format is not None:
|
if Format is not None:
|
||||||
table.Format = int(Format)
|
table.Format = int(Format)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user