Skip to content

Commit d92f564

Browse files
committed
fix some bugs
1 parent c9bf151 commit d92f564

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ASFMKV_dev.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@
158158
# 结构为:{ platformID(Decimal) : { LCID : textcoding } }
159159
# 目前Textcoding没有实际作用,仅用于让这个词典可读性更强
160160
# 详情可在 https://docs.microsoft.com/en-us/typography/opentype/spec/name#platform-encoding-and-language-ids 查询
161-
lcidfil = {3: {
161+
lcidfil = {
162+
3: {
162163
2052: 'gbk',
163164
1042: 'euc-kr',
164165
1041: 'shift-jis',
@@ -669,8 +670,6 @@ def assStylesEventsRead(tagLine: int) -> list[dict]:
669670
break
670671
else:
671672
singleLine[lineFormat[j]] = line[j]
672-
if not isEvent:
673-
singleLine['Fontname'] = singleLine['Fontname'].lstrip('@')
674673

675674
if (isEvent and len(singleLine) != len(lineFormat) + 1) or (not isEvent and len(singleLine) != len(lineFormat)):
676675
raise Exception(f'ASS/SSA格式错误 - 缺少逗号分隔 - 位于行{i+1} 文件\"{path.basename(assPath)}\"')
@@ -776,7 +775,7 @@ def assFontList(assInfo: dict, eventSplit: dict) -> dict:
776775

777776
for i in eventSplit.keys():
778777
for l in eventSplit[i]:
779-
fn = l['Fontname']
778+
fn = l['Fontname'].lstrip('@')
780779
l['Text'] = re.sub(r'\{.*?\\.*?\}', '', l['Text'])
781780
if len(assInfo['Subset']) > 0 and fn in assInfo['Subset']:
782781
fn = assInfo['Subset'][fn]
@@ -1966,12 +1965,13 @@ def assFontChange(newfont_name: dict, asspath: str, assInfo: dict, splitEvents:
19661965
styleItalic = abs(int(assInfo['Styles'][k]['Italic']))
19671966
styleBold = abs(int(assInfo['Styles'][k]['Bold']))
19681967
fontstr = assInfo['Styles'][k]['Fontname']
1969-
nfnKey = (fontstr, styleItalic, styleBold)
1968+
nfnKey = (fontstr.lstrip('@'), styleItalic, styleBold)
19701969
if newfont_name.get(nfnKey) is None:
19711970
continue
19721971
else:
19731972
if not newfont_name[nfnKey][1] is None:
19741973
assInfo['Styles'][k]['Fontname'] = newfont_name[nfnKey][1].split('?')[0]
1974+
if fontstr[0] == '@': assInfo['Styles'][k]['Fontname'] = '@' + assInfo['Styles'][k]['Fontname']
19751975

19761976
used_nf_name2 = {}
19771977
for k2 in [k for k in newfont_name.keys() if not newfont_name[k][1] is None]:
@@ -1989,7 +1989,7 @@ def assFontChange(newfont_name: dict, asspath: str, assInfo: dict, splitEvents:
19891989
for fnLine in splitEvents.keys():
19901990
if len(splitEvents[fnLine]) == 1: continue
19911991
for l in splitEvents[fnLine]:
1992-
fname = l['Fontname']
1992+
fname = l['Fontname'].lstrip('@')
19931993
#if len(fname) > 0 and not used_nf_name[fname.upper()][1] is None:
19941994
if len(fname) > 0:
19951995
replaceFn = None
@@ -3686,7 +3686,7 @@ def cFontSubset(font_info):
36863686
if work == 19:
36873687
muxer = 2
36883688
for subp in subonlyp:
3689-
newasspaths, newfont_name, mkvr = main(font_info2, [subp[1]],
3689+
newasspaths, newfont_name, mkvr = main(font_info2, [subp],
36903690
mux=False,
36913691
outdir=[assout_cache, fontout_cache, mkvout_cache],
36923692
FFmuxer = muxer)

0 commit comments

Comments
 (0)