diff --git a/LunaTranslator/LunaTranslator/rendertext/internal/webview/faguang.py b/LunaTranslator/LunaTranslator/rendertext/internal/webview/faguang.py index 475ec249..afcf6ccd 100644 --- a/LunaTranslator/LunaTranslator/rendertext/internal/webview/faguang.py +++ b/LunaTranslator/LunaTranslator/rendertext/internal/webview/faguang.py @@ -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); }}""" return style + f'
{text}
' diff --git a/LunaTranslator/LunaTranslator/rendertext/internal/webview/normal.py b/LunaTranslator/LunaTranslator/rendertext/internal/webview/normal.py index fc3fc8c0..b3125fd9 100644 --- a/LunaTranslator/LunaTranslator/rendertext/internal/webview/normal.py +++ b/LunaTranslator/LunaTranslator/rendertext/internal/webview/normal.py @@ -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); }}""" return style + f'
{text}
' diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.py b/LunaTranslator/LunaTranslator/rendertext/webview.py index af595a63..93837f73 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.py +++ b/LunaTranslator/LunaTranslator/rendertext/webview.py @@ -148,7 +148,11 @@ class TextBrowser(QWidget, dataget): isshowhira, isshow_fenci, isfenciclick = flags fm, fskana, bold = self._getfontinfo_kana() kanacolor = self._getkanacolor() - text = "" + if isshowhira: + rb, rb2, rt, rt2 = "", "", "", "" + else: + rb, rb2, rt, rt2 = "", "", "", "" + 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 + "
" + text = text + rb2 + "
" + rb continue text += ( f"""
""" @@ -168,22 +172,19 @@ class TextBrowser(QWidget, dataget): + "
" ) if (word["orig"] != word["hira"]) and isshowhira: - text += ( - f"" - + self.gen_html( - word["hira"], - fm, - fskana, - bold, - True, - kanacolor, - globalconfig["extra_space"], - ) - + "" + inner = self.gen_html( + word["hira"], + fm, + fskana, + bold, + True, + kanacolor, + globalconfig["extra_space"], ) else: - text += "" - text = text + "
" + inner = "" + text += rt + inner + rt2 + text = text + rb2 fm, fs, bold = self._getfontinfo(origin) text = self.gen_html(