[_g_l_y_f] factor out code for writing instructions in toXML

This commit is contained in:
Cosimo Lupo 2017-01-24 17:33:53 +00:00
parent 0aa086a94b
commit 0918f7cf3e
No known key found for this signature in database
GPG Key ID: B61AAAD0B53A6419

View File

@ -354,12 +354,7 @@ class Glyph(object):
if self.isComposite():
for compo in self.components:
compo.toXML(writer, ttFont)
if hasattr(self, "program"):
writer.begintag("instructions")
writer.newline()
self.program.toXML(writer, ttFont)
writer.endtag("instructions")
writer.newline()
haveInstructions = hasattr(self, "program")
else:
last = 0
for i in range(self.numberOfContours):
@ -374,12 +369,13 @@ class Glyph(object):
last = self.endPtsOfContours[i] + 1
writer.endtag("contour")
writer.newline()
if self.numberOfContours:
writer.begintag("instructions")
writer.newline()
self.program.toXML(writer, ttFont)
writer.endtag("instructions")
writer.newline()
haveInstructions = self.numberOfContours > 0
if haveInstructions:
writer.begintag("instructions")
writer.newline()
self.program.toXML(writer, ttFont)
writer.endtag("instructions")
writer.newline()
def fromXML(self, name, attrs, content, ttFont):
if name == "contour":