diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index d7bedf8a..c7554591 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -319,10 +319,10 @@ class GuiDocEditor(QPlainTextEdit): SHARED.updateSpellCheckLanguage() # Set font - textFont = QFont() - textFont.setFamily(CONFIG.textFont) - textFont.setPointSize(CONFIG.textSize) - self.setFont(textFont) + font = QFont() + font.setFamily(CONFIG.textFont) + font.setPointSize(CONFIG.textSize) + self.setFont(font) # Set default text margins # Due to cursor visibility, a part of the margin must be @@ -358,13 +358,14 @@ class GuiDocEditor(QPlainTextEdit): # Refresh the tab stops self.setTabStopDistance(CONFIG.getTabWidth()) - # If we have a document open, we should reload it in case the + # If we have a document open, we should refresh it in case the # font changed, otherwise we just clear the editor entirely, # which makes it read only. - if self._docHandle is None: - self.clearEditor() - else: + if self._docHandle: self._qDocument.syntaxHighlighter.rehighlight() + self.docHeader.setTitleFromHandle(self._docHandle) + else: + self.clearEditor() return diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index dc0562d3..5a066ccc 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -142,10 +142,10 @@ class GuiDocViewer(QTextBrowser): self._makeStyleSheet() # Set Font - textFont = QFont() - textFont.setFamily(CONFIG.textFont) - textFont.setPointSize(CONFIG.textSize) - self.setFont(textFont) + font = QFont() + font.setFamily(CONFIG.textFont) + font.setPointSize(CONFIG.textSize) + self.setFont(font) # Set the widget colours to match syntax theme mainPalette = self.palette() @@ -164,10 +164,10 @@ class GuiDocViewer(QTextBrowser): # Set default text margins self.document().setDocumentMargin(0) - theOpt = QTextOption() + options = QTextOption() if CONFIG.doJustify: - theOpt.setAlignment(Qt.AlignmentFlag.AlignJustify) - self.document().setDefaultTextOption(theOpt) + options.setAlignment(Qt.AlignmentFlag.AlignJustify) + self.document().setDefaultTextOption(options) # Scroll bars if CONFIG.hideVScroll: