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

Method fromXML

ST2/meshtable.py:234–271  ·  view source on GitHub ↗
(self, name, attrs, content, ttFont)

Source from the content-addressed store, hash-verified

232 xmlWriter.newline()
233
234 def fromXML(self, name, attrs, content, ttFont):
235 if name in ["ppem", "resolution"]:
236 setattr(self, name, safeEval(attrs["value"]))
237 elif name == "glyph":
238 if "graphicType" in attrs:
239 myFormat = safeEval("'''" + attrs["graphicType"] + "'''")
240 else:
241 myFormat = None
242 if "glyphname" in attrs:
243 myGlyphName = safeEval("'''" + attrs["glyphname"] + "'''")
244 elif "name" in attrs:
245 myGlyphName = safeEval("'''" + attrs["name"] + "'''")
246 else:
247 from fontTools import ttLib
248 raise ttLib.TTLibError("Glyph must have a glyph name.")
249 if "originOffsetX" in attrs:
250 myOffsetX = safeEval(attrs["originOffsetX"])
251 else:
252 myOffsetX = 0
253 if "originOffsetY" in attrs:
254 myOffsetY = safeEval(attrs["originOffsetY"])
255 else:
256 myOffsetY = 0
257 current_glyph = Glyph(
258 glyphName=myGlyphName,
259 graphicType=myFormat,
260 originOffsetX=myOffsetX,
261 originOffsetY=myOffsetY,
262 )
263 for element in content:
264 if isinstance(element, tuple):
265 name, attrs, content = element
266 current_glyph.fromXML(name, attrs, content, ttFont)
267 current_glyph.compile(ttFont)
268 self.glyphs[current_glyph.glyphName] = current_glyph
269 else:
270 from fontTools import ttLib
271 raise ttLib.TTLibError("can't handle '%s' element" % name)
272
273
274

Callers 1

fromXMLMethod · 0.95

Calls 3

fromXMLMethod · 0.95
compileMethod · 0.95
GlyphClass · 0.85

Tested by

no test coverage detected