-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
66 lines (52 loc) · 1.92 KB
/
__init__.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
# pip install git+https://github.com/BlackFoundryCom/fontra.git
# pip install git+https://github.com/BlackFoundryCom/fontra-rcjk.git
from font import createFontBuilder
from rcjkTools import *
from flatFont import buildFlatFont
from varcFont import buildVarcFont
import argparse
import asyncio
import sys
from fontra_rcjk.backend_fs import RCJKBackend
async def main(args):
print("Loading glyphs")
parser = argparse.ArgumentParser(description="Build a fontra font")
parser.add_argument("rcjk_path", type=str, help="Path to the RCJK font")
parser.add_argument(
"glyphs", type=str, nargs="*", help="List of glyphs to build (default: all)"
)
parser.add_argument(
"--optimize-font-speed",
action="store_true",
help="Optimize the font for speed (default: False)",
)
parser.add_argument(
"--status",
type=int,
help="Only build glyphs with the specified status (default: all)",
)
args = parser.parse_args(args)
optimizeSpeed = args.optimize_font_speed or False
rcjk_path = args.rcjk_path
status = args.status
glyphset = args.glyphs
rcjkfont = RCJKBackend.fromPath(rcjk_path)
revCmap = await rcjkfont.getGlyphMap()
glyphs = {}
for glyphname in revCmap.keys() if not glyphset else glyphset:
print("Loading glyph", glyphname)
glyph = await rcjkfont.getGlyph(glyphname)
glyph_masters = glyphMasters(glyph)
if status is not None:
if not any(
source.customData.get("fontra.development.status", status) == status
for source in glyph.sources
):
print("Skipping glyph", glyphname)
continue
glyphs[glyphname] = glyph
await buildVarcFont(rcjkfont, glyphs, optimizeSpeed)
await buildFlatFont(rcjkfont, glyphs, optimizeSpeed)
if __name__ == "__main__":
import sys
asyncio.run(main(sys.argv[1:]))