def glifToPy(self, glif): glif = stripText(glif) glif = "<?xml version=\"1.0\"?>\n" + glif glyph = Glyph() readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph, validate=True) return glyph.py()
def pyToGLIF(self, py): py = stripText(py) glyph = Glyph() exec py in {"glyph" : glyph, "pointPen" : glyph} glif = writeGlyphToString(glyph.name, glyphObject=glyph, drawPointsFunc=glyph.drawPoints, formatVersion=1) glif = "\n".join(glif.splitlines()[1:]) return glif
def pyToGLIF(self, py): py = stripText(py) glyph = Glyph() exec(py, {"glyph": glyph, "pointPen": glyph}) glif = writeGlyphToString(glyph.name, glyphObject=glyph, drawPointsFunc=glyph.drawPoints, formatVersion=1, validate=True) # discard the first line containing the xml declaration return "\n".join(islice(glif.splitlines(), 1, None))
def glifToPy(self, glif): glif = stripText(glif) glif = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + glif glyph = Glyph() readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph) return glyph.py()