-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-encoding.py
26 lines (21 loc) · 971 Bytes
/
set-encoding.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
import sys
import json
import codecs
import configure
if __name__ == '__main__':
param = sys.argv[1]
param = json.loads(param)
dep = {**param, "encoding": "unspec"}
with open("build/nowar/{}.otd".format(configure.GenerateFilename(dep)), 'rb') as baseFile:
baseFont = json.loads(
baseFile.read().decode('UTF-8', errors='replace'))
if param["encoding"] == "abg":
baseFont['OS_2']['ulCodePageRange1']["gbk"] = True
baseFont['OS_2']['ulCodePageRange1']["big5"] = True
baseFont['OS_2']['ulCodePageRange1']["jis"] = True
baseFont['OS_2']['ulCodePageRange1']["korean"] = True
else:
baseFont['OS_2']['ulCodePageRange1'][param["encoding"]] = True
outStr = json.dumps(baseFont, ensure_ascii=False, separators=(',', ':'))
with codecs.open("build/nowar/{}.otd".format(configure.GenerateFilename(param)), 'w', 'UTF-8') as outFile:
outFile.write(outStr)