diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index f1d48f9b3..f71fd3e2d 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -746,7 +746,7 @@ class Glyph(object): for compo in self.components: compo.toXML(writer, ttFont) haveInstructions = hasattr(self, "program") - if self.isVarComposite(): + elif self.isVarComposite(): for compo in self.components: compo.toXML(writer, ttFont) haveInstructions = False diff --git a/Tests/ttLib/tables/_g_l_y_f_test.py b/Tests/ttLib/tables/_g_l_y_f_test.py index ddcdb5959..71627b82b 100644 --- a/Tests/ttLib/tables/_g_l_y_f_test.py +++ b/Tests/ttLib/tables/_g_l_y_f_test.py @@ -186,6 +186,7 @@ GLYF_BIN = os.path.join(DATA_DIR, "_g_l_y_f_outline_flag_bit6.glyf.bin") HEAD_BIN = os.path.join(DATA_DIR, "_g_l_y_f_outline_flag_bit6.head.bin") LOCA_BIN = os.path.join(DATA_DIR, "_g_l_y_f_outline_flag_bit6.loca.bin") MAXP_BIN = os.path.join(DATA_DIR, "_g_l_y_f_outline_flag_bit6.maxp.bin") +INST_TTX = os.path.join(DATA_DIR, "_g_l_y_f_instructions.ttx") def strip_ttLibVersion(string): @@ -235,6 +236,18 @@ class GlyfTableTest(unittest.TestCase): glyfData = glyfTable.compile(font) self.assertEqual(glyfData, self.glyfData) + def test_instructions_roundtrip(self): + font = TTFont(sfntVersion="\x00\x01\x00\x00") + font.importXML(INST_TTX) + glyfTable = font["glyf"] + self.glyfData = glyfTable.compile(font) + out = StringIO() + font.saveXML(out) + glyfXML = strip_ttLibVersion(out.getvalue()).splitlines() + with open(INST_TTX, "r") as f: + origXML = strip_ttLibVersion(f.read()).splitlines() + self.assertEqual(glyfXML, origXML) + def test_recursiveComponent(self): glyphSet = {} pen_dummy = TTGlyphPen(glyphSet) diff --git a/Tests/ttLib/tables/data/_g_l_y_f_instructions.ttx b/Tests/ttLib/tables/data/_g_l_y_f_instructions.ttx new file mode 100644 index 000000000..d090a25f6 --- /dev/null +++ b/Tests/ttLib/tables/data/_g_l_y_f_instructions.ttx @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SVTCA[0] /* SetFPVectorToAxis */ + PUSHW[ ] /* 1 value pushed */ + 3 + MDAP[1] /* MoveDirectAbsPt */ + IUP[0] /* InterpolateUntPts */ + IUP[1] /* InterpolateUntPts */ + + + + + + + + + SVTCA[0] /* SetFPVectorToAxis */ + PUSHW[ ] /* 1 value pushed */ + 1 + MDAP[1] /* MoveDirectAbsPt */ + IUP[0] /* InterpolateUntPts */ + IUP[1] /* InterpolateUntPts */ + + + + + + + + + + +