Update font description and add native font dialog setting to config

This commit is contained in:
Veronica Berglyd Olsen
2024-05-22 23:31:28 +02:00
parent cc32674b0f
commit 1fe7ca3db8
4 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -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"
+3 -1
View File
@@ -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),
}
@@ -9,6 +9,7 @@ localisation = en_GB
hidevscroll = False
hidehscroll = False
lastnotes = 0x0
nativefont = True
lastpath =
[Sizes]
+2 -1
View File
@@ -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