Esempio n. 1
0
 def decompile(self, data, ttFont):
     axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
     glyphs = ttFont.getGlyphOrder()
     sstruct.unpack(GVAR_HEADER_FORMAT, data[0:GVAR_HEADER_SIZE], self)
     assert len(glyphs) == self.glyphCount
     assert len(axisTags) == self.axisCount
     offsets = self.decompileOffsets_(data[GVAR_HEADER_SIZE:],
                                      tableFormat=(self.flags & 1),
                                      glyphCount=self.glyphCount)
     sharedCoords = tv.decompileSharedTuples(axisTags,
                                             self.sharedTupleCount, data,
                                             self.offsetToSharedTuples)
     self.variations = {}
     offsetToData = self.offsetToGlyphVariationData
     for i in range(self.glyphCount):
         glyphName = glyphs[i]
         glyph = ttFont["glyf"][glyphName]
         numPointsInGlyph = self.getNumPoints_(glyph)
         gvarData = data[offsetToData + offsets[i]:offsetToData +
                         offsets[i + 1]]
         try:
             self.variations[glyphName] = decompileGlyph_(
                 numPointsInGlyph, sharedCoords, axisTags, gvarData)
         except Exception:
             log.error(
                 "Failed to decompile deltas for glyph '%s' (%d points)",
                 glyphName,
                 numPointsInGlyph,
             )
             raise
Esempio n. 2
0
	def decompile(self, data, ttFont):
		axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
		glyphs = ttFont.getGlyphOrder()
		sstruct.unpack(GVAR_HEADER_FORMAT, data[0:GVAR_HEADER_SIZE], self)
		assert len(glyphs) == self.glyphCount
		assert len(axisTags) == self.axisCount
		offsets = self.decompileOffsets_(data[GVAR_HEADER_SIZE:], tableFormat=(self.flags & 1), glyphCount=self.glyphCount)
		sharedCoords = tv.decompileSharedTuples(
			axisTags, self.sharedTupleCount, data, self.offsetToSharedTuples)
		self.variations = {}
		offsetToData = self.offsetToGlyphVariationData
		for i in range(self.glyphCount):
			glyphName = glyphs[i]
			glyph = ttFont["glyf"][glyphName]
			numPointsInGlyph = self.getNumPoints_(glyph)
			gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]]
			try:
				self.variations[glyphName] = decompileGlyph_(
					numPointsInGlyph, sharedCoords, axisTags, gvarData)
			except Exception:
				log.error(
					"Failed to decompile deltas for glyph '%s' (%d points)",
					glyphName, numPointsInGlyph,
				)
				raise
Esempio n. 3
0
 def decompile(self, data, ttFont):
     axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
     glyphs = ttFont.getGlyphOrder()
     sstruct.unpack(GVAR_HEADER_FORMAT, data[0:GVAR_HEADER_SIZE], self)
     assert len(glyphs) == self.glyphCount
     assert len(axisTags) == self.axisCount
     offsets = self.decompileOffsets_(data[GVAR_HEADER_SIZE:],
                                      tableFormat=(self.flags & 1),
                                      glyphCount=self.glyphCount)
     sharedCoords = tv.decompileSharedTuples(axisTags,
                                             self.sharedTupleCount, data,
                                             self.offsetToSharedTuples)
     self.variations = _lazy_dict()
     offsetToData = self.offsetToGlyphVariationData
     glyf = ttFont['glyf']
     for i in range(self.glyphCount):
         glyphName = glyphs[i]
         glyph = glyf[glyphName]
         numPointsInGlyph = self.getNumPoints_(glyph)
         gvarData = data[offsetToData + offsets[i]:offsetToData +
                         offsets[i + 1]]
         self.variations[glyphName] = partial(decompileGlyph_,
                                              numPointsInGlyph,
                                              sharedCoords, axisTags,
                                              gvarData)