Skip to content

Commit

Permalink
<fix> fix reversed font problem in some languages like arabic and imp…
Browse files Browse the repository at this point in the history
…rove filter for extraction

update version to v2.4.2
  • Loading branch information
anonymousException committed Jun 17, 2024
1 parent bdd5b59 commit 467818c
Show file tree
Hide file tree
Showing 39 changed files with 515 additions and 118 deletions.
33 changes: 23 additions & 10 deletions src/font_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QDialog, QLabel, QPushButton,
QSizePolicy, QTextEdit, QWidget)
from PySide6.QtWidgets import (QApplication, QCheckBox, QDialog, QLabel,
QPushButton, QSizePolicy, QTextEdit, QWidget)

class Ui_FontReplaceDialog(object):
def setupUi(self, FontReplaceDialog):
if not FontReplaceDialog.objectName():
FontReplaceDialog.setObjectName(u"FontReplaceDialog")
FontReplaceDialog.resize(663, 346)
FontReplaceDialog.resize(733, 438)
self.widget_3 = QWidget(FontReplaceDialog)
self.widget_3.setObjectName(u"widget_3")
self.widget_3.setGeometry(QRect(30, 10, 600, 331))
self.widget_3.setGeometry(QRect(30, 10, 691, 421))
self.widget_3.setMinimumSize(QSize(600, 220))
self.label_11 = QLabel(self.widget_3)
self.label_11.setObjectName(u"label_11")
Expand All @@ -35,30 +35,38 @@ def setupUi(self, FontReplaceDialog):
self.label_11.setFont(font)
self.selectFontText = QTextEdit(self.widget_3)
self.selectFontText.setObjectName(u"selectFontText")
self.selectFontText.setGeometry(QRect(80, 160, 411, 91))
self.selectFontText.setGeometry(QRect(80, 160, 521, 91))
self.label_4 = QLabel(self.widget_3)
self.label_4.setObjectName(u"label_4")
self.label_4.setGeometry(QRect(0, 190, 81, 31))
self.label_4.setWordWrap(True)
self.selectFontBtn = QPushButton(self.widget_3)
self.selectFontBtn.setObjectName(u"selectFontBtn")
self.selectFontBtn.setGeometry(QRect(490, 160, 81, 91))
self.selectFontBtn.setGeometry(QRect(600, 160, 81, 91))
self.replaceFontBtn = QPushButton(self.widget_3)
self.replaceFontBtn.setObjectName(u"replaceFontBtn")
self.replaceFontBtn.setGeometry(QRect(80, 260, 411, 24))
self.replaceFontBtn.setGeometry(QRect(0, 350, 681, 24))
self.openFontStyleBtn = QPushButton(self.widget_3)
self.openFontStyleBtn.setObjectName(u"openFontStyleBtn")
self.openFontStyleBtn.setGeometry(QRect(80, 300, 411, 24))
self.openFontStyleBtn.setGeometry(QRect(0, 390, 681, 24))
self.label_12 = QLabel(self.widget_3)
self.label_12.setObjectName(u"label_12")
self.label_12.setGeometry(QRect(0, 70, 81, 31))
self.label_12.setWordWrap(True)
self.selectDirText_3 = QTextEdit(self.widget_3)
self.selectDirText_3.setObjectName(u"selectDirText_3")
self.selectDirText_3.setGeometry(QRect(80, 38, 411, 101))
self.selectDirText_3.setGeometry(QRect(80, 38, 521, 101))
self.selectDirBtn_3 = QPushButton(self.widget_3)
self.selectDirBtn_3.setObjectName(u"selectDirBtn_3")
self.selectDirBtn_3.setGeometry(QRect(490, 38, 81, 101))
self.selectDirBtn_3.setGeometry(QRect(600, 38, 81, 101))
self.rtlCheckBox = QCheckBox(self.widget_3)
self.rtlCheckBox.setObjectName(u"rtlCheckBox")
self.rtlCheckBox.setGeometry(QRect(0, 270, 681, 20))
self.rtlCheckBox.setCursor(QCursor(Qt.ArrowCursor))
self.label = QLabel(self.widget_3)
self.label.setObjectName(u"label")
self.label.setGeometry(QRect(0, 290, 681, 61))
self.label.setWordWrap(True)

self.retranslateUi(FontReplaceDialog)

Expand All @@ -76,5 +84,10 @@ def retranslateUi(self, FontReplaceDialog):
self.label_12.setText(QCoreApplication.translate("FontReplaceDialog", u"directory", None))
self.selectDirText_3.setPlaceholderText(QCoreApplication.translate("FontReplaceDialog", u"input or choose or drag the directory you want to replace font here. Example:F:\\GameName\\game\\tl\\language", None))
self.selectDirBtn_3.setText(QCoreApplication.translate("FontReplaceDialog", u"...", None))
#if QT_CONFIG(tooltip)
self.rtlCheckBox.setToolTip("")
#endif // QT_CONFIG(tooltip)
self.rtlCheckBox.setText(QCoreApplication.translate("FontReplaceDialog", u"Enable RTL (Right To Left)", None))
self.label.setText(QCoreApplication.translate("FontReplaceDialog", u"(Fix reversed font problem for some languages like arabic, urdu)", None))
# retranslateUi

