diff options
Diffstat (limited to 'Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py')
-rw-r--r-- | Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py index 9197923d..10b4f828 100644 --- a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py +++ b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py @@ -28,32 +28,37 @@ smallGlyphMetricsFormat = """ Advance: B """ + class BitmapGlyphMetrics(object): + def toXML(self, writer, ttFont): + writer.begintag(self.__class__.__name__) + writer.newline() + for metricName in sstruct.getformat(self.__class__.binaryFormat)[1]: + writer.simpletag(metricName, value=getattr(self, metricName)) + writer.newline() + writer.endtag(self.__class__.__name__) + writer.newline() - def toXML(self, writer, ttFont): - writer.begintag(self.__class__.__name__) - writer.newline() - for metricName in sstruct.getformat(self.__class__.binaryFormat)[1]: - writer.simpletag(metricName, value=getattr(self, metricName)) - writer.newline() - writer.endtag(self.__class__.__name__) - writer.newline() - - def fromXML(self, name, attrs, content, ttFont): - metricNames = set(sstruct.getformat(self.__class__.binaryFormat)[1]) - for element in content: - if not isinstance(element, tuple): - continue - name, attrs, content = element - # Make sure this is a metric that is needed by GlyphMetrics. - if name in metricNames: - vars(self)[name] = safeEval(attrs['value']) - else: - log.warning("unknown name '%s' being ignored in %s.", name, self.__class__.__name__) + def fromXML(self, name, attrs, content, ttFont): + metricNames = set(sstruct.getformat(self.__class__.binaryFormat)[1]) + for element in content: + if not isinstance(element, tuple): + continue + name, attrs, content = element + # Make sure this is a metric that is needed by GlyphMetrics. + if name in metricNames: + vars(self)[name] = safeEval(attrs["value"]) + else: + log.warning( + "unknown name '%s' being ignored in %s.", + name, + self.__class__.__name__, + ) class BigGlyphMetrics(BitmapGlyphMetrics): - binaryFormat = bigGlyphMetricsFormat + binaryFormat = bigGlyphMetricsFormat + class SmallGlyphMetrics(BitmapGlyphMetrics): - binaryFormat = smallGlyphMetricsFormat + binaryFormat = smallGlyphMetricsFormat |