[ttLib.removeOverlaps] Use argparse
This commit is contained in:
parent
2da78ba158
commit
9268e1cdee
@ -311,24 +311,25 @@ def removeOverlaps(
|
|||||||
def main(args=None):
|
def main(args=None):
|
||||||
"""Simplify glyphs in TTFont by merging overlapping contours."""
|
"""Simplify glyphs in TTFont by merging overlapping contours."""
|
||||||
|
|
||||||
import sys
|
import argparse
|
||||||
|
|
||||||
if args is None:
|
parser = argparse.ArgumentParser(
|
||||||
args = sys.argv[1:]
|
"fonttools ttLib.removeOverlaps", description=__doc__
|
||||||
|
)
|
||||||
|
|
||||||
if len(args) < 2:
|
parser.add_argument("input", metavar="INPUT.ttf", help="Input font file")
|
||||||
print(
|
parser.add_argument("output", metavar="OUTPUT.ttf", help="Output font file")
|
||||||
f"usage: fonttools ttLib.removeOverlaps INPUT.ttf OUTPUT.ttf [GLYPHS ...]"
|
parser.add_argument(
|
||||||
)
|
"glyphs",
|
||||||
sys.exit(1)
|
metavar="GLYPHS",
|
||||||
|
nargs="*",
|
||||||
|
help="Optional list of glyph names to remove overlaps from",
|
||||||
|
)
|
||||||
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
src = args[0]
|
with ttFont.TTFont(args.input) as f:
|
||||||
dst = args[1]
|
removeOverlaps(f, args.glyphs or None)
|
||||||
glyphNames = args[2:] or None
|
f.save(args.output)
|
||||||
|
|
||||||
with ttFont.TTFont(src) as f:
|
|
||||||
removeOverlaps(f, glyphNames)
|
|
||||||
f.save(dst)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user