201
201
6 : 'utf-16-be'
202
202
}}
203
203
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
-
210
204
# 以下环境变量不应更改
211
205
# 编译 style行 搜索用正则表达式
212
206
style_read = re .compile ('.*\n Style:.*' )
@@ -1881,7 +1875,7 @@ def assFontSubset(assfont: dict, fontdir: str, allTTF: bool = False):
1881
1875
# print(fontdir, path.exists(path.dirname(fontdir)), path.exists(fontdir))
1882
1876
fontname = re .sub (cillegal , '_' , s [4 ])
1883
1877
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 ]) )
1885
1879
if char_compatible :
1886
1880
if re .search (r'[0-9]' , s [2 ]):
1887
1881
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):
1891
1885
gfs , gfs_uni , out_of_range = charExistCheck (s [0 ], s [1 ], s [2 ])
1892
1886
gfs = gfs .lstrip (',' )
1893
1887
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
+
1894
1891
if ignoreLost :
1895
- print ('\n \ 033 [1;31m[WARNING] 已忽略不在字体中的字符\033 [0m' )
1892
+ print ('\033 [1;31m[WARNING] 已忽略不在字体中的字符 {} \033 [0m' . format ( showOutChars ) )
1896
1893
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 ]))
1898
1895
print ('\033 [1;31m[ERROR] 已停止子集化,如果您想要强行子集化,请启用ignoreLost\033 [0m' )
1899
1896
return None
1900
1897
if len (gfs ) == 0 :
@@ -3163,8 +3160,11 @@ def writeEmbeddedFonts(filePath: str, assInfo: dict):
3163
3160
if char_lost :
3164
3161
print ('\033 [1;33m正在检查:\033 [0m \033 [1m{0}\033 [0m' .format (assfont [s ][1 ]))
3165
3162
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
+
3166
3166
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 ]
3168
3168
elif len (a ) == 0 :
3169
3169
print ('\033 [1;31m检查失败:\033 [0m \033 [1m{0}\033 [0m' .format (assfont [s ][1 ]))
3170
3170
out_of_ranges [s ] = ['N' , '' ]
0 commit comments