Esempio n. 1
0
    def decompile(self):
        self.metrics = BigGlyphMetrics()
        dummy, data = sstruct.unpack2(bigGlyphMetricsFormat, self.data,
                                      self.metrics)
        (dataLen, ) = struct.unpack(">L", data[:4])
        data = data[4:]

        # For the image data cut it to the size specified by dataLen.
        assert dataLen <= len(data), "Data overun in format 18"
        self.imageData = data[:dataLen]
Esempio n. 2
0
 def decompile(self):
     (self.imageSize, ) = struct.unpack(">L", self.data[:4])
     self.metrics = BigGlyphMetrics()
     sstruct.unpack2(bigGlyphMetricsFormat, self.data[4:], self.metrics)
     glyphIds = range(self.firstGlyphIndex, self.lastGlyphIndex + 1)
     offsets = [
         self.imageSize * i + self.imageDataOffset
         for i in xrange(len(glyphIds) + 1)
     ]
     self.locations = zip(offsets, offsets[1:])
     self.names = map(self.ttFont.getGlyphName, glyphIds)
Esempio n. 3
0
 def decompile(self):
     self.metrics = BigGlyphMetrics()
     dummy, data = sstruct.unpack2(bigGlyphMetricsFormat, self.data,
                                   self.metrics)
     (numComponents, ) = struct.unpack(">H", data[:2])
     data = data[2:]
     self.componentArray = []
     for i in xrange(numComponents):
         curComponent = EbdtComponent()
         dummy, data = sstruct.unpack2(ebdtComponentFormat, data,
                                       curComponent)
         curComponent.name = self.ttFont.getGlyphName(
             curComponent.glyphCode)
         self.componentArray.append(curComponent)
Esempio n. 4
0
class FixedSizeIndexSubTableMixin:
    def writeMetrics(self, writer, ttFont):
        writer.simpletag('imageSize', value=self.imageSize)
        writer.newline()
        self.metrics.toXML(writer, ttFont)

    def readMetrics(self, (name, attrs, content), ttFont):
        for element in content:
            if type(element) != TupleType:
                continue
            name, attrs, content = element
            if name == 'imageSize':
                self.imageSize = safeEval(attrs['value'])
            elif name == BigGlyphMetrics.__name__:
                self.metrics = BigGlyphMetrics()
                self.metrics.fromXML(element, ttFont)
            elif name == SmallGlyphMetrics.__name__:
                print "Warning: SmallGlyphMetrics being ignored in format %d." % self.indexFormat
Esempio n. 5
0
    def decompile(self):
        self.origDataLen = 0
        (self.imageSize, ) = struct.unpack(">L", self.data[:4])
        data = self.data[4:]
        self.metrics, data = sstruct.unpack2(bigGlyphMetricsFormat, data,
                                             BigGlyphMetrics())
        (numGlyphs, ) = struct.unpack(">L", data[:4])
        data = data[4:]
        glyphIds = [
            struct.unpack(">H", data[2 * i:2 * (i + 1)])[0]
            for i in xrange(numGlyphs)
        ]

        offsets = [
            self.imageSize * i + self.imageDataOffset
            for i in xrange(len(glyphIds) + 1)
        ]
        self.locations = zip(offsets, offsets[1:])
        self.names = map(self.ttFont.getGlyphName, glyphIds)
Esempio n. 6
0
 def decompile(self):
     self.metrics = BigGlyphMetrics()
     dummy, data = sstruct.unpack2(bigGlyphMetricsFormat, self.data,
                                   self.metrics)
     self.imageData = data