11
11
from fontTools import ttLib , subset
12
12
from chardet .universaldetector import UniversalDetector
13
13
from chardet import detect
14
- import os , sys , re , winreg , zlib , json , copy , traceback , shutil , configparser , time , locale , codecs , argparse
14
+ import os , sys , re , winreg , zlib , json , copy , traceback , shutil , configparser , time , locale , codecs , argparse , unicodedata
15
15
from os import path
16
16
from colorama import init
17
17
from datetime import datetime
@@ -1135,13 +1135,12 @@ def fnReadCorrect(ttfont: ttLib.ttFont, index: int, fontpath: str):
1135
1135
return namestr , c
1136
1136
1137
1137
1138
-
1139
1138
def outputSameLength (s : str ) -> str :
1140
1139
length = 0
1141
1140
output = ''
1142
1141
for i in range (len (s ) - 1 , - 1 , - 1 ):
1143
1142
si = s [i ]
1144
- if 65281 <= ord (si ) <= 65374 or ord ( si ) == 12288 or ord ( si ) not in range ( 33 , 127 ) :
1143
+ if unicodedata . east_asian_width (si ) in [ 'F' , 'W' , 'A' ] :
1145
1144
length += 2
1146
1145
else :
1147
1146
length += 1
@@ -1150,7 +1149,8 @@ def outputSameLength(s: str) -> str:
1150
1149
break
1151
1150
else :
1152
1151
output = si + output
1153
- return output + '' .join ([' ' for _ in range (0 , 60 - length )])
1152
+ return output .ljust (60 - (length - len (output )), ' ' )
1153
+ # + ''.join([' ' for _ in range(0, 60 - length)])
1154
1154
1155
1155
1156
1156
# 当前字体缓存版本,小于该版本的字体缓存会被删除重建
0 commit comments