aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/ttLib/tables/T_S_I__5.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/fontTools/ttLib/tables/T_S_I__5.py')
-rw-r--r--Lib/fontTools/ttLib/tables/T_S_I__5.py59
1 files changed, 31 insertions, 28 deletions
diff --git a/Lib/fontTools/ttLib/tables/T_S_I__5.py b/Lib/fontTools/ttLib/tables/T_S_I__5.py
index 7be09f9a..5edc86a9 100644
--- a/Lib/fontTools/ttLib/tables/T_S_I__5.py
+++ b/Lib/fontTools/ttLib/tables/T_S_I__5.py
@@ -10,34 +10,37 @@ import array
class table_T_S_I__5(DefaultTable.DefaultTable):
+ def decompile(self, data, ttFont):
+ numGlyphs = ttFont["maxp"].numGlyphs
+ assert len(data) == 2 * numGlyphs
+ a = array.array("H")
+ a.frombytes(data)
+ if sys.byteorder != "big":
+ a.byteswap()
+ self.glyphGrouping = {}
+ for i in range(numGlyphs):
+ self.glyphGrouping[ttFont.getGlyphName(i)] = a[i]
- def decompile(self, data, ttFont):
- numGlyphs = ttFont['maxp'].numGlyphs
- assert len(data) == 2 * numGlyphs
- a = array.array("H")
- a.frombytes(data)
- if sys.byteorder != "big": a.byteswap()
- self.glyphGrouping = {}
- for i in range(numGlyphs):
- self.glyphGrouping[ttFont.getGlyphName(i)] = a[i]
+ def compile(self, ttFont):
+ glyphNames = ttFont.getGlyphOrder()
+ a = array.array("H")
+ for i in range(len(glyphNames)):
+ a.append(self.glyphGrouping.get(glyphNames[i], 0))
+ if sys.byteorder != "big":
+ a.byteswap()
+ return a.tobytes()
- def compile(self, ttFont):
- glyphNames = ttFont.getGlyphOrder()
- a = array.array("H")
- for i in range(len(glyphNames)):
- a.append(self.glyphGrouping.get(glyphNames[i], 0))
- if sys.byteorder != "big": a.byteswap()
- return a.tobytes()
+ def toXML(self, writer, ttFont):
+ names = sorted(self.glyphGrouping.keys())
+ for glyphName in names:
+ writer.simpletag(
+ "glyphgroup", name=glyphName, value=self.glyphGrouping[glyphName]
+ )
+ writer.newline()
- def toXML(self, writer, ttFont):
- names = sorted(self.glyphGrouping.keys())
- for glyphName in names:
- writer.simpletag("glyphgroup", name=glyphName, value=self.glyphGrouping[glyphName])
- writer.newline()
-
- def fromXML(self, name, attrs, content, ttFont):
- if not hasattr(self, "glyphGrouping"):
- self.glyphGrouping = {}
- if name != "glyphgroup":
- return
- self.glyphGrouping[attrs["name"]] = safeEval(attrs["value"])
+ def fromXML(self, name, attrs, content, ttFont):
+ if not hasattr(self, "glyphGrouping"):
+ self.glyphGrouping = {}
+ if name != "glyphgroup":
+ return
+ self.glyphGrouping[attrs["name"]] = safeEval(attrs["value"])