From 830cff62532ad9e7d85aaaeba7352d514ac6d038 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 21 Apr 2021 14:10:27 -0600 Subject: [PATCH] [ttLib] Add Value.getEffectiveFormat() This ignores 0/None values that don't need to be encoded. --- Lib/fontTools/ttLib/tables/otBase.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index 3c07f9e11..dd8b724d7 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -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 = []