This commit is contained in:
恍兮惚兮 2024-06-19 20:49:03 +08:00
parent 0b3647e0bb
commit 96cabbfea7
3 changed files with 19 additions and 18 deletions

View File

@ -20,6 +20,6 @@ def gen_html(configs, text, fm, fs, bold, atcenter, color, extra_space):
{bold}
text-shadow:{ntimes};
{align};
line-height: calc(1.5em + {extra_space}px);
line-height: calc(1.2em + {extra_space}px);
}}</style>"""
return style + f'<div id="{_id}">{text}</div>'

View File

@ -13,7 +13,7 @@ def gen_html(configs, text, fm, fs, bold, atcenter, color, extra_space):
color:{color};
{bold}
{align}
line-height: calc(1.5em + {extra_space}px);
line-height: calc(1.2em + {extra_space}px);
}}</style>"""
return style + f'<div id="{_id}">{text}</div>'

View File

@ -148,7 +148,11 @@ class TextBrowser(QWidget, dataget):
isshowhira, isshow_fenci, isfenciclick = flags
fm, fskana, bold = self._getfontinfo_kana()
kanacolor = self._getkanacolor()
text = "<ruby>"
if isshowhira:
rb, rb2, rt, rt2 = "<ruby>", "</ruby>", "<rt>", "</rt>"
else:
rb, rb2, rt, rt2 = "<ruby>", "</ruby>", "", ""
text = rb
for word in tag:
color1 = self._randomcolor(word, ignorealpha=True)
if isshow_fenci and color1:
@ -160,7 +164,7 @@ class TextBrowser(QWidget, dataget):
else:
click = ""
if word["orig"] == "\n":
text = text + "</ruby><br><ruby>"
text = text + rb2 + "<br>" + rb
continue
text += (
f"""<div {style} {click}>"""
@ -168,9 +172,7 @@ class TextBrowser(QWidget, dataget):
+ "</div>"
)
if (word["orig"] != word["hira"]) and isshowhira:
text += (
f"<rt>"
+ self.gen_html(
inner = self.gen_html(
word["hira"],
fm,
fskana,
@ -179,11 +181,10 @@ class TextBrowser(QWidget, dataget):
kanacolor,
globalconfig["extra_space"],
)
+ "</rt>"
)
else:
text += "<rt></rt>"
text = text + "</ruby>"
inner = ""
text += rt + inner + rt2
text = text + rb2
fm, fs, bold = self._getfontinfo(origin)
text = self.gen_html(