diff options
author | Elliott Hughes <enh@google.com> | 2022-08-24 18:50:57 +0000 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2022-08-24 18:50:57 +0000 |
commit | ae8de171b84d09142c6303a8d04dfb89af956964 (patch) | |
tree | e2eb0b9f93f0a8cb6705199d2f738f35cba28e7f /Tests/subset | |
parent | 2f76e5ea08a08dc7ffef910e066da6777a3c829f (diff) | |
download | fonttools-ae8de171b84d09142c6303a8d04dfb89af956964.tar.gz |
Upgrade fonttools to 4.37.1
Test: make
Change-Id: I32c4b2d3d1f16d5cad6a8a2a2aa058823f924dea
Diffstat (limited to 'Tests/subset')
-rw-r--r-- | Tests/subset/data/expect_no_notdef_outline_cid.ttx | 2 | ||||
-rw-r--r-- | Tests/subset/data/expect_notdef_width_cid.ttx | 2 | ||||
-rw-r--r-- | Tests/subset/subset_test.py | 63 |
3 files changed, 59 insertions, 8 deletions
diff --git a/Tests/subset/data/expect_no_notdef_outline_cid.ttx b/Tests/subset/data/expect_no_notdef_outline_cid.ttx index 5167c2cf..990caa5c 100644 --- a/Tests/subset/data/expect_no_notdef_outline_cid.ttx +++ b/Tests/subset/data/expect_no_notdef_outline_cid.ttx @@ -23,7 +23,7 @@ <CIDFontType value="0"/> <CIDCount value="4"/> <!-- charset is dumped separately as the 'GlyphOrder' element --> - <FDSelect format="3"/> + <FDSelect format="0"/> <FDArray> <FontDict index="0"> <FontName value="TestCID-Regular-One"/> diff --git a/Tests/subset/data/expect_notdef_width_cid.ttx b/Tests/subset/data/expect_notdef_width_cid.ttx index ccd0f65f..8ea77e5e 100644 --- a/Tests/subset/data/expect_notdef_width_cid.ttx +++ b/Tests/subset/data/expect_notdef_width_cid.ttx @@ -23,7 +23,7 @@ <CIDFontType value="0"/> <CIDCount value="4"/> <!-- charset is dumped separately as the 'GlyphOrder' element --> - <FDSelect format="3"/> + <FDSelect format="0"/> <FDArray> <FontDict index="0"> <FontName value="NotdefWidthCID-Regular-Space"/> diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index facafb2a..7efcb698 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -819,13 +819,20 @@ class SubsetTest: if not have_uharfbuzz: pytest.skip("uharfbuzz is not installed") if not ok: - # pretend hb.repack returns an error + # pretend hb.repack/repack_with_tag return an error import uharfbuzz as hb def mock_repack(data, obj_list): raise hb.RepackerError("mocking") monkeypatch.setattr(hb, "repack", mock_repack) + + if hasattr(hb, "repack_with_tag"): # uharfbuzz >= 0.30.0 + + def mock_repack_with_tag(tag, data, obj_list): + raise hb.RepackerError("mocking") + + monkeypatch.setattr(hb, "repack_with_tag", mock_repack_with_tag) else: if have_uharfbuzz: # pretend uharfbuzz is not installed @@ -879,8 +886,8 @@ class SubsetTest: # test we emit a log.error if hb.repack fails (and we don't if successful) assert ( ( - "hb.repack failed to serialize 'GSUB', reverting to " - "pure-python serializer; the error message was: RepackerError: mocking" + "hb.repack failed to serialize 'GSUB', attempting fonttools resolutions " + "; the error message was: RepackerError: mocking" ) in caplog.text ) ^ ok @@ -953,7 +960,8 @@ def test_subset_feature_variations_drop_all(featureVarsTestFont): # https://github.com/fonttools/fonttools/issues/1881#issuecomment-619415044 -def test_subset_single_pos_format(): +@pytest.fixture +def singlepos2_font(): fb = FontBuilder(unitsPerEm=1000) fb.setupGlyphOrder([".notdef", "a", "b", "c"]) fb.setupCharacterMap({ord("a"): "a", ord("b"): "b", ord("c"): "c"}) @@ -971,8 +979,11 @@ def test_subset_single_pos_format(): fb.save(buf) buf.seek(0) - font = TTFont(buf) + return TTFont(buf) + +def test_subset_single_pos_format(singlepos2_font): + font = singlepos2_font # The input font has a SinglePos Format 2 subtable where each glyph has # different ValueRecords assert getXML(font["GPOS"].table.LookupList.Lookup[0].toXML, font) == [ @@ -1018,6 +1029,46 @@ def test_subset_single_pos_format(): '</Lookup>', ] +def test_subset_single_pos_format2_all_None(singlepos2_font): + # https://github.com/fonttools/fonttools/issues/2602 + font = singlepos2_font + gpos = font["GPOS"].table + subtable = gpos.LookupList.Lookup[0].SubTable[0] + assert subtable.Format == 2 + # Hack a SinglePosFormat2 with ValueFormat = 0; our own buildSinglePos + # never makes these as a SinglePosFormat1 is more compact, but they can + # be found in the wild. + subtable.Value = [None] * subtable.ValueCount + subtable.ValueFormat = 0 + + assert getXML(subtable.toXML, font) == [ + '<SinglePos Format="2">', + ' <Coverage>', + ' <Glyph value="a"/>', + ' <Glyph value="b"/>', + ' <Glyph value="c"/>', + ' </Coverage>', + ' <ValueFormat value="0"/>', + ' <!-- ValueCount=3 -->', + '</SinglePos>', + ] + + options = subset.Options() + subsetter = subset.Subsetter(options) + subsetter.populate(unicodes=[ord("a"), ord("c")]) + subsetter.subset(font) + + # Check it was downgraded to Format1 after subsetting + assert getXML(font["GPOS"].table.LookupList.Lookup[0].SubTable[0].toXML, font) == [ + '<SinglePos Format="1">', + ' <Coverage>', + ' <Glyph value="a"/>', + ' <Glyph value="c"/>', + ' </Coverage>', + ' <ValueFormat value="0"/>', + '</SinglePos>', + ] + @pytest.fixture def ttf_path(tmp_path): @@ -1426,7 +1477,7 @@ def test_subset_svg_missing_lxml(ttf_path): font["SVG "].docList = [('<svg><g id="glyph1"/></svg>', 1, 1)] font.save(ttf_path) - with pytest.raises(ModuleNotFoundError): + with pytest.raises(ImportError): subset.main([str(ttf_path), "--gids=0,1"]) |