| 50 | self.graphicType += " "[:(4 - len(self.graphicType))] |
| 51 | |
| 52 | def decompile(self, ttFont): |
| 53 | #print("DECOMPILING", self.rawdata) |
| 54 | self.glyphName = ttFont.getGlyphName(self.gid) |
| 55 | if self.rawdata is None: |
| 56 | from fontTools import ttLib |
| 57 | raise ttLib.TTLibError("No table data to decompile") |
| 58 | if len(self.rawdata) > 0: |
| 59 | if len(self.rawdata) < meshGlyphHeaderFormatSize: |
| 60 | from fontTools import ttLib |
| 61 | #print "Glyph %i header too short: Expected %x, got %x." % (self.gid, meshGlyphHeaderFormatSize, len(self.rawdata)) |
| 62 | raise ttLib.TTLibError("Glyph header too short.") |
| 63 | |
| 64 | sstruct.unpack(meshGlyphHeaderFormat, self.rawdata[:meshGlyphHeaderFormatSize], self) |
| 65 | |
| 66 | if self.graphicType == "dupe": |
| 67 | # this glyph is a reference to another glyph's image data |
| 68 | gid, = struct.unpack(">H", self.rawdata[meshGlyphHeaderFormatSize:]) |
| 69 | self.referenceGlyphName = ttFont.getGlyphName(gid) |
| 70 | else: |
| 71 | self.meshData = self.rawdata[meshGlyphHeaderFormatSize:] |
| 72 | self.referenceGlyphName = None |
| 73 | # clean up |
| 74 | del self.rawdata |
| 75 | del self.gid |
| 76 | |
| 77 | def compile(self, ttFont): |
| 78 | if self.glyphName is None: |