diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 88b720892..16a103060 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -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":