diff --git a/novelwriter/config.py b/novelwriter/config.py index ee85b1f1..44daf01f 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -392,13 +392,14 @@ class Config: self.textFont = QFont() self.textFont.fromString(value) else: - font = QFont() fontDB = QFontDatabase() fontFam = fontDB.families() if self.osWindows and "Arial" in fontFam: + font = QFont() font.setFamily("Arial") font.setPointSize(12) elif self.osDarwin and "Helvetica" in fontFam: + font = QFont() font.setFamily("Helvetica") font.setPointSize(12) else: @@ -587,21 +588,14 @@ class Config: # Main sec = "Main" - self.guiTheme = conf.rdStr(sec, "theme", self.guiTheme) - self.guiSyntax = conf.rdStr(sec, "syntax", self.guiSyntax) - guiFont = conf.rdStr(sec, "font", "") - self.guiLocale = conf.rdStr(sec, "localisation", self.guiLocale) - 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._lastPath = conf.rdPath(sec, "lastpath", self._lastPath) - - # If we have an old config file, we have an explicit font size, - # in which case we convert the old settings. - if fontSize := conf.rdInt(sec, "fontsize", 0): - guiFont = f"{guiFont},{fontSize}" - - self.setGuiFont(guiFont) + self.setGuiFont(conf.rdStr(sec, "font", "")) + self.guiTheme = conf.rdStr(sec, "theme", self.guiTheme) + self.guiSyntax = conf.rdStr(sec, "syntax", self.guiSyntax) + self.guiLocale = conf.rdStr(sec, "localisation", self.guiLocale) + 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._lastPath = conf.rdPath(sec, "lastpath", self._lastPath) # Sizes sec = "Sizes" @@ -623,7 +617,7 @@ class Config: # Editor sec = "Editor" - textFont = conf.rdStr(sec, "textfont", "") + self.setTextFont(conf.rdStr(sec, "textfont", "")) self.textWidth = conf.rdInt(sec, "width", self.textWidth) self.textMargin = conf.rdInt(sec, "margin", self.textMargin) self.tabWidth = conf.rdInt(sec, "tabwidth", self.tabWidth) @@ -662,13 +656,6 @@ class Config: self.stopWhenIdle = conf.rdBool(sec, "stopwhenidle", self.stopWhenIdle) self.userIdleTime = conf.rdInt(sec, "useridletime", self.userIdleTime) - # If we have an old config file, we have an explicit font size, - # in which case we convert the old settings. - if textSize := conf.rdInt(sec, "textsize", 0): - textFont = f"{textFont},{textSize}" - - self.setTextFont(textFont) - # State sec = "State" self.showViewerPanel = conf.rdBool(sec, "showviewerpanel", self.showViewerPanel) @@ -710,9 +697,9 @@ class Config: } conf["Main"] = { + "font": self.guiFont.toString(), "theme": str(self.guiTheme), "syntax": str(self.guiSyntax), - "guifont": str(self.guiFont.toString()), "localisation": str(self.guiLocale), "hidevscroll": str(self.hideVScroll), "hidehscroll": str(self.hideHScroll), @@ -739,7 +726,7 @@ class Config: } conf["Editor"] = { - "textfont": str(self.textFont.toString()), + "textfont": self.textFont.toString(), "width": str(self.textWidth), "margin": str(self.textMargin), "tabwidth": str(self.tabWidth), diff --git a/novelwriter/core/buildsettings.py b/novelwriter/core/buildsettings.py index 13f4cc07..f7392e26 100644 --- a/novelwriter/core/buildsettings.py +++ b/novelwriter/core/buildsettings.py @@ -76,7 +76,7 @@ SETTINGS_TEMPLATE = { "text.includeBodyText": (bool, True), "text.ignoredKeywords": (str, ""), "text.addNoteHeadings": (bool, True), - "format.textFont": (str, CONFIG.textFont), + "format.textFont": (str, CONFIG.textFont.family()), "format.textSize": (int, 12), "format.lineHeight": (float, 1.15, 0.75, 3.0), "format.justifyText": (bool, False), diff --git a/novelwriter/core/docbuild.py b/novelwriter/core/docbuild.py index 86187b4a..403137fb 100644 --- a/novelwriter/core/docbuild.py +++ b/novelwriter/core/docbuild.py @@ -288,7 +288,7 @@ class NWBuildDocument: textFont = self._build.getStr("format.textFont") textSize = self._build.getInt("format.textSize") - fontFamily = textFont or CONFIG.textFont + fontFamily = textFont or CONFIG.textFont.family() bldFont = QFont(fontFamily, textSize) fontInfo = QFontInfo(bldFont) textFixed = fontInfo.fixedPitch() diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 096cc337..3158fa24 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -881,9 +881,9 @@ class GuiPreferences(QDialog): CONFIG.guiLocale = guiLocale CONFIG.guiTheme = guiTheme - CONFIG.guiFont = self._guiFont CONFIG.hideVScroll = self.hideVScroll.isChecked() CONFIG.hideHScroll = self.hideHScroll.isChecked() + CONFIG.setGuiFont(self._guiFont) # Document Style guiSyntax = self.guiSyntax.currentData() @@ -896,7 +896,7 @@ class GuiPreferences(QDialog): CONFIG.emphLabels = emphLabels CONFIG.showFullPath = self.showFullPath.isChecked() CONFIG.incNotesWCount = self.incNotesWCount.isChecked() - CONFIG.textFont = self._textFont + CONFIG.setTextFont(self._textFont) # Auto Save CONFIG.autoSaveDoc = self.autoSaveDoc.value() diff --git a/novelwriter/tools/manuscript.py b/novelwriter/tools/manuscript.py index 5c39b7a5..ca19e6d0 100644 --- a/novelwriter/tools/manuscript.py +++ b/novelwriter/tools/manuscript.py @@ -787,7 +787,7 @@ class _PreviewWidget(QTextBrowser): self._updateDocMargins() self._updateBuildAge() - self.setTextFont(CONFIG.textFont, CONFIG.textSize) + self.setTextFont(CONFIG.textFont.family(), CONFIG.textFont.pointSize()) # Age Timer self.ageTimer = QTimer(self) diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index 963da221..dca739f9 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -1175,7 +1175,7 @@ class _FormatTab(NScrollableForm): """Populate the widgets.""" textFont = self._build.getStr("format.textFont") if not textFont: - textFont = str(CONFIG.textFont) + textFont = str(CONFIG.textFont.family()) self.textFont.setText(textFont) self.textSize.setValue(self._build.getInt("format.textSize"))