From 5b0a6f05ed6246a5561edfa3c66c33fb5e3420be Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Sun, 19 May 2024 21:47:53 +0200
Subject: [PATCH 1/5] Fix enchant folder missing bug for dictionaries tool
(#1874)
---
novelwriter/tools/dictionaries.py | 9 +++----
tests/test_tools/test_tools_dictionaries.py | 26 +++++++++++----------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/novelwriter/tools/dictionaries.py b/novelwriter/tools/dictionaries.py
index a2607e63..7625dbe3 100644
--- a/novelwriter/tools/dictionaries.py
+++ b/novelwriter/tools/dictionaries.py
@@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
)
from novelwriter import CONFIG, SHARED
-from novelwriter.common import formatFileFilter, openExternalPath, formatInt, getFileSize
+from novelwriter.common import formatFileFilter, formatInt, getFileSize, openExternalPath
from novelwriter.error import formatException
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.types import QtDialogClose
@@ -143,11 +143,12 @@ class GuiDictionaries(QDialog):
try:
import enchant
path = Path(enchant.get_user_config_dir())
+ self._installPath = Path(path).resolve()
+ self._installPath.mkdir(exist_ok=True, parents=True)
except Exception:
logger.error("Could not get enchant path")
return False
- self._installPath = Path(path).resolve()
if path.is_dir():
self.inPath.setText(str(path))
hunspell = path / "hunspell"
@@ -199,9 +200,9 @@ class GuiDictionaries(QDialog):
if self._installPath:
temp = self.huInput.text()
if temp and (path := Path(temp)).is_file():
- hunspell = self._installPath / "hunspell"
- hunspell.mkdir(exist_ok=True)
try:
+ hunspell = self._installPath / "hunspell"
+ hunspell.mkdir(exist_ok=True)
nAff, nDic = self._extractDicts(path, hunspell)
if nAff == 0 or nDic == 0:
self._appendLog(procErr, err=True)
diff --git a/tests/test_tools/test_tools_dictionaries.py b/tests/test_tools/test_tools_dictionaries.py
index 9f11d51c..a110af80 100644
--- a/tests/test_tools/test_tools_dictionaries.py
+++ b/tests/test_tools/test_tools_dictionaries.py
@@ -20,12 +20,10 @@ along with this program. If not, see .
"""
from __future__ import annotations
-import pytest
-import enchant
-
from zipfile import ZipFile
-from mocked import causeException
+import enchant
+import pytest
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QFileDialog
@@ -33,11 +31,15 @@ from PyQt5.QtWidgets import QFileDialog
from novelwriter import SHARED
from novelwriter.tools.dictionaries import GuiDictionaries
+from tests.mocked import causeException
+
@pytest.mark.gui
def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
"""Test the Dictionaries downloader tool."""
- monkeypatch.setattr(enchant, "get_user_config_dir", lambda *a: str(fncPath))
+ # Must also create the enchant folder, see issue #1874
+ enchPath = fncPath / "enchant"
+ monkeypatch.setattr(enchant, "get_user_config_dir", lambda *a: str(enchPath))
# Fail to open
with monkeypatch.context() as mp:
@@ -52,7 +54,7 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
nwDicts = SHARED.findTopLevelWidget(GuiDictionaries)
assert isinstance(nwDicts, GuiDictionaries)
assert nwDicts.isVisible()
- assert nwDicts.inPath.text() == str(fncPath)
+ assert nwDicts.inPath.text() == str(enchPath)
# Allow Open Dir
SHARED._lastAlert = ""
@@ -98,9 +100,9 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
nwDicts._doBrowseHunspell()
assert nwDicts.huInput.text() == str(foDict)
nwDicts._doImportHunspell()
- assert (fncPath / "hunspell").is_dir()
- assert (fncPath / "hunspell" / "en_GB.aff").is_file()
- assert (fncPath / "hunspell" / "en_GB.dic").is_file()
+ assert (enchPath / "hunspell").is_dir()
+ assert (enchPath / "hunspell" / "en_GB.aff").is_file()
+ assert (enchPath / "hunspell" / "en_GB.dic").is_file()
assert nwDicts.infoBox.blockCount() == 3
# Import Libre Office Dictionary
@@ -109,9 +111,9 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
nwDicts._doBrowseHunspell()
assert nwDicts.huInput.text() == str(loDict)
nwDicts._doImportHunspell()
- assert (fncPath / "hunspell").is_dir()
- assert (fncPath / "hunspell" / "en_US.aff").is_file()
- assert (fncPath / "hunspell" / "en_US.dic").is_file()
+ assert (enchPath / "hunspell").is_dir()
+ assert (enchPath / "hunspell" / "en_US.aff").is_file()
+ assert (enchPath / "hunspell" / "en_US.dic").is_file()
assert nwDicts.infoBox.blockCount() == 5
# Handle Unreadable File
From 09b51badd40090091d4a82fcc4f790661d1da7fe Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Mon, 20 May 2024 11:17:23 +0200
Subject: [PATCH 2/5] Add an explicit font setting function for text editor
that covers all font settings
---
novelwriter/gui/doceditor.py | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index bfd0be9a..3db8fca2 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -43,8 +43,8 @@ from PyQt5.QtCore import (
pyqtSignal, pyqtSlot
)
from PyQt5.QtGui import (
- QColor, QCursor, QFont, QKeyEvent, QKeySequence, QMouseEvent, QPalette,
- QPixmap, QResizeEvent, QTextBlock, QTextCursor, QTextDocument, QTextOption
+ QColor, QCursor, QKeyEvent, QKeySequence, QMouseEvent, QPalette, QPixmap,
+ QResizeEvent, QTextBlock, QTextCursor, QTextDocument, QTextOption
)
from PyQt5.QtWidgets import (
QAction, QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit,
@@ -329,10 +329,7 @@ class GuiDocEditor(QPlainTextEdit):
SHARED.updateSpellCheckLanguage()
# Set font
- font = QFont()
- font.setFamily(CONFIG.textFont)
- font.setPointSize(CONFIG.textSize)
- self._qDocument.setDefaultFont(font)
+ self.initFont()
# Update highlighter settings
self._qDocument.syntaxHighlighter.initHighlighter()
@@ -382,6 +379,29 @@ class GuiDocEditor(QPlainTextEdit):
return
+ def initFont(self) -> None:
+ """Set the font of the widget and document. This needs special
+ attention since there appears to be a bug in Qt 5.15.3. See
+ issues #1862 and #1875.
+ """
+ wFont = self.font()
+ wFont.setFamily(CONFIG.textFont)
+ wFont.setPointSize(CONFIG.textSize)
+
+ dFont = self._qDocument.defaultFont()
+ dFont.setFamily(CONFIG.textFont)
+ dFont.setPointSize(CONFIG.textSize)
+
+ self.setFont(wFont)
+ self._qDocument.setDefaultFont(dFont)
+
+ # Reset sub-widget font to GUI font
+ self.docHeader.setFont(SHARED.theme.guiFont)
+ self.docFooter.setFont(SHARED.theme.guiFont)
+ self.docSearch.setFont(SHARED.theme.guiFont)
+
+ return
+
def loadText(self, tHandle: str, tLine: int | None = None) -> bool:
"""Load text from a document into the editor. If we have an I/O
error, we must handle this and clear the editor so that we don't
From cb19475409e8f4e7d43a3f03a3c6f89d0b078ae4 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Mon, 20 May 2024 11:36:30 +0200
Subject: [PATCH 3/5] Add font init to viewer, and update manuscript tool
preview
---
novelwriter/gui/doceditor.py | 20 +++++++-------------
novelwriter/gui/docviewer.py | 28 ++++++++++++++++++----------
novelwriter/tools/manuscript.py | 15 ++++++++++-----
3 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index 3db8fca2..cc3ea2c3 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -380,20 +380,14 @@ class GuiDocEditor(QPlainTextEdit):
return
def initFont(self) -> None:
- """Set the font of the widget and document. This needs special
- attention since there appears to be a bug in Qt 5.15.3. See
- issues #1862 and #1875.
+ """Set the font of the main widget and sub-widgets. This needs
+ special attention since there appears to be a bug in Qt 5.15.3.
+ See issues #1862 and #1875.
"""
- wFont = self.font()
- wFont.setFamily(CONFIG.textFont)
- wFont.setPointSize(CONFIG.textSize)
-
- dFont = self._qDocument.defaultFont()
- dFont.setFamily(CONFIG.textFont)
- dFont.setPointSize(CONFIG.textSize)
-
- self.setFont(wFont)
- self._qDocument.setDefaultFont(dFont)
+ font = self.font()
+ font.setFamily(CONFIG.textFont)
+ font.setPointSize(CONFIG.textSize)
+ self.setFont(font)
# Reset sub-widget font to GUI font
self.docHeader.setFont(SHARED.theme.guiFont)
diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py
index f5fbec42..d5e0fcdd 100644
--- a/novelwriter/gui/docviewer.py
+++ b/novelwriter/gui/docviewer.py
@@ -31,10 +31,7 @@ import logging
from enum import Enum
from PyQt5.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot
-from PyQt5.QtGui import (
- QCursor, QFont, QMouseEvent, QPalette, QResizeEvent, QTextCursor,
- QTextOption
-)
+from PyQt5.QtGui import QCursor, QMouseEvent, QPalette, QResizeEvent, QTextCursor, QTextOption
from PyQt5.QtWidgets import (
QAction, QApplication, QFrame, QHBoxLayout, QLabel, QMenu, QTextBrowser,
QToolButton, QWidget
@@ -141,12 +138,7 @@ class GuiDocViewer(QTextBrowser):
def initViewer(self) -> None:
"""Set editor settings from main config."""
self._makeStyleSheet()
-
- # Set Font
- font = QFont()
- font.setFamily(CONFIG.textFont)
- font.setPointSize(CONFIG.textSize)
- self.document().setDefaultFont(font)
+ self.initFont()
# Set the widget colours to match syntax theme
mainPalette = self.palette()
@@ -189,6 +181,22 @@ class GuiDocViewer(QTextBrowser):
return
+ def initFont(self) -> None:
+ """Set the font of the main widget and sub-widgets. This needs
+ special attention since there appears to be a bug in Qt 5.15.3.
+ See issues #1862 and #1875.
+ """
+ font = self.font()
+ font.setFamily(CONFIG.textFont)
+ font.setPointSize(CONFIG.textSize)
+ self.setFont(font)
+
+ # Reset sub-widget font to GUI font
+ self.docHeader.setFont(SHARED.theme.guiFont)
+ self.docFooter.setFont(SHARED.theme.guiFont)
+
+ return
+
def loadText(self, tHandle: str, updateHistory: bool = True) -> bool:
"""Load text into the viewer from an item handle."""
if not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):
diff --git a/novelwriter/tools/manuscript.py b/novelwriter/tools/manuscript.py
index 17909a8d..376d8a6a 100644
--- a/novelwriter/tools/manuscript.py
+++ b/novelwriter/tools/manuscript.py
@@ -31,7 +31,7 @@ from time import time
from typing import TYPE_CHECKING
from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot
-from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
+from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QPalette, QResizeEvent
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
from PyQt5.QtWidgets import (
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
@@ -831,12 +831,17 @@ class _PreviewWidget(QTextBrowser):
return
def setTextFont(self, family: str, size: int) -> None:
- """Set the text font properties."""
- if family:
- font = QFont()
+ """Set the text font properties and then reset for sub-widgets.
+ This needs special attention since there appears to be a bug in
+ Qt 5.15.3. See issues #1862 and #1875.
+ """
+ if family and size > 4:
+ font = self.font()
font.setFamily(family)
font.setPointSize(size)
- self.document().setDefaultFont(font)
+ self.setFont(font)
+ self.ageLabel.setFont(SHARED.theme.guiFont)
+ self.buildProgress.setFont(SHARED.theme.guiFont)
return
##
From 9388ce6a46a30b77abf261c9b2c969503c81baef Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Mon, 20 May 2024 12:00:19 +0200
Subject: [PATCH 4/5] Fix support for 90% font
---
novelwriter/gui/doceditor.py | 57 ++++++++++++++++++++-------------
novelwriter/gui/docviewer.py | 30 +++++++++--------
novelwriter/gui/theme.py | 6 ++--
novelwriter/tools/manuscript.py | 5 +--
4 files changed, 58 insertions(+), 40 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index cc3ea2c3..c50b327d 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -390,9 +390,9 @@ class GuiDocEditor(QPlainTextEdit):
self.setFont(font)
# Reset sub-widget font to GUI font
- self.docHeader.setFont(SHARED.theme.guiFont)
- self.docFooter.setFont(SHARED.theme.guiFont)
- self.docSearch.setFont(SHARED.theme.guiFont)
+ self.docHeader.updateFont()
+ self.docFooter.updateFont()
+ self.docSearch.updateFont()
return
@@ -2410,9 +2410,6 @@ class GuiDocEditSearch(QFrame):
iSz = SHARED.theme.baseIconSize
mPx = CONFIG.pxInt(6)
- self.boxFont = SHARED.theme.guiFont
- self.boxFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
-
self.setContentsMargins(0, 0, 0, 0)
self.setAutoFillBackground(True)
self.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
@@ -2424,12 +2421,10 @@ class GuiDocEditSearch(QFrame):
# ==========
self.searchBox = QLineEdit(self)
- self.searchBox.setFont(self.boxFont)
self.searchBox.setPlaceholderText(self.tr("Search for"))
self.searchBox.returnPressed.connect(self._doSearch)
self.replaceBox = QLineEdit(self)
- self.replaceBox.setFont(self.boxFont)
self.replaceBox.setPlaceholderText(self.tr("Replace with"))
self.replaceBox.returnPressed.connect(self._doReplace)
@@ -2439,12 +2434,9 @@ class GuiDocEditSearch(QFrame):
self.searchOpt.setContentsMargins(0, 0, 0, 0)
self.searchLabel = QLabel(self.tr("Search"), self)
- self.searchLabel.setFont(self.boxFont)
self.searchLabel.setIndent(CONFIG.pxInt(6))
self.resultLabel = QLabel("?/?", self)
- self.resultLabel.setFont(self.boxFont)
- self.resultLabel.setMinimumWidth(SHARED.theme.getTextWidth("?/?", self.boxFont))
self.toggleCase = QAction(self.tr("Case Sensitive"), self)
self.toggleCase.setCheckable(True)
@@ -2529,6 +2521,7 @@ class GuiDocEditSearch(QFrame):
self.replaceButton.setVisible(False)
self.adjustSize()
+ self.updateFont()
self.updateTheme()
logger.debug("Ready: GuiDocEditSearch")
@@ -2612,7 +2605,9 @@ class GuiDocEditSearch(QFrame):
numCount = f"{lim:n}+" if (resCount or 0) > lim else f"{resCount:n}"
sCurrRes = "?" if currRes is None else str(currRes)
sResCount = "?" if resCount is None else numCount
- minWidth = SHARED.theme.getTextWidth(f"{sResCount}//{sResCount}", self.boxFont)
+ minWidth = SHARED.theme.getTextWidth(
+ f"{sResCount}//{sResCount}", SHARED.theme.guiFontSmall
+ )
self.resultLabel.setText(f"{sCurrRes}/{sResCount}")
self.resultLabel.setMinimumWidth(minWidth)
self.adjustSize()
@@ -2623,6 +2618,18 @@ class GuiDocEditSearch(QFrame):
# Methods
##
+ def updateFont(self) -> None:
+ """Update the font settings."""
+ self.setFont(SHARED.theme.guiFont)
+ self.searchBox.setFont(SHARED.theme.guiFontSmall)
+ self.replaceBox.setFont(SHARED.theme.guiFontSmall)
+ self.searchLabel.setFont(SHARED.theme.guiFontSmall)
+ self.resultLabel.setFont(SHARED.theme.guiFontSmall)
+ self.resultLabel.setMinimumWidth(
+ SHARED.theme.getTextWidth("?/?", SHARED.theme.guiFontSmall)
+ )
+ return
+
def updateTheme(self) -> None:
"""Update theme elements."""
qPalette = QApplication.palette()
@@ -2807,10 +2814,6 @@ class GuiDocEditHeader(QWidget):
self.itemTitle.setAlignment(QtAlignCenterTop)
self.itemTitle.setFixedHeight(iPx)
- lblFont = self.itemTitle.font()
- lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
- self.itemTitle.setFont(lblFont)
-
# Other Widgets
self.outlineMenu = QMenu(self)
@@ -2864,6 +2867,7 @@ class GuiDocEditHeader(QWidget):
self.setContentsMargins(0, 0, 0, 0)
self.setMinimumHeight(iPx + 2*mPx)
+ self.updateFont()
self.updateTheme()
logger.debug("Ready: GuiDocEditHeader")
@@ -2902,6 +2906,12 @@ class GuiDocEditHeader(QWidget):
logger.debug("Document outline updated in %.3f ms", 1000*(time() - tStart))
return
+ def updateFont(self) -> None:
+ """Update the font settings."""
+ self.setFont(SHARED.theme.guiFont)
+ self.itemTitle.setFont(SHARED.theme.guiFontSmall)
+ return
+
def updateTheme(self) -> None:
"""Update theme elements."""
self.tbButton.setThemeIcon("menu")
@@ -3015,9 +3025,6 @@ class GuiDocEditFooter(QWidget):
bSp = CONFIG.pxInt(4)
hSp = CONFIG.pxInt(6)
- lblFont = self.font()
- lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
-
# Cached Translations
self._trLineCount = self.tr("Line: {0} ({1})")
self._trWordCount = self.tr("Words: {0} ({1})")
@@ -3040,7 +3047,6 @@ class GuiDocEditFooter(QWidget):
self.statusText.setAutoFillBackground(True)
self.statusText.setFixedHeight(fPx)
self.statusText.setAlignment(QtAlignLeftTop)
- self.statusText.setFont(lblFont)
# Lines
self.linesIcon = QLabel("", self)
@@ -3055,7 +3061,6 @@ class GuiDocEditFooter(QWidget):
self.linesText.setAutoFillBackground(True)
self.linesText.setFixedHeight(fPx)
self.linesText.setAlignment(QtAlignLeftTop)
- self.linesText.setFont(lblFont)
# Words
self.wordsIcon = QLabel("", self)
@@ -3070,7 +3075,6 @@ class GuiDocEditFooter(QWidget):
self.wordsText.setAutoFillBackground(True)
self.wordsText.setFixedHeight(fPx)
self.wordsText.setAlignment(QtAlignLeftTop)
- self.wordsText.setFont(lblFont)
# Assemble Layout
self.outerBox = QHBoxLayout()
@@ -3093,6 +3097,7 @@ class GuiDocEditFooter(QWidget):
self.setMinimumHeight(fPx + 2*mPx)
# Fix the Colours
+ self.updateFont()
self.updateTheme()
# Initialise Info
@@ -3106,6 +3111,14 @@ class GuiDocEditFooter(QWidget):
# Methods
##
+ def updateFont(self) -> None:
+ """Update the font settings."""
+ self.setFont(SHARED.theme.guiFont)
+ self.statusText.setFont(SHARED.theme.guiFontSmall)
+ self.linesText.setFont(SHARED.theme.guiFontSmall)
+ self.wordsText.setFont(SHARED.theme.guiFontSmall)
+ return
+
def updateTheme(self) -> None:
"""Update theme elements."""
iPx = round(0.9*SHARED.theme.baseIconHeight)
diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py
index d5e0fcdd..afaeb366 100644
--- a/novelwriter/gui/docviewer.py
+++ b/novelwriter/gui/docviewer.py
@@ -192,8 +192,8 @@ class GuiDocViewer(QTextBrowser):
self.setFont(font)
# Reset sub-widget font to GUI font
- self.docHeader.setFont(SHARED.theme.guiFont)
- self.docFooter.setFont(SHARED.theme.guiFont)
+ self.docHeader.updateFont()
+ self.docFooter.updateFont()
return
@@ -654,10 +654,6 @@ class GuiDocViewHeader(QWidget):
self.itemTitle.setAlignment(QtAlignCenterTop)
self.itemTitle.setFixedHeight(iPx)
- lblFont = self.itemTitle.font()
- lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
- self.itemTitle.setFont(lblFont)
-
# Other Widgets
self.outlineMenu = QMenu(self)
@@ -708,7 +704,7 @@ class GuiDocViewHeader(QWidget):
self.outerBox.setContentsMargins(mPx, mPx, mPx, mPx)
self.setMinimumHeight(iPx + 2*mPx)
- # Fix the Colours
+ self.updateFont()
self.updateTheme()
logger.debug("Ready: GuiDocViewHeader")
@@ -753,6 +749,12 @@ class GuiDocViewHeader(QWidget):
self._docOutline = data
return
+ def updateFont(self) -> None:
+ """Update the font settings."""
+ self.setFont(SHARED.theme.guiFont)
+ self.itemTitle.setFont(SHARED.theme.guiFontSmall)
+ return
+
def updateTheme(self) -> None:
"""Update theme elements."""
self.outlineButton.setThemeIcon("list")
@@ -894,11 +896,6 @@ class GuiDocViewFooter(QWidget):
self.showSynopsis.toggled.connect(self._doToggleSynopsis)
self.showSynopsis.setToolTip(self.tr("Show Synopsis Comments"))
- lblFont = self.font()
- lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
- self.showComments.setFont(lblFont)
- self.showSynopsis.setFont(lblFont)
-
# Assemble Layout
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.showHide, 0)
@@ -914,7 +911,7 @@ class GuiDocViewFooter(QWidget):
self.outerBox.setContentsMargins(mPx, mPx, mPx, mPx)
self.setMinimumHeight(iPx + 2*mPx)
- # Fix the Colours
+ self.updateFont()
self.updateTheme()
logger.debug("Ready: GuiDocViewFooter")
@@ -925,6 +922,13 @@ class GuiDocViewFooter(QWidget):
# Methods
##
+ def updateFont(self) -> None:
+ """Update the font settings."""
+ self.setFont(SHARED.theme.guiFont)
+ self.showComments.setFont(SHARED.theme.guiFontSmall)
+ self.showSynopsis.setFont(SHARED.theme.guiFontSmall)
+ return
+
def updateTheme(self) -> None:
"""Update theme elements."""
# Icons
diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py
index c13283f4..6af30b8d 100644
--- a/novelwriter/gui/theme.py
+++ b/novelwriter/gui/theme.py
@@ -30,9 +30,7 @@ from math import ceil
from pathlib import Path
from PyQt5.QtCore import QSize, Qt
-from PyQt5.QtGui import (
- QPalette, QColor, QIcon, QFont, QFontMetrics, QFontDatabase, QPixmap
-)
+from PyQt5.QtGui import QColor, QFont, QFontDatabase, QFontMetrics, QIcon, QPalette, QPixmap
from PyQt5.QtWidgets import QApplication
from novelwriter import CONFIG
@@ -154,6 +152,8 @@ class GuiTheme:
self.guiFont = QApplication.font()
self.guiFontB = QApplication.font()
self.guiFontB.setBold(True)
+ self.guiFontSmall = QApplication.font()
+ self.guiFontSmall.setPointSizeF(0.9*self.guiFont.pointSizeF())
qMetric = QFontMetrics(self.guiFont)
fHeight = qMetric.height()
diff --git a/novelwriter/tools/manuscript.py b/novelwriter/tools/manuscript.py
index 376d8a6a..12ca8212 100644
--- a/novelwriter/tools/manuscript.py
+++ b/novelwriter/tools/manuscript.py
@@ -761,7 +761,6 @@ class _PreviewWidget(QTextBrowser):
self.setPalette(dPalette)
self.setMinimumWidth(40*SHARED.theme.textNWidth)
- self.setTextFont(CONFIG.textFont, CONFIG.textSize)
self.setTabStopDistance(CONFIG.getTabWidth())
self.setOpenExternalLinks(False)
@@ -802,6 +801,8 @@ class _PreviewWidget(QTextBrowser):
self._updateDocMargins()
self._updateBuildAge()
+ self.setTextFont(CONFIG.textFont, CONFIG.textSize)
+
# Age Timer
self.ageTimer = QTimer(self)
self.ageTimer.setInterval(10000)
@@ -840,8 +841,8 @@ class _PreviewWidget(QTextBrowser):
font.setFamily(family)
font.setPointSize(size)
self.setFont(font)
- self.ageLabel.setFont(SHARED.theme.guiFont)
self.buildProgress.setFont(SHARED.theme.guiFont)
+ self.ageLabel.setFont(SHARED.theme.guiFontSmall)
return
##
From 60593cde21cfe9170a0ab71726bc20e712a54414 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Mon, 20 May 2024 12:29:03 +0200
Subject: [PATCH 5/5] Bump version to 2.4.3 and update changelog
---
CHANGELOG.md | 23 +++++++++++++++++++++++
novelwriter/__init__.py | 6 +++---
sample/nwProject.nwx | 6 +++---
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97e73da0..2b8a9a03 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,28 @@
# novelWriter Changelog
+## Version 2.4.3 [2024-05-20]
+
+### Release Notes
+
+This is a patch release that fixes issues with the document font in the editor, viewer and
+manuscript preview on some Linux distros, and also fixes a potential crash on Windows when using
+the spell check dictionary install tool.
+
+### Detailed Changelog
+
+**Bugfixes**
+
+* Fix a crash in the dictionaries install tool on Windows if the config folder reported by the
+ third party Enchant spell checker tool didn't already exist prior to adding new dictionaries.
+ The folder is now created when the tool is opened if it doesn't exist. Issue #1874. PR #1876.
+* Fix issues setting a different text font for the editor and viewer, and related issues with the
+ preview in the Manuscript Build tool, on certain platforms. Changing the font and setting
+ non-standard font sizes produced unexpected results when reloading. The issue seems to be related
+ to Qt 5.15.3, but that is not fully confirmed. However, the only place so far where the issue is
+ observed is on Mint 21.3. Issues #1862 and #1875. PR #1877.
+
+----
+
## Version 2.4.2 [2024-05-18]
### Release Notes
diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py
index 8f2d6a96..8d5a736e 100644
--- a/novelwriter/__init__.py
+++ b/novelwriter/__init__.py
@@ -47,9 +47,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
-__version__ = "2.4.2"
-__hexversion__ = "0x020402f0"
-__date__ = "2024-05-18"
+__version__ = "2.4.3"
+__hexversion__ = "0x020403f0"
+__date__ = "2024-05-20"
__status__ = "Stable"
__domain__ = "novelwriter.io"
diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx
index e5d1f346..c59679ed 100644
--- a/sample/nwProject.nwx
+++ b/sample/nwProject.nwx
@@ -1,6 +1,6 @@
-
-
+
+
Sample Project
Jane Smith
@@ -57,7 +57,7 @@
Chapter One
-
-
+
Making a Scene
-