Skip to content

Commit

Permalink
fix logic of autohint parameter
Browse files Browse the repository at this point in the history
an empty string (autohint='') means run ttfautohint with default options.
autohint=None means don't run ttfautohint.
  • Loading branch information
anthrotype committed Feb 9, 2022
1 parent c741c98 commit 9e0c3dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Lib/fontmake/font_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,17 @@ def save_otfs(
font["GSUB"] = gsub_src["GSUB"]

# Decide on autohinting and its parameters
autohint_thisfont = ttf and (
autohint or ufo.lib.get(AUTOHINTING_PARAMETERS)
autohint_thisfont = (
(
autohint
if autohint is not None
else ufo.lib.get(AUTOHINTING_PARAMETERS)
)
if ttf
else None
)

if autohint_thisfont:
if autohint_thisfont is not None:
# if we are autohinting, we save the unhinted font to a
# temporary path, and the hinted one to the final destination
fd, otf_path = tempfile.mkstemp("." + ext)
Expand All @@ -576,7 +582,7 @@ def save_otfs(
):
self.subset_otf_from_ufo(otf_path, ufo)

if not autohint_thisfont:
if autohint_thisfont is None:
continue

if output_path is not None:
Expand Down
11 changes: 10 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,15 @@ def test_main_with_filter(data_dir, tmp_path):
platform.python_implementation() == "PyPy",
reason="ttfautohint-py doesn't work with pypy",
)
def test_autohinting(data_dir, tmp_path):
@pytest.mark.parametrize(
"autohint_options",
[
(),
("-a",),
("--autohint", "-D latn"),
]
)
def test_autohinting(data_dir, tmp_path, autohint_options):
shutil.copytree(data_dir / "AutohintingTest", tmp_path / "sources")

fontmake.__main__.main(
Expand All @@ -731,6 +739,7 @@ def test_autohinting(data_dir, tmp_path):
"-i",
"--output-dir",
str(tmp_path),
*autohint_options,
]
)

Expand Down

0 comments on commit 9e0c3dc

Please sign in to comment.