diff ui/main.cpp @ 876:0051cb07da28

Reduce libraries, document i386 build and statically link fonts.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 07 Aug 2014 19:12:37 +0200
parents 4efd6378c001
children 59fc7ececa5f
line wrap: on
line diff
--- a/ui/main.cpp	Thu Aug 07 13:05:26 2014 +0200
+++ b/ui/main.cpp	Thu Aug 07 19:12:37 2014 +0200
@@ -9,6 +9,7 @@
 #include "processhelp.h"
 #include "logging.h"
 #include "selftest.h"
+#include "util.h"
 #ifdef WIN32
 #include "taskscheduler.h"
 #endif
@@ -22,6 +23,7 @@
 #include <QTranslator>
 
 #include <QStyleFactory>
+#include <QFontDatabase>
 
 #ifndef VERSION
 #define VERSION "0.0.1"
@@ -70,6 +72,7 @@
 
     qDebug() << "Application style is: " << app.style()->metaObject()->className();
     qDebug() << "Available styles: " << QStyleFactory::keys().join(", ");
+    qDebug() << "Font is: " << app.font();
 
     QStringList arguments = QApplication::arguments();
     bool trayMode = arguments.contains("--tray");
@@ -129,6 +132,20 @@
     startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8());
     startup_file.close();
 #endif
+
+    /* Install static fonts */
+
+    /* The putenv here works around a bug in qt. Qt thinks it is a fatal
+     * error if the font directory does not exist. */
+    qputenv("QT_QPA_FONTDIR", get_install_dir());
+    int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
+    if (fontId != -1)
+    {
+        QFont font("DejaVuSans");
+        font.setPointSize(9);
+        app.setFont(font);
+    }
+
     MainWindow mainWin(trayMode);
 
     return app.exec();

http://wald.intevation.org/projects/trustbridge/