Move all code to set default text font into the Config class

This commit is contained in:
Veronica Berglyd Olsen
2023-05-31 17:49:31 +02:00
parent 74f46f4633
commit 704fffada3
13 changed files with 62 additions and 63 deletions
+5 -20
View File
@@ -276,31 +276,16 @@ class GuiDocEditor(QTextEdit):
self.setDictionaries()
# Set font
theFont = QFont()
qDoc = self.document()
if CONFIG.textFont is None:
# If none is defined, set a default font
theFont = QFont()
if CONFIG.osWindows and "Arial" in self.mainTheme.guiFontDB.families():
theFont.setFamily("Arial")
theFont.setPointSize(12)
elif CONFIG.osDarwin and "Courier" in self.mainTheme.guiFontDB.families():
theFont.setFamily("Courier")
theFont.setPointSize(12)
else:
theFont = qDoc.defaultFont()
CONFIG.textFont = theFont.family()
CONFIG.textSize = theFont.pointSize()
theFont.setFamily(CONFIG.textFont)
theFont.setPointSize(CONFIG.textSize)
self.setFont(theFont)
textFont = QFont()
textFont.setFamily(CONFIG.textFont)
textFont.setPointSize(CONFIG.textSize)
self.setFont(textFont)
# Set default text margins
# Due to cursor visibility, a part of the margin must be
# allocated to the document itself. See issue #1112.
cW = self.cursorWidth()
qDoc = self.document()
qDoc.setDocumentMargin(cW)
self._vpMargin = max(CONFIG.getTextMargin() - cW, 0)
self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)