diff options
author | Jonathan White <support@dmapps.us> | 2021-03-24 00:35:36 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2021-05-30 15:44:09 +0300 |
commit | 7f2281940da9a8382a6be937b036e89eeb032733 (patch) | |
tree | 34452753d2e2b51f2466e3e4f90e4ff724113c26 | |
parent | aaf8f188521a1742ded2fbd104cd594191d43a75 (diff) |
Use application font size when setting default or monospace fonts
* Fix #6286
-rw-r--r-- | src/gui/Font.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/Font.cpp b/src/gui/Font.cpp index 021380c29..8bb54863b 100644 --- a/src/gui/Font.cpp +++ b/src/gui/Font.cpp @@ -18,29 +18,29 @@ #include "Font.h" #include <QFontDatabase> +#include <QGuiApplication> QFont Font::defaultFont() { - return QFontDatabase::systemFont(QFontDatabase::GeneralFont); + return qApp->font(); } QFont Font::fixedFont() { - QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); + auto fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); #ifdef Q_OS_WIN // try to use Consolas on Windows, because the default Courier New has too many similar characters - QFont consolasFont = QFontDatabase().font("Consolas", fixedFont.styleName(), fixedFont.pointSize()); - const QFont defaultFont; - if (fixedFont != defaultFont) { + auto consolasFont = QFontDatabase().font("Consolas", fixedFont.styleName(), fixedFont.pointSize()); + if (consolasFont.family().contains("consolas", Qt::CaseInsensitive)) { fixedFont = consolasFont; } #endif #ifdef Q_OS_MACOS // Qt doesn't choose a monospace font correctly on macOS - const QFont defaultFont; - fixedFont = QFontDatabase().font("Menlo", defaultFont.styleName(), defaultFont.pointSize()); + fixedFont = QFontDatabase().font("Menlo", fixedFont.styleName(), fixedFont.pointSize()); #endif + fixedFont.setPointSize(qApp->font().pointSize()); return fixedFont; } |