From fed416f2b26202dc9f630888112557db702c55bb 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: Mon, 15 Jul 2024 01:42:59 +0800 Subject: [PATCH] ala --- .../rendertext/textbrowser_imp/base.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/base.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/base.py index 99252f94..02bfc604 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/base.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/base.py @@ -59,7 +59,22 @@ class base(QLabel): self.movedx = 0 self.movedy = 0 dx, dy = self.moveoffset() - self.movedx -= dx + text = self.text() + isarabic = lambda char: (ord(char) >= 0x0600 and ord(char) <= 0x06E0) + isasciinoteng = ( + lambda char: (ord(char) <= 0x40) + or ((ord(char) >= 0x5B) and (ord(char) <= 0x60)) + or ((ord(char) >= 0x7B) and (ord(char) <= 0x7F)) + ) + isarabicx = any(isarabic(char) for char in text) and all( + (isasciinoteng(char) or isarabic(char)) for char in text + ) + + if isarabicx: + self.movedx -= self.width() + self.movedx += dx + else: + self.movedx -= dx self.movedy -= dy super().move(QPoint(int(x + self.movedx), int(y + self.movedy)))