@@ -374,6 +374,11 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
374
374
events = assInfo ['Events' ]
375
375
lines = {}
376
376
377
+ reVector = re .compile (r'\{.*?\\p[1-9]\d*.*?\}([\s\S]*?)\{.*?\\p0.*?\}' )
378
+ reVector2 = re .compile (r'\{.*?\\p[1-9]\d*.*?\}' )
379
+ reEffect = re .compile (r'\{.*?(?:\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r).*?\}' )
380
+ reIBon = re .compile (r'\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r' )
381
+
377
382
for i in range (0 , len (events )):
378
383
if events [i ]['Event' ] != 'Dialogue' :
379
384
continue
@@ -382,18 +387,18 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
382
387
textremain = ''
383
388
# 矢量绘图处理,如果发现有矢量表达,从字符串中删除这一部分
384
389
# 这一部分的工作未经详细验证,作用也不大
385
- if re .search (r'\{.*?\\p[1-9]\d*.*?\}([\s\S]*?)\{.*?\\p0.*?\}' , eventftext ) is not None :
386
- vecpos = re .findall (r'\{.*?\\p[1-9]\d*.*?\}[\s\S]*?\{.*?\\p0.*?\}' , eventftext )
390
+ if re .search (reVector , eventftext ) is not None :
391
+ vecpos = re .findall (reVector , eventftext )
387
392
nexts = 0
388
393
for s in vecpos :
389
394
vecfind = eventftext .find (s )
390
395
textremain += eventftext [nexts :vecfind ]
391
396
nexts = vecfind
392
397
s = re .sub (r'\\p\d+' , '' , re .sub (r'}.*?{' , '}{' , s ))
393
398
textremain += s
394
- elif re .search (r'\{.*?\\p[1-9]\d*.*?\}' , eventftext ) is not None :
399
+ elif re .search (reVector2 , eventftext ) is not None :
395
400
eventftext = re .sub (r'\\p\d+' , '' ,
396
- eventftext [:re .search (r'\{.*?\\p[1-9]\d*.*?\}' , eventftext ).span ()[0 ]])
401
+ eventftext [:re .search (reVector2 , eventftext ).span ()[0 ]])
397
402
if len (textremain ) > 0 :
398
403
eventftext = textremain
399
404
eventfont = assInfo ['Styles' ].get (events [i ]['Style' ])
@@ -410,15 +415,15 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
410
415
lfi = eventfont ['Italic' ]
411
416
lfb = eventfont ['Bold' ]
412
417
# 首先查找蕴含有启用粗体/斜体标记的特效标签
413
- if re .search (r'\{.*?(?:\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r).*?\}' , eventftext ) is not None :
418
+ if re .search (reEffect , eventftext ) is not None :
414
419
lastfind = 0
415
420
allfind = re .findall (r'\{.*?\}' , eventftext )
416
421
eventftext2 = eventftext
417
422
# 在所有特效标签中寻找
418
423
# 然后分别确认该特效标签的适用范围,以准确将字体子集化b
419
424
for sti in range (0 , len (allfind )):
420
425
st = allfind [sti ]
421
- ibopen = re .search (r'\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r' , st )
426
+ ibopen = re .search (reIBon , st )
422
427
if ibopen is not None :
423
428
stfind = eventftext2 .find (st )
424
429
addbold = lfb
@@ -3946,7 +3951,7 @@ def cFontSubset(font_info):
3946
3951
3947
3952
def cLicense ():
3948
3953
cls ()
3949
- print ('''AddSubFontMKV Python Remake Preview 24
3954
+ print ('''AddSubFontMKV Python Remake Preview 25
3950
3955
3951
3956
Apache-2.0 License
3952
3957
https://www.apache.org/licenses/
@@ -4218,7 +4223,7 @@ def checkFF():
4218
4223
def loadMain (reload : bool = False ):
4219
4224
global extlist , no_mkvm , no_cmdc , dupfont , mkvmv , font_info , fontin , langlist , ffmv , insteadFF
4220
4225
# 初始化字体列表 和 mkvmerge 相关参数
4221
- os .system ('title ASFMKV Python Remake Pre24 ^| (c) 2022-2024 yyfll ^| Apache-2.0' )
4226
+ os .system ('title ASFMKV Python Remake Pre25 ^| (c) 2022-2024 yyfll ^| Apache-2.0' )
4222
4227
if not reload :
4223
4228
if not o_fontload :
4224
4229
font_list = getFontFileList (fontin )
@@ -4265,7 +4270,7 @@ def loadMain(reload: bool = False):
4265
4270
if not len (ffmv ) > 0 :
4266
4271
ffMessage = '\n [F] 检查并启用FFmpeg'
4267
4272
ffSelect = 'F'
4268
- print ('''ASFMKV Python Remake Pre24 | (c) 2022-2024 yyfll{0}{5}
4273
+ print ('''ASFMKV Python Remake Pre25 | (c) 2022-2024 yyfll{0}{5}
4269
4274
字体名称数: [\033 [1;33m{2}\033 [0m]({4})
4270
4275
请选择功能:
4271
4276
[A] 列出字幕所用字体
0 commit comments