Skip to content

Commit

Permalink
Try to fix font loading problems on windows by applying resources aft…
Browse files Browse the repository at this point in the history
…er mainwindow construction
  • Loading branch information
Cubitect committed Jun 3, 2022
1 parent 48ce790 commit 0dd82e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cubiomes
Submodule cubiomes updated 2 files
+4 −5 finders.c
+1 −0 finders.h
2 changes: 1 addition & 1 deletion src/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
32 changes: 16 additions & 16 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0dd82e6

Please sign in to comment.