[ttLib] Add Value.getEffectiveFormat()

This ignores 0/None values that don't need to be encoded.
This commit is contained in:
Behdad Esfahbod 2021-04-21 14:10:27 -06:00
parent 8ab6af03c8
commit 830cff6253

View File

@ -970,6 +970,13 @@ class ValueRecord(object):
format = format | valueRecordFormatDict[name][0]
return format
def getEffectiveFormat(self):
format = 0
for name,value in self.__dict__.items():
if value:
format = format | valueRecordFormatDict[name][0]
return format
def toXML(self, xmlWriter, font, valueName, attrs=None):
if attrs is None:
simpleItems = []