From 1fe7ca3db82e7e1470b24c46556d9eb1d2e2a345 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 22 May 2024 23:31:28 +0200 Subject: [PATCH] Update font description and add native font dialog setting to config --- novelwriter/common.py | 4 +++- novelwriter/config.py | 4 +++- tests/reference/baseConfig_novelwriter.conf | 1 + tests/test_base/test_base_common.py | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/novelwriter/common.py b/novelwriter/common.py index 70c4ce27..0ef07541 100644 --- a/novelwriter/common.py +++ b/novelwriter/common.py @@ -405,7 +405,9 @@ def describeFont(font: QFont) -> str: """Describe a font in a way that can be displayed on the GUI.""" if isinstance(font, QFont): info = QFontInfo(font) - return f"{font.family()} {info.styleName()} @ {font.pointSize()} pt" + family = info.family() + styles = [v for v in info.styleName().split() if v not in family] + return " ".join([f"{info.pointSize()} pt", family] + styles) return "Error" diff --git a/novelwriter/config.py b/novelwriter/config.py index 90d25c13..148e75d4 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -114,7 +114,7 @@ class Config: self.hideVScroll = False # Hide vertical scroll bars on main widgets self.hideHScroll = False # Hide horizontal scroll bars on main widgets self.lastNotes = "0x0" # The latest release notes that have been shown - self.nativeFont = False # Use native font dialog + self.nativeFont = True # Use native font dialog # Size Settings self._mainWinSize = [1200, 650] # Last size of the main GUI window @@ -599,6 +599,7 @@ class Config: self.hideVScroll = conf.rdBool(sec, "hidevscroll", self.hideVScroll) self.hideHScroll = conf.rdBool(sec, "hidehscroll", self.hideHScroll) self.lastNotes = conf.rdStr(sec, "lastnotes", self.lastNotes) + self.nativeFont = conf.rdBool(sec, "nativefont", self.nativeFont) self._lastPath = conf.rdPath(sec, "lastpath", self._lastPath) # Sizes @@ -708,6 +709,7 @@ class Config: "hidevscroll": str(self.hideVScroll), "hidehscroll": str(self.hideHScroll), "lastnotes": str(self.lastNotes), + "nativefont": str(self.nativeFont), "lastpath": str(self._lastPath), } diff --git a/tests/reference/baseConfig_novelwriter.conf b/tests/reference/baseConfig_novelwriter.conf index 99559ed8..0554bd6d 100644 --- a/tests/reference/baseConfig_novelwriter.conf +++ b/tests/reference/baseConfig_novelwriter.conf @@ -9,6 +9,7 @@ localisation = en_GB hidevscroll = False hidehscroll = False lastnotes = 0x0 +nativefont = True lastpath = [Sizes] diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index dba88e9b..5bf2d1db 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -492,7 +492,8 @@ def testBaseCommon_describeFont(): """Test the describeFont function.""" fontDB = QFontDatabase() font = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont) - assert font.family() in describeFont(font) + font.setPointSize(12) + assert describeFont(font).startswith("12 pt") assert describeFont(None) == "Error" # type: ignore