From e8527bcb485f80879ce377235934827efe8c0bcb Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jan 2017 16:39:02 +0000 Subject: [PATCH 1/5] [data/TestCLR-Regular.ttx] revert unnecessary changes from 337dd1d --- Tests/subset/data/TestCLR-Regular.ttx | 48 +++++++++------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/Tests/subset/data/TestCLR-Regular.ttx b/Tests/subset/data/TestCLR-Regular.ttx index a05057869..302298bff 100644 --- a/Tests/subset/data/TestCLR-Regular.ttx +++ b/Tests/subset/data/TestCLR-Regular.ttx @@ -442,8 +442,7 @@ - - + PUSH[ ] /* 2 values pushed */ 1 0 MDAP[1] /* MoveDirectAbsPt */ @@ -477,8 +476,7 @@ 1 2 0 MIRP[01101] /* MoveIndirectRelPt */ SHP[0] /* ShiftPointByLastPoint */ - - + @@ -490,10 +488,8 @@ - - - - + + @@ -503,10 +499,8 @@ - - - - + + @@ -516,10 +510,8 @@ - - - - + + @@ -585,10 +577,8 @@ - - - - + + @@ -632,10 +622,8 @@ - - - - + + @@ -659,10 +647,8 @@ - - - - + + @@ -676,10 +662,8 @@ - - - - + + From 0aa086a94bac1be709132eeaee993c9d9ecd01d2 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jan 2017 17:27:01 +0000 Subject: [PATCH 2/5] [_f_p_g_m] remove writer.newline() as it's now implied by self.program.toXML() this also applies to table_p_r_e_p --- Lib/fontTools/ttLib/tables/_f_p_g_m.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/fontTools/ttLib/tables/_f_p_g_m.py b/Lib/fontTools/ttLib/tables/_f_p_g_m.py index 6fc8efcec..6536dba99 100644 --- a/Lib/fontTools/ttLib/tables/_f_p_g_m.py +++ b/Lib/fontTools/ttLib/tables/_f_p_g_m.py @@ -15,7 +15,6 @@ class table__f_p_g_m(DefaultTable.DefaultTable): def toXML(self, writer, ttFont): self.program.toXML(writer, ttFont) - writer.newline() def fromXML(self, name, attrs, content, ttFont): program = ttProgram.Program() From 0918f7cf3eb23c14e7d697f1b574e3cf091f7879 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jan 2017 17:33:53 +0000 Subject: [PATCH 3/5] [_g_l_y_f] factor out code for writing instructions in toXML --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) 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": From 3c46a4280f37a1258ec16351c46418a8c102c2d2 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jan 2017 18:33:57 +0000 Subject: [PATCH 4/5] [_g_l_y_f] use short empty element notation for glyf instructions --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 16a103060..8b524512a 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -371,10 +371,13 @@ class Glyph(object): writer.newline() haveInstructions = self.numberOfContours > 0 if haveInstructions: - writer.begintag("instructions") - writer.newline() - self.program.toXML(writer, ttFont) - writer.endtag("instructions") + if self.program: + writer.begintag("instructions") + writer.newline() + self.program.toXML(writer, ttFont) + writer.endtag("instructions") + else: + writer.simpletag("instructions") writer.newline() def fromXML(self, name, attrs, content, ttFont): From 385c6d8f4f709fc221f121b93a28fb6cf5119bb4 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jan 2017 18:34:55 +0000 Subject: [PATCH 5/5] [data/expect_keep_colr.ttx] adjust empty instructions elements in test data --- Tests/subset/data/expect_keep_colr.ttx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Tests/subset/data/expect_keep_colr.ttx b/Tests/subset/data/expect_keep_colr.ttx index 5fdbc5cc3..d6736ef27 100644 --- a/Tests/subset/data/expect_keep_colr.ttx +++ b/Tests/subset/data/expect_keep_colr.ttx @@ -36,8 +36,7 @@ - - + @@ -61,8 +60,7 @@ - - + @@ -106,8 +104,7 @@ - - + @@ -171,8 +168,7 @@ - - +