Skip to content

Commit 30fa83d

Browse files
authored
Merge pull request #185 from SECTL/copilot/fix-font-display-issue
Fix font weight lost on system fonts due to shared QFont mutation
2 parents ef013df + c832c62 commit 30fa83d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

app/core/font_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _apply_system_font(font_family: str, font_weight: int) -> str:
114114
current_font.family() != font_family
115115
or current_font.weight() != app_font.weight()
116116
):
117-
new_font = app_font
117+
new_font = QFont(app_font) # 创建新的字体对象,保留字重
118118
new_font.setBold(current_font.bold())
119119
new_font.setItalic(current_font.italic())
120120
widget.setFont(new_font)
@@ -185,7 +185,7 @@ def apply_font_to_application(font_family: str) -> None:
185185
font_family: 字体家族名称
186186
"""
187187
current_font = QApplication.font()
188-
app_font = current_font
188+
app_font = QFont(current_font) # 创建新的字体对象,保留原有属性
189189
app_font.setFamily(font_family)
190190

191191
widgets_updated = 0
@@ -225,7 +225,7 @@ def update_widget_fonts(widget: Optional[QWidget], font, font_family: str) -> bo
225225
if current_widget_font.family() == font_family:
226226
return False
227227

228-
new_font = font
228+
new_font = QFont(font) # 创建新的字体对象,保留字重等属性
229229
new_font.setBold(current_widget_font.bold())
230230
new_font.setItalic(current_widget_font.italic())
231231
widget.setFont(new_font)

0 commit comments

Comments
 (0)