From 447116fdba8b7f458dc8ad4666ce3e7725b2d347 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 19 May 2021 20:05:36 +0100 Subject: [PATCH 1/3] Add test to reproduce issue 2312 --- ...S_SinglePos_no_value_issue_2312.subset.ttx | 234 ++++++ .../GPOS_SinglePos_no_value_issue_2312.ttx | 689 ++++++++++++++++++ Tests/subset/subset_test.py | 13 + 3 files changed, 936 insertions(+) create mode 100644 Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.subset.ttx create mode 100644 Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.ttx diff --git a/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.subset.ttx b/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.subset.ttx new file mode 100644 index 000000000..7eee95fe4 --- /dev/null +++ b/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.subset.ttx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.ttx b/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.ttx new file mode 100644 index 000000000..914963723 --- /dev/null +++ b/Tests/subset/data/GPOS_SinglePos_no_value_issue_2312.ttx @@ -0,0 +1,689 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright 2019 Google Inc. All Rights Reserved. + + + Noto Sans Siddham + + + Regular + + + 2.001;GOOG;NotoSansSiddham-Regular + + + Noto Sans Siddham Regular + + + Version 2.001 + + + NotoSansSiddham-Regular + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index 0c39eb011..1294ca586 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -793,6 +793,19 @@ class SubsetTest(unittest.TestCase): subsetfont = TTFont(subsetpath) self.expect_ttx(subsetfont, expected_ttx, ["GPOS"]) + def test_GPOS_SinglePos_prune_post_subset_no_value(self): + _, fontpath = self.compile_font( + self.getpath("GPOS_SinglePos_no_value_issue_2312.ttx"), ".ttf" + ) + subsetpath = self.temp_path(".ttf") + subset.main([fontpath, "*", "--glyph-names", "--output-file=%s" % subsetpath]) + subsetfont = TTFont(subsetpath) + self.expect_ttx( + subsetfont, + self.getpath("GPOS_SinglePos_no_value_issue_2312.subset.ttx"), + ["GlyphOrder", "GPOS"], + ) + @pytest.fixture def featureVarsTestFont(): From defe0f997a8c9b02d94df016befd6cab37937e0d Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 19 May 2021 20:16:14 +0100 Subject: [PATCH 2/3] subset: don't prune_post_subset if no SinglePos Value Fixes https://github.com/fonttools/fonttools/issues/2312 --- Lib/fontTools/subset/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index beea837c3..1b61fefc7 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -555,6 +555,9 @@ def subset_glyphs(self, s): @_add_method(otTables.SinglePos) def prune_post_subset(self, font, options): + if not self.Value: + return False + # Shrink ValueFormat if self.Format == 1: if not options.hinting: From 926f7218320f2541a00b13b7f4a9024c51396492 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 20 May 2021 10:01:58 +0100 Subject: [PATCH 3/3] return True from SinglePos.prune_post_subset to not change semantics the useless subtable might have been there to stop the next subtable from applying... https://github.com/fonttools/fonttools/pull/2313#issuecomment-844497422 --- Lib/fontTools/subset/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index 1b61fefc7..65415e2e9 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -555,8 +555,9 @@ def subset_glyphs(self, s): @_add_method(otTables.SinglePos) def prune_post_subset(self, font, options): - if not self.Value: - return False + if self.Value is None: + assert self.ValueFormat == 0 + return True # Shrink ValueFormat if self.Format == 1: @@ -575,7 +576,7 @@ def prune_post_subset(self, font, options): self.Value = self.Value[0] if self.ValueFormat != 0 else None del self.ValueCount - return bool(self.ValueFormat) + return True @_add_method(otTables.PairPos) def subset_glyphs(self, s):