From baf480995fc479573f549042b2a5f065ee0701ea Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Wed, 15 Jun 2016 12:57:58 +0200
Subject: Load and set Lato font as UI font for Qt

Test-Information:

Tested on OS X 10.11.5 with Qt 5.4.2 and Debian 8.5 with
Qt 5.3.2.

Change-Id: I9a60fc4b5556379576fdddc12a697cb71597e241

diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 56f2907..6e36fa4 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -13,6 +13,7 @@
 
 #include <QApplication>
 #include <QFile>
+#include <QFontDatabase>
 #include <QMap>
 #include <QMessageBox>
 #include <qdebug.h>
@@ -171,6 +172,36 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
         Log::setLogLevel(Swift::Log::debug);
     }
 
+    // Load fonts
+    std::vector<std::string> fontNames = {
+        "themes/Default/Lato2OFL/Lato-Black.ttf",
+        "themes/Default/Lato2OFL/Lato-BlackItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Bold.ttf",
+        "themes/Default/Lato2OFL/Lato-BoldItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Hairline.ttf",
+        "themes/Default/Lato2OFL/Lato-HairlineItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Heavy.ttf",
+        "themes/Default/Lato2OFL/Lato-HeavyItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Italic.ttf",
+        "themes/Default/Lato2OFL/Lato-Light.ttf",
+        "themes/Default/Lato2OFL/Lato-LightItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Medium.ttf",
+        "themes/Default/Lato2OFL/Lato-MediumItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Regular.ttf",
+        "themes/Default/Lato2OFL/Lato-Semibold.ttf",
+        "themes/Default/Lato2OFL/Lato-SemiboldItalic.ttf",
+        "themes/Default/Lato2OFL/Lato-Thin.ttf",
+        "themes/Default/Lato2OFL/Lato-ThinItalic.ttf"
+    };
+
+    for (auto&& fontName : fontNames) {
+        std::string fontPath = std::string(":/") + fontName;
+        int error = QFontDatabase::addApplicationFont(P2QSTRING(fontPath));
+        assert((error != -1) && "Failed to load font.");
+    }
+
+    QApplication::setFont(QFont("Lato"));
+
     bool enableAdHocCommandOnJID = options.count("enable-jid-adhocs") > 0;
     tabs_ = nullptr;
     if (options.count("no-tabs") && !splitter_) {
-- 
cgit v0.10.2-6-g49f6