Skip to content

Commit

Permalink
add option to --drop-implied-oncurves
Browse files Browse the repository at this point in the history
requires not-yet-released ufo2ft and fonttools

googlefonts/ufo2ft#753
  • Loading branch information
anthrotype committed Jun 12, 2023
1 parent 79302f3 commit 46ad66b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/fontmake/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ def main(args=None):
action="store_false",
help="Don't automatically set USE_MY_METRICS glyf component flags (0x0200).",
)
contourGroup.add_argument(
"--drop-implied-oncurves",
action="store_true",
help="drop on-curve points that can be implied when exactly in the middle of "
"two off-curve points (TrueType only; default: %(default)s).",
)

layoutGroup = parser.add_argument_group(title="Handling of OpenType Layout")
layoutGroup.add_argument(
Expand Down
7 changes: 7 additions & 0 deletions Lib/fontmake/font_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def build_variable_fonts(
flatten_components=False,
filters=None,
auto_use_my_metrics=True,
drop_implied_oncurves=False,
**kwargs,
):
"""Build OpenType variable fonts from masters in a designspace."""
Expand Down Expand Up @@ -434,6 +435,7 @@ def build_variable_fonts(
inplace=True,
variableFontNames=list(vf_name_to_output_path),
autoUseMyMetrics=auto_use_my_metrics,
dropImpliedOnCurves=drop_implied_oncurves,
)
else:
fonts = ufo2ft.compileVariableCFF2s(
Expand Down Expand Up @@ -466,6 +468,7 @@ def _iter_compile(self, ufos, ttf=False, debugFeatureFile=None, **kwargs):
"reverseDirection",
"flattenComponents",
"autoUseMyMetrics",
"dropImpliedOnCurves",
):
options.pop(key, None)
compile_func, fmt = ufo2ft.compileOTF, "OTF"
Expand Down Expand Up @@ -513,6 +516,7 @@ def save_otfs(
generate_GDEF=True,
fea_include_dir=None,
auto_use_my_metrics=True,
drop_implied_oncurves=False,
):
"""Build OpenType binaries from UFOs.
Expand Down Expand Up @@ -570,6 +574,8 @@ def save_otfs(
be disabled with other arguments.
auto_use_my_metrics: whether to automatically set USE_MY_METRICS glyf
component flags (0x0200). Not needed unless the font has hinted metrics.
drop_implied_oncurves: drop on-curve points that can be implied when exactly
in the middle of two off-curve points (TrueType only; default: False).
""" # noqa: B950
assert not (output_path and output_dir), "mutually exclusive args"

Expand Down Expand Up @@ -624,6 +630,7 @@ def save_otfs(
flattenComponents=flatten_components,
filters=filters,
autoUseMyMetrics=auto_use_my_metrics,
dropImpliedOnCurves=drop_implied_oncurves,
inplace=True, # avoid extra copy
)

Expand Down

0 comments on commit 46ad66b

Please sign in to comment.