Move all code to set default text font into the Config class
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -114,13 +114,10 @@ class GuiDocViewer(QTextBrowser):
|
||||
self._makeStyleSheet()
|
||||
|
||||
# Set Font
|
||||
theFont = QFont()
|
||||
if CONFIG.textFont is None:
|
||||
# If none is defined, set the default back to config
|
||||
CONFIG.textFont = self.document().defaultFont().family()
|
||||
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 the widget colours to match syntax theme
|
||||
mainPalette = self.palette()
|
||||
|
||||
@@ -107,7 +107,6 @@ class GuiTheme:
|
||||
# ===========
|
||||
|
||||
# Init GUI Font
|
||||
self.guiFontDB = QFontDatabase()
|
||||
self._setGuiFont()
|
||||
|
||||
# Load Themes
|
||||
@@ -366,13 +365,14 @@ class GuiTheme:
|
||||
"""Update the GUI's font style from settings.
|
||||
"""
|
||||
theFont = QFont()
|
||||
if CONFIG.guiFont not in self.guiFontDB.families():
|
||||
if CONFIG.osWindows and "Arial" in self.guiFontDB.families():
|
||||
fontDB = QFontDatabase()
|
||||
if CONFIG.guiFont not in fontDB.families():
|
||||
if CONFIG.osWindows and "Arial" in fontDB.families():
|
||||
# On Windows we default to Arial if possible
|
||||
theFont.setFamily("Arial")
|
||||
theFont.setPointSize(10)
|
||||
else:
|
||||
theFont = self.guiFontDB.systemFont(QFontDatabase.GeneralFont)
|
||||
theFont = fontDB.systemFont(QFontDatabase.GeneralFont)
|
||||
CONFIG.guiFont = theFont.family()
|
||||
CONFIG.guiFontSize = theFont.pointSize()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user