Skip to content

Commit

Permalink
Version 0.2.6
Browse files Browse the repository at this point in the history
'ftcli utils remove-hinting' now relies on dehinter by Source Foundry: https://twitter.com/messages/15084480-1389235201021288448
  • Loading branch information
ftCLI committed May 28, 2021
1 parent 0fea28e commit 2386459
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The following packages will be installed during setup:
* fonttools
* click
* colorama
* dehinter
* brotli
* skia-pathops
* zopfli
Expand Down
37 changes: 29 additions & 8 deletions ftcli/commands/ftcli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,48 @@ def rmHinting():

@rmHinting.command()
@click.argument('input_path', type=click.Path(exists=True, resolve_path=True))
@click.option('--keep-cvar', is_flag=True, default=False, help="keep cvar table")
@click.option('--keep-cvt', is_flag=True, default=False, help="keep cvt table")
@click.option('--keep-fpgm', is_flag=True, default=False, help="keep fpgm table")
@click.option('--keep-hdmx', is_flag=True, default=False, help="keep hdmx table")
@click.option('--keep-ltsh', is_flag=True, default=False, help="keep LTSH table")
@click.option('--keep-prep', is_flag=True, default=False, help="keep prep table")
@click.option('--keep-ttfa', is_flag=True, default=False, help="keep ttfa table")
@click.option('--keep-vdmx', is_flag=True, default=False, help="keep vdmx table")
@click.option('--keep-glyf', is_flag=True, default=False, help="do not modify glyf table")
@click.option('--keep-gasp', is_flag=True, default=False, help="do not modify gasp table")
@click.option('--keep-maxp', is_flag=True, default=False, help="do not modify maxp table")
@click.option('--keep-head', is_flag=True, default=False, help="do not head glyf table")
@click.option('--verbose', is_flag=True, default=False, help="display standard output")
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True), default=None,
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t'
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t '
'exist, will be created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False, show_default=True,
help='Keep the original font \'modified\' timestamp (head.modified) or set it to current time. By'
help='Keep the original font \'modified\' timestamp (head.modified) or set it to current time. By '
'default, original timestamp is kept.')
@click.option('--overwrite/--no-overwrite', default=True, show_default=True,
help='Overwrite existing output files or save them to a new file (numbers are appended at the end of file'
'name). By default, files are overwritten.')
def remove_hinting(input_path, output_dir=None, recalc_timestamp=False, overwrite=True):
help='Overwrite existing output files or save them to a new file (numbers are appended at the end of '
'file name). By default, files are overwritten.')
def remove_hinting(input_path, keep_cvar, keep_cvt, keep_fpgm, keep_hdmx, keep_ltsh, keep_prep, keep_ttfa, keep_vdmx,
keep_glyf, keep_gasp, keep_maxp, keep_head, verbose, output_dir=None, recalc_timestamp=False,
overwrite=True):
"""Drops hinting from all glyphs.
Currently this only works with TrueType fonts with 'glyf' table.
This is a CLI for dehinter by Source Foundry: https://github.com/source-foundry/dehinter/tree/master/lib/dehinter
"""

from dehinter.font import dehint

files = getFontsList(input_path)
for f in files:
try:
font = TTFont(f, recalcTimestamp=recalc_timestamp)
if not font.sfntVersion == 'OTTO':
font['glyf'].removeHinting()
dehint(font, keep_cvar=keep_cvar, keep_cvt=keep_cvt, keep_fpgm=keep_fpgm, keep_gasp=keep_gasp,
keep_glyf=keep_glyf, keep_head=keep_head, keep_ltsh=keep_ltsh, keep_maxp=keep_maxp,
keep_prep=keep_prep, keep_ttfa=keep_ttfa, keep_vdmx=keep_vdmx, verbose=verbose)
output_file = makeOutputFileName(f, outputDir=output_dir, overWrite=overwrite)
font.save(output_file)
click.secho('%s saved' % output_file, fg='green')
Expand All @@ -54,7 +75,7 @@ def rmOverlaps():
@rmOverlaps.command()
@click.argument('input_path', type=click.Path(exists=True, resolve_path=True))
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True), default=None,
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t'
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t '
'exist, will be created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False, show_default=True,
help='Keep the original font \'modified\' timestamp (head.modified) or set it to current time. By'
Expand Down Expand Up @@ -97,7 +118,7 @@ def extractTTC():
@extractTTC.command()
@click.argument('input_path', type=click.Path(exists=True, resolve_path=True, dir_okay=False))
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True), default=None,
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t'
help='Specify the output directory where the output files are to be saved. If output_directory doesn\'t '
'exist, will be created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False, show_default=True,
help='Keep the original font \'modified\' timestamp (head.modified) or set it to current time. By'
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name='ftcli',
version='0.2.5',
version='0.2.6',
description='ftCLI',
packages=setuptools.find_packages(),
include_package_data=True,
Expand All @@ -11,6 +11,7 @@
'fonttools>=4.21.1',
'brotli',
'click',
'dehinter',
'colorama',
'skia-pathops',
'zopfli',
Expand Down

0 comments on commit 2386459

Please sign in to comment.