From b183fe7f285e50114ccdfdfce6656d28e889f1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 31 Jul 2024 00:31:45 +0800 Subject: [PATCH] fix --- .../LunaTranslator/rendertext/textbrowser.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py index 4a5c642f..cd2b134e 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py @@ -246,6 +246,12 @@ class TextBrowser(QWidget, dataget): def append(self, origin, atcenter, text, tag, flags, color, cleared): isshowhira, isshow_fenci, isfenciclick = flags + if len(tag): + font = self._createqfont(origin) + textlines, linetags = self._splitlinestags(font, tag, text) + text = "\n".join(textlines) + tag = self._join_tags(linetags, True) + self._textbrowser_append( origin, atcenter, text, tag if isshowhira else [], color, cleared ) @@ -272,22 +278,16 @@ class TextBrowser(QWidget, dataget): _space = "" if cleared else "\n" blockcount = 0 if cleared else self.textbrowser.document().blockCount() hastag = len(tag) > 0 - if hastag: - textlines, linetags = self._splitlinestags(font, tag, text) + self.textbrowser.insertPlainText(_space + text) + blockcount_after = self.textbrowser.document().blockCount() - self.textbrowser.insertPlainText(_space + "\n".join(textlines)) - blockcount_after = self.textbrowser.document().blockCount() - self._setlineheight_x(blockcount, blockcount_after, linetags) + if hastag: + self._setlineheight_x(blockcount, blockcount_after, self._split_tags(tag)) else: - self.textbrowser.insertPlainText(_space + text) - blockcount_after = self.textbrowser.document().blockCount() self._setlineheight(blockcount, blockcount_after, origin) self.textbrowser.document().blockSignals(False) self.textbrowser.document().contentsChanged.emit() if hastag: - xtag = self._join_tags(linetags, True) - tag.clear() - tag.extend(xtag) self._addtag(tag) self._showyinyingtext(blockcount, blockcount_after, color, font)