From 0dd82e6b48b71b8b306274a7383a002ff46096e7 Mon Sep 17 00:00:00 2001 From: Cubitect Date: Fri, 3 Jun 2022 21:12:25 +0200 Subject: [PATCH] Try to fix font loading problems on windows by applying resources after mainwindow construction --- cubiomes | 2 +- src/aboutdialog.h | 2 +- src/main.cpp | 1 + src/mainwindow.cpp | 32 ++++++++++++++++---------------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cubiomes b/cubiomes index 761b876..91ba293 160000 --- a/cubiomes +++ b/cubiomes @@ -1 +1 @@ -Subproject commit 761b876b2fb6883fdc2c4308b810a2c2a626c2d7 +Subproject commit 91ba2936167f673d55963a8fc3e3898fb56c9f78 diff --git a/src/aboutdialog.h b/src/aboutdialog.h index f993299..796a9e6 100644 --- a/src/aboutdialog.h +++ b/src/aboutdialog.h @@ -6,7 +6,7 @@ #define VERS_MAJOR 2 #define VERS_MINOR 2 -#define VERS_PATCH 1 // negative patch number designates a development version +#define VERS_PATCH 2 // negative patch number designates a development version // returns +1 if newer, -1 if older and 0 if equal inline int cmpVers(int major, int minor, int patch) diff --git a/src/main.cpp b/src/main.cpp index 804d030..b97c4de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,7 @@ int main(int argc, char *argv[]) initBiomeTypeColors(tempsColors); QApplication a(argc, argv); + QCoreApplication::setApplicationName("cubiomes-viewer"); QTranslator translator; translator.load("en_US", ":/lang"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 086eaa3..de567ac 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -66,24 +66,8 @@ MainWindow::MainWindow(QWidget *parent) , dimactions{} , dimgroup() { - int fontid = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf"); - if (fontid >= 0) - { - QFontDatabase::addApplicationFont(":/fonts/DejaVuSans-Bold.ttf"); - QFont fontdef = QFontDatabase::applicationFontFamilies(fontid).at(0); - fontdef.setPointSize(10); - QApplication::setFont(fontdef); - } - else - { - fprintf(stderr, "Failed to load recources.\n"); - exit(1); - } - ui->setupUi(this); - QCoreApplication::setApplicationName("cubiomes-viewer"); - formCond = new FormConditions(this); formGen48 = new FormGen48(this); formControl = new FormSearchControl(this); @@ -248,6 +232,22 @@ MainWindow::MainWindow(QWidget *parent) if (config.checkForUpdates) searchForUpdates(true); #endif + + QCoreApplication::setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles, true); + int fontid = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf"); + if (fontid >= 0) + { + QFontDatabase::addApplicationFont(":/fonts/DejaVuSans-Bold.ttf"); + QFont fontdef = QFontDatabase::applicationFontFamilies(fontid).at(0); + fontdef.setPointSize(10); + QApplication::setFont(fontdef); + //setStyleSheet("* { font: 10px '" + fontdef.family() + "'; }"); + } + else + { + fprintf(stderr, "Failed to load recources.\n"); + exit(1); + } } MainWindow::~MainWindow()