-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmerge_font.py
More file actions
53 lines (39 loc) · 1.13 KB
/
merge_font.py
File metadata and controls
53 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
# coding=utf8
import os
import argparse
from fontTools.ttLib import TTFont
from fontTools.merge import Merger
def merge_font(font1, font2, output):
# Merge the fonts
merger = Merger()
new_font = merger.merge([font1, font2])
# Save the merged font
new_font.save(output)
def cli():
parser = argparse.ArgumentParser(
description="merge font")
parser.add_argument("--font1",
help="input font1 file",
required=True,
type=str)
parser.add_argument("--font2",
help="input font2 file",
required=True,
type=str)
parser.add_argument("--output",
help="output font folder",
default="output.ttf",
type=str)
args = parser.parse_args()
pass_precheck = True
if not os.path.exists(args.font1):
pass_precheck = False
print("font1 file not found: %s" % (args.font1))
if not os.path.exists(args.font2):
pass_precheck = False
print("font2 file not found: %s" % (args.font2))
if pass_precheck:
merge_font(args.font1, args.font2, args.output)
if __name__ == "__main__":
cli()