make --ttf-only more intuitive #337

This commit is contained in:
subframe7536 2025-02-18 21:42:52 +08:00
parent 57a803bcb0
commit 66359f7442

View file

@ -100,7 +100,7 @@ def parse_args():
dest="hinted", dest="hinted",
default=None, default=None,
action="store_false", action="store_false",
help="Use unhinted font as base font", help="Use unhinted font as base font in NF / CN / NF-CN",
) )
liga_group = feature_group.add_mutually_exclusive_group() liga_group = feature_group.add_mutually_exclusive_group()
liga_group.add_argument( liga_group.add_argument(
@ -162,7 +162,7 @@ def parse_args():
build_group.add_argument( build_group.add_argument(
"--ttf-only", "--ttf-only",
action="store_true", action="store_true",
help="Only build unhinted TTF format", help="Only build TTF format",
) )
build_group.add_argument( build_group.add_argument(
"--cache", "--cache",
@ -758,16 +758,20 @@ def build_mono(f: str, font_config: FontConfig, build_option: BuildOption):
font.save(target_path) font.save(target_path)
font.close() font.close()
# Autohint version
print(f"Auto hint {postscript_name}.ttf")
run(f"ftcli ttf autohint {target_path} -out {build_option.output_ttf_hinted}")
if font_config.ttf_only: if font_config.ttf_only:
return return
print(f"Auto hint {postscript_name}.ttf") # Woff2 version
run(f"ftcli ttf autohint {target_path} -out {build_option.output_ttf_hinted}")
print(f"Convert {postscript_name}.ttf to WOFF2") print(f"Convert {postscript_name}.ttf to WOFF2")
run( run(
f"ftcli converter ft2wf {target_path} -out {build_option.output_woff2} -f woff2" f"ftcli converter ft2wf {target_path} -out {build_option.output_woff2} -f woff2"
) )
# OTF version
_otf_path = joinPaths( _otf_path = joinPaths(
build_option.output_otf, path.basename(target_path).replace(".ttf", ".otf") build_option.output_otf, path.basename(target_path).replace(".ttf", ".otf")
) )