From 7144148074c084fc5aab75c07a5bc1b10a78ad29 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, 24 Apr 2024 17:33:41 +0800 Subject: [PATCH] fix Update textbrowser.py Update textbrowser.py --- LunaTranslator/LunaTranslator/gui/textbrowser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index b59a70b4..f6fbdd0b 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -393,7 +393,13 @@ class Textbrowser: index = linei _ = self.yinyinglabels[index] - _.move(tl1) + if self.align:#不然有时候有一个微小的错位 + fm = QFontMetricsF(self.textbrowser.currentCharFormat().font()) + w = fm.width(block.text()[s : s + l]) + WW = self.textbrowser.width() + _.move(int(WW / 2 - w / 2), tl1.y()) + else: + _.move(tl1) _.setText(block.text()[s : s + l]) _.setFont(self.textbrowser.currentCharFormat().font())