Fix font matching style bug (#2503)

This commit is contained in:
Veronica Berglyd Olsen
2025-08-24 15:51:32 +02:00
committed by GitHub
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -445,6 +445,7 @@ def fontMatcher(font: QFont) -> QFont:
default Qt font matching algorithm doesn't handle well changing
application fonts at runtime.
"""
font.setStyleName(None) # Make sure no font style name is set from config, see #2502
info = QFontInfo(font)
if (famRequest := font.family()) != (famActual := info.family()):
logger.warning("Font mismatch: Requested '%s', but got '%s'", famRequest, famActual)
+5
View File
@@ -537,6 +537,11 @@ def testBaseCommon_fontMatcher(monkeypatch):
nonsense = QFont("nonesense", 10)
assert fontMatcher(nonsense) is nonsense
# Style is reset
nonsense.setStyleName("blabla")
assert nonsense.styleName() == "blabla"
assert fontMatcher(nonsense).styleName() == ""
# General font
if len(QFontDatabase.families()) > 1:
fontOne = QFont(QFontDatabase.families()[0])