63 changes: 49 additions & 14 deletions src/font_replace.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>663</width>
<height>346</height>
<width>733</width>
<height>438</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -18,8 +18,8 @@
<rect>
<x>30</x>
<y>10</y>
<width>600</width>
<height>331</height>
<width>691</width>
<height>421</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -51,7 +51,7 @@
<rect>
<x>80</x>
<y>160</y>
<width>411</width>
<width>521</width>
<height>91</height>
</rect>
</property>
Expand All @@ -78,7 +78,7 @@
<widget class="QPushButton" name="selectFontBtn">
<property name="geometry">
<rect>
<x>490</x>
<x>600</x>
<y>160</y>
<width>81</width>
<height>91</height>
Expand All @@ -91,9 +91,9 @@
<widget class="QPushButton" name="replaceFontBtn">
<property name="geometry">
<rect>
<x>80</x>
<y>260</y>
<width>411</width>
<x>0</x>
<y>350</y>
<width>681</width>
<height>24</height>
</rect>
</property>
Expand All @@ -104,9 +104,9 @@
<widget class="QPushButton" name="openFontStyleBtn">
<property name="geometry">
<rect>
<x>80</x>
<y>300</y>
<width>411</width>
<x>0</x>
<y>390</y>
<width>681</width>
<height>24</height>
</rect>
</property>
Expand Down Expand Up @@ -135,7 +135,7 @@
<rect>
<x>80</x>
<y>38</y>
<width>411</width>
<width>521</width>
<height>101</height>
</rect>
</property>
Expand All @@ -146,7 +146,7 @@
<widget class="QPushButton" name="selectDirBtn_3">
<property name="geometry">
<rect>
<x>490</x>
<x>600</x>
<y>38</y>
<width>81</width>
<height>101</height>
Expand All @@ -156,6 +156,41 @@
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="rtlCheckBox">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>681</width>
<height>20</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Enable RTL (Right To Left)</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>290</y>
<width>681</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>(Fix reversed font problem for some languages like arabic, urdu)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
</widget>
<resources/>
Expand Down
7 changes: 4 additions & 3 deletions src/font_replace_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
from font_util import get_default_font_path

class replaceFontThread(threading.Thread):
def __init__(self, select_dir, font_path):
def __init__(self, select_dir, font_path, is_rtl_enabled):
threading.Thread.__init__(self)
self.select_dir = select_dir
self.font_path = font_path
self.is_rtl_enabled = is_rtl_enabled


def run(self):
try:
log_print('start replace font ...')
GenGuiFonts(self.select_dir, self.font_path)
GenGuiFonts(self.select_dir, self.font_path, self.is_rtl_enabled)
log_print('replace complete!')
except Exception as e:
msg = traceback.format_exc()
Expand Down Expand Up @@ -67,7 +68,7 @@ def replaceFont(self):
select_dir = select_dir + '/'
font_path = self.selectFontText.toPlainText()
font_path = font_path.replace('file:///', '')
t = replaceFontThread(select_dir, font_path)
t = replaceFontThread(select_dir, font_path, self.rtlCheckBox.isChecked())
self.replace_font_thread = t
t.start()
self.setDisabled(True)
Expand Down
1 change: 1 addition & 0 deletions src/font_style_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ init python early hide:
return old_load_face(fn, *args)

renpy.text.font.load_face = my_load_face
renpy.config.rtl = {is_rtl_enabled}

translate {tl_name} python:
import os
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
sourceDic = dict()
translator = QTranslator()

VERSION = '2.4.1'
VERSION = '2.4.2'


class MyProxyForm(QDialog, Ui_ProxyDialog):
Expand Down
23 changes: 18 additions & 5 deletions src/one_key_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Ui_OneKeyTranslateDialog(object):
def setupUi(self, OneKeyTranslateDialog):
if not OneKeyTranslateDialog.objectName():
OneKeyTranslateDialog.setObjectName(u"OneKeyTranslateDialog")
OneKeyTranslateDialog.resize(1039, 679)
OneKeyTranslateDialog.resize(1039, 762)
self.selectFileBtn = QPushButton(OneKeyTranslateDialog)
self.selectFileBtn.setObjectName(u"selectFileBtn")
self.selectFileBtn.setGeometry(QRect(520, 25, 81, 91))
Expand Down Expand Up @@ -61,14 +61,14 @@ def setupUi(self, OneKeyTranslateDialog):
self.localGlossaryCheckBox.setGeometry(QRect(30, 450, 571, 20))
self.selectFontBtn = QPushButton(OneKeyTranslateDialog)
self.selectFontBtn.setObjectName(u"selectFontBtn")
self.selectFontBtn.setGeometry(QRect(520, 570, 81, 91))
self.selectFontBtn.setGeometry(QRect(520, 660, 81, 91))
self.label_4 = QLabel(OneKeyTranslateDialog)
self.label_4.setObjectName(u"label_4")
self.label_4.setGeometry(QRect(30, 600, 71, 31))
self.label_4.setGeometry(QRect(30, 690, 71, 31))
self.label_4.setWordWrap(True)
self.selectFontText = QTextEdit(OneKeyTranslateDialog)
self.selectFontText.setObjectName(u"selectFontText")
self.selectFontText.setGeometry(QRect(110, 570, 411, 91))
self.selectFontText.setGeometry(QRect(110, 660, 411, 91))
self.unpackCheckBox = QCheckBox(OneKeyTranslateDialog)
self.unpackCheckBox.setObjectName(u"unpackCheckBox")
self.unpackCheckBox.setGeometry(QRect(620, 30, 411, 20))
Expand Down Expand Up @@ -108,7 +108,7 @@ def setupUi(self, OneKeyTranslateDialog):
self.label_14.setAlignment(Qt.AlignCenter)
self.startButton = QPushButton(OneKeyTranslateDialog)
self.startButton.setObjectName(u"startButton")
self.startButton.setGeometry(QRect(620, 420, 401, 241))
self.startButton.setGeometry(QRect(620, 420, 401, 331))
self.officialExtractionCheckBox = QCheckBox(OneKeyTranslateDialog)
self.officialExtractionCheckBox.setObjectName(u"officialExtractionCheckBox")
self.officialExtractionCheckBox.setGeometry(QRect(620, 150, 411, 20))
Expand Down Expand Up @@ -145,6 +145,14 @@ def setupUi(self, OneKeyTranslateDialog):
self.unpackAllCheckBox.setObjectName(u"unpackAllCheckBox")
self.unpackAllCheckBox.setGeometry(QRect(30, 420, 561, 20))
self.unpackAllCheckBox.setChecked(False)
self.rtlCheckBox = QCheckBox(OneKeyTranslateDialog)
self.rtlCheckBox.setObjectName(u"rtlCheckBox")
self.rtlCheckBox.setGeometry(QRect(30, 570, 591, 20))
self.rtlCheckBox.setCursor(QCursor(Qt.ArrowCursor))
self.label_3 = QLabel(OneKeyTranslateDialog)
self.label_3.setObjectName(u"label_3")
self.label_3.setGeometry(QRect(30, 590, 591, 61))
self.label_3.setWordWrap(True)

self.retranslateUi(OneKeyTranslateDialog)

Expand Down Expand Up @@ -183,5 +191,10 @@ def retranslateUi(self, OneKeyTranslateDialog):
self.underlineCheckBox.setText(QCoreApplication.translate("OneKeyTranslateDialog", u"Skip extract the contents which include underline", None))
self.overwriteCheckBox.setText(QCoreApplication.translate("OneKeyTranslateDialog", u"Overwrite the rpy file if exsits", None))
self.unpackAllCheckBox.setText(QCoreApplication.translate("OneKeyTranslateDialog", u"Unpack all files (if disabled only script files will be unpacked)", None))
#if QT_CONFIG(tooltip)
self.rtlCheckBox.setToolTip("")
#endif // QT_CONFIG(tooltip)
self.rtlCheckBox.setText(QCoreApplication.translate("OneKeyTranslateDialog", u"Enable RTL (Right To Left)", None))
self.label_3.setText(QCoreApplication.translate("OneKeyTranslateDialog", u"(Fix reversed font problem for some languages like arabic, urdu)", None))
# retranslateUi

45 changes: 40 additions & 5 deletions src/one_key_translate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1039</width>
<height>679</height>
<height>762</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -163,7 +163,7 @@
<property name="geometry">
<rect>
<x>520</x>
<y>570</y>
<y>660</y>
<width>81</width>
<height>91</height>
</rect>
Expand All @@ -176,7 +176,7 @@
<property name="geometry">
<rect>
<x>30</x>
<y>600</y>
<y>690</y>
<width>71</width>
<height>31</height>
</rect>
Expand All @@ -192,7 +192,7 @@
<property name="geometry">
<rect>
<x>110</x>
<y>570</y>
<y>660</y>
<width>411</width>
<height>91</height>
</rect>
Expand Down Expand Up @@ -351,7 +351,7 @@
<x>620</x>
<y>420</y>
<width>401</width>
<height>241</height>
<height>331</height>
</rect>
</property>
<property name="text">
Expand Down Expand Up @@ -493,6 +493,41 @@
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox" name="rtlCheckBox">
<property name="geometry">
<rect>
<x>30</x>
<y>570</y>
<width>591</width>
<height>20</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Enable RTL (Right To Left)</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>30</x>
<y>590</y>
<width>591</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>(Fix reversed font problem for some languages like arabic, urdu)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
<connections/>
Expand Down
Loading

0 comments on commit 467818c

Please sign in to comment.