Skip to content

Commit

Permalink
subset_test: add test for dropping 'rvrn' feature and all FeatureVari…
Browse files Browse the repository at this point in the history
…ationRecords

Added a TODO for the partial dropping of FeatureVariationRecords
#1881 (comment)
  • Loading branch information
anthrotype committed Apr 25, 2020
1 parent 8825e19 commit ec62051
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions Tests/subset/subset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ def test_subset_flavor(self):
self.assertEqual(ttf.flavor, None)


def test_subset_feature_variations():
@pytest.fixture
def featureVarsTestFont():
fb = FontBuilder(unitsPerEm=100)
fb.setupGlyphOrder([".notdef", "f", "f_f", "dollar", "dollar.rvrn"])
fb.setupCharacterMap({ord("f"): "f", ord("$"): "dollar"})
Expand All @@ -753,7 +754,11 @@ def test_subset_feature_variations():
fb.save(buf)
buf.seek(0)

font = TTFont(buf)
return TTFont(buf)


def test_subset_feature_variations_keep_all(featureVarsTestFont):
font = featureVarsTestFont

options = subset.Options()
subsetter = subset.Subsetter(options)
Expand All @@ -771,6 +776,30 @@ def test_subset_feature_variations():
assert "dollar.rvrn" in font.getGlyphOrder()


def test_subset_feature_variations_drop_all(featureVarsTestFont):
font = featureVarsTestFont

options = subset.Options()
options.layout_features.remove("rvrn") # drop 'rvrn'
subsetter = subset.Subsetter(options)
subsetter.populate(unicodes=[ord("f"), ord("$")])
subsetter.subset(font)

featureTags = {
r.FeatureTag for r in font["GSUB"].table.FeatureList.FeatureRecord
}
glyphs = set(font.getGlyphOrder())

assert "rvrn" not in featureTags
assert glyphs == {".notdef", "f", "dollar"}
# all FeatureVariationRecords were dropped
assert not font["GSUB"].table.FeatureVariations.FeatureVariationRecord


# TODO test_subset_feature_variations_drop_from_end_empty_records
# https://github.com/fonttools/fonttools/issues/1881#issuecomment-619415044


def test_subset_single_pos_format():
fb = FontBuilder(unitsPerEm=1000)
fb.setupGlyphOrder([".notdef", "a", "b", "c"])
Expand Down

0 comments on commit ec62051

Please sign in to comment.