From 65d2a3b3131a1b8f37d92440f9ff31ce44cfce8f Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 21 Aug 2025 22:41:58 +0200 Subject: [PATCH 1/2] Reset font style name after loading fonts --- novelwriter/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/novelwriter/common.py b/novelwriter/common.py index 83a364bf..f03fa823 100644 --- a/novelwriter/common.py +++ b/novelwriter/common.py @@ -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) From b484dd6f7156f83f02e04752f0f88e139310b12c Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 24 Aug 2025 15:47:28 +0200 Subject: [PATCH 2/2] Test the fontMatcher style name reset --- tests/test_base/test_base_common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index 76a11bd7..a46f02d0 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -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])