MCPcopy Create free account
hub / github.com/coldtype/st2 / compile

Method compile

ST2/meshtable.py:188–217  ·  view source on GitHub ↗
(self, ttFont)

Source from the content-addressed store, hash-verified

186 del self.data
187
188 def compile(self, ttFont):
189 self.glyphDataOffsets = b""
190 self.bitmapData = b""
191
192 glyphOrder = ttFont.getGlyphOrder()
193
194 # first glyph starts right after the header
195 currentGlyphDataOffset = meshStrikeHeaderFormatSize + meshGlyphDataOffsetFormatSize * (len(glyphOrder) + 1)
196 for glyphName in glyphOrder:
197 if glyphName in self.glyphs:
198 # we have glyph data for this glyph
199 current_glyph = self.glyphs[glyphName]
200 else:
201 # must add empty glyph data record for this glyph
202 current_glyph = Glyph(glyphName=glyphName)
203 current_glyph.compile(ttFont)
204 current_glyph.glyphDataOffset = currentGlyphDataOffset
205 self.bitmapData += current_glyph.rawdata
206 currentGlyphDataOffset += len(current_glyph.rawdata)
207 self.glyphDataOffsets += sstruct.pack(meshGlyphDataOffsetFormat, current_glyph)
208
209 # add last "offset", really the end address of the last glyph data record
210 dummy = Glyph()
211 dummy.glyphDataOffset = currentGlyphDataOffset
212 self.glyphDataOffsets += sstruct.pack(meshGlyphDataOffsetFormat, dummy)
213
214 # pack header
215 self.data = sstruct.pack(meshStrikeHeaderFormat, self)
216 # add offsets and image data after header
217 self.data += self.glyphDataOffsets + self.bitmapData
218
219 def toXML(self, xmlWriter, ttFont):
220 xmlWriter.begintag("strike")

Callers

nothing calls this directly

Calls 2

compileMethod · 0.95
GlyphClass · 0.85

Tested by

no test coverage detected