def test_deprecated_methods(self, FontClass): compiler = FeatureCompiler(FontClass()) with pytest.warns(UserWarning, match="method is deprecated"): compiler.setupFile_features() compiler.features = "" with pytest.warns(UserWarning, match="method is deprecated"): compiler.setupFile_featureTables() class UserCompiler(FeatureCompiler): def setupFile_features(self): self.features = "# hello world" def setupFile_featureTables(self): self.ttFont = ttLib.TTFont() compiler = UserCompiler(FontClass()) with pytest.warns(UserWarning, match="method is deprecated"): compiler.compile()
def test_mode(self): class MockTTFont: def getReverseGlyphMap(self): return {"one": 0, "four": 1, "six": 2, "seven": 3} outline = MockTTFont() ufo = Font() for name in ("one", "four", "six", "seven"): ufo.newGlyph(name) existing = dedent(""" feature kern { pos one four' -50 six; } kern; """) ufo.features.text = existing ufo.kerning.update({ ('seven', 'six'): 25.0, }) writer = KernFeatureWriter() # default mode="skip" compiler = FeatureCompiler(ufo, outline, featureWriters=[writer]) compiler.setupFile_features() assert compiler.features == existing writer = KernFeatureWriter(mode="append") compiler = FeatureCompiler(ufo, outline, featureWriters=[writer]) compiler.setupFile_features() assert compiler.features == existing + dedent(""" lookup kern_ltr { lookupflag IgnoreMarks; pos seven six 25; } kern_ltr; feature kern { lookup kern_ltr; } kern;""") writer = KernFeatureWriter(mode="prepend") compiler = FeatureCompiler(ufo, outline, featureWriters=[writer]) compiler.setupFile_features() assert compiler.features == dedent(""" lookup kern_ltr { lookupflag IgnoreMarks; pos seven six 25; } kern_ltr; feature kern { lookup kern_ltr; } kern; """) + existing