Skip to content

Commit 7d025f5

Browse files
committed
improved lost chars display, fix fontTools saving problem
1 parent 286c6ce commit 7d025f5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ASFMKV_dev.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@
201201
6: 'utf-16-be'
202202
}}
203203

204-
# 将fontTools文本编解码模块中gb2312等效参数改为gbk
205-
fontTools.misc.encodingTools._encodingMap[3][3] = 'gbk'
206-
fontTools.misc.encodingTools._encodingMap[1][25] = 'gbk'
207-
208-
# lcidfil = fontTools.misc.encodingTools._encodingMap
209-
210204
# 以下环境变量不应更改
211205
# 编译 style行 搜索用正则表达式
212206
style_read = re.compile('.*\nStyle:.*')
@@ -1881,7 +1875,7 @@ def assFontSubset(assfont: dict, fontdir: str, allTTF: bool = False):
18811875
# print(fontdir, path.exists(path.dirname(fontdir)), path.exists(fontdir))
18821876
fontname = re.sub(cillegal, '_', s[4])
18831877
subfontpath = path.join(fontdir, fontname + subfontext)
1884-
print('\r\033[1;32m[{0}/{1}]\033[0m \033[1m正在子集化…… \033[0m'.format(kip, lk), end='')
1878+
print('\033[1;32m[{0}/{1}]\033[0m \033[1m正在子集化……{2}\033[0m'.format(kip, lk, s[4]))
18851879
if char_compatible:
18861880
if re.search(r'[0-9]', s[2]):
18871881
s[2] = '{0}{1}'.format(re.sub(r'[0-9]', '', s[2].replace('\n', '')), '0123456789')
@@ -1891,10 +1885,13 @@ def assFontSubset(assfont: dict, fontdir: str, allTTF: bool = False):
18911885
gfs, gfs_uni, out_of_range = charExistCheck(s[0], s[1], s[2])
18921886
gfs = gfs.lstrip(',')
18931887
if len(out_of_range) > 0:
1888+
1889+
showOutChars = ' '.join([(c if c.isprintable() else 'U+' + hex(ord(c))[2:].rjust(4, '0').upper()) for c in out_of_range])
1890+
18941891
if ignoreLost:
1895-
print('\n\033[1;31m[WARNING] 已忽略不在字体中的字符\033[0m')
1892+
print('\033[1;31m[WARNING] 已忽略不在字体中的字符 {}\033[0m'.format(showOutChars))
18961893
else:
1897-
print('\n\033[1;31m[ERROR] 以下字符不在字体\"{1}\"\033[0m\n\"{0}\"\n\033[1;31m[ERROR] 以上字符不在字体\"{1}\"\033[0m'.format(out_of_range, s[3]))
1894+
print('\033[1;31m[ERROR] 以下字符不在字体\"{1}\"\033[0m\n\"{0}\"\n\033[1;31m[ERROR] 以上字符不在字体\"{1}\"\033[0m'.format(showOutChars, s[3]))
18981895
print('\033[1;31m[ERROR] 已停止子集化,如果您想要强行子集化,请启用ignoreLost\033[0m')
18991896
return None
19001897
if len(gfs) == 0:
@@ -3163,8 +3160,11 @@ def writeEmbeddedFonts(filePath: str, assInfo: dict):
31633160
if char_lost:
31643161
print('\033[1;33m正在检查:\033[0m \033[1m{0}\033[0m'.format(assfont[s][1]))
31653162
a, b, out_of_range = charExistCheck(s[0], int(s[1]), assfont[s][0])
3163+
3164+
showOutChars = ' '.join([(c if c.isprintable() else 'U+' + hex(ord(c))[2:].rjust(4, '0').upper()) for c in out_of_range])
3165+
31663166
if len(out_of_range) > 0:
3167-
out_of_ranges[s] = [str(len(out_of_range)), out_of_range.strip(' ')]
3167+
out_of_ranges[s] = [str(len(out_of_range)), showOutChars]
31683168
elif len(a) == 0:
31693169
print('\033[1;31m检查失败:\033[0m \033[1m{0}\033[0m'.format(assfont[s][1]))
31703170
out_of_ranges[s] = ['N', '']

0 commit comments

Comments
 (0)