Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_shared_features_expansion(data_dir, tmp_path):
shutil.copytree(data_dir / "DesignspaceTestSharedFeatures", tmp_path / "sources")
fontmake.__main__.main(
[
"-m",
str(tmp_path / "sources" / "DesignspaceTestSharedFeatures.designspace"),
"-i",
"--expand-features-to-instances",
"-o",
"ttf",
"--output-dir",
str(tmp_path),
]
)
test_feature_file = (
tmp_path / "sources/instance_ufo/DesignspaceTest-Light.ufo/features.fea"
)
assert test_feature_file.read_text() == "# test"
def test_shared_features_ufo(data_dir, tmp_path):
shutil.copytree(data_dir / "DesignspaceTestSharedFeatures", tmp_path / "sources")
fontmake.__main__.main(
[
"-u",
str(tmp_path / "sources" / "DesignspaceTest-Light.ufo"),
str(tmp_path / "sources" / "DesignspaceTest-Regular.ufo"),
"-o",
"ttf",
"--output-dir",
str(tmp_path),
]
)
assert {p.name for p in tmp_path.glob("*.*")} == {
"DesignspaceTest-Light.ttf",
"DesignspaceTest-Regular.ttf",
}
def test_variable_otf(data_dir, tmp_path):
shutil.copytree(data_dir / "DesignspaceTest", tmp_path / "sources")
fontmake.__main__.main(
[
"-m",
str(tmp_path / "sources" / "DesignspaceTest.designspace"),
"-o",
"variable-cff2",
"--output-dir",
str(tmp_path),
]
)
assert {p.name for p in tmp_path.glob("*.*")} == {"DesignspaceTest-VF.otf"}
def test_interpolation_and_masters_as_instances(data_dir, tmp_path):
shutil.copytree(data_dir / "DesignspaceTest", tmp_path / "sources")
fontmake.__main__.main(
[
"-m",
str(tmp_path / "sources" / "DesignspaceTest.designspace"),
"-i",
"-M",
"--output-dir",
str(tmp_path),
]
)
assert {p.name for p in tmp_path.glob("*.*")} == {
"MyFont-Bold.otf",
"MyFont-Bold.ttf",
"MyFont-Light.otf",
"MyFont-Light.ttf",
"MyFont-Regular.otf",
designspace = designspaceLib.DesignSpaceDocument.fromfile(
tmp_path / "master_ufos" / "GlyphsUnitTestSans.designspace"
)
assert "public.skipExportGlyphs" in designspace.lib
assert designspace.lib["public.skipExportGlyphs"] == [
"_part.shoulder",
"_part.stem",
]
for path in (tmp_path / "master_ufos").glob("*.ufo"):
with ufoLib2.Font.open(path) as ufo:
assert "public.skipExportGlyphs" in ufo.lib
shutil.rmtree(tmp_path / "master_ufos")
fontmake.__main__.main(args + ["--no-write-skipexportglyphs"])
designspace = designspaceLib.DesignSpaceDocument.fromfile(
tmp_path / "master_ufos" / "GlyphsUnitTestSans.designspace"
)
assert "public.skipExportGlyphs" not in designspace.lib
for path in (tmp_path / "master_ufos").glob("*.ufo"):
with ufoLib2.Font.open(path) as ufo:
assert "public.skipExportGlyphs" not in ufo.lib
assert not ufo["_part.shoulder"].lib["com.schriftgestaltung.Glyphs.Export"]
assert not ufo["_part.stem"].lib["com.schriftgestaltung.Glyphs.Export"]
"--master-dir",
str(tmp_path / "master_ufos"),
"--instance-dir",
str(tmp_path / "instance_ufos"),
"-i",
"Test Subset Regular",
"-o",
"ttf",
"otf",
"--output-dir",
str(tmp_path),
]
if not write_skipexportglyphs:
args.append("--no-write-skipexportglyphs")
fontmake.__main__.main(args)
for output_format in ("ttf", "otf"):
for font_path in tmp_path.glob("*." + output_format):
font = fontTools.ttLib.TTFont(font_path)
assert font.getGlyphOrder() == [".notdef", "space", "A", "C"]
def test_masters_and_instances_ttf_interpolatable(data_dir, tmp_path):
shutil.copytree(data_dir / "DesignspaceTest", tmp_path / "sources")
fontmake.__main__.main(
[
"-m",
str(tmp_path / "sources" / "DesignspaceTest.designspace"),
"-o",
"ttf-interpolatable",
"--output-dir",
str(tmp_path),
]
)
assert {p.name for p in tmp_path.glob("*.*")} == {
"MyFont-Bold.ttf",
"MyFont-Light.ttf",
"DesignspaceTest.designspace",
}