Add font directory support
Stefan Bund [Mon, 1 Nov 2010 22:10:06 +0000 (23:10 +0100)]
main.cc

diff --git a/main.cc b/main.cc
index fcebd20..023e143 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -15,6 +15,9 @@
 #include <QApplication>
 #include <QSplashScreen>
 #include <QSettings>
+#include <QDir>
+#include <QFileInfo>
+#include <QFontDatabase>
 #include <boost/scoped_ptr.hpp>
 #include "MainWindow.hh"
 #include "PythonPublisher.hh"
@@ -48,6 +51,22 @@ int main(int argc, char *argv[])
         QString iconPath (settings.value("icon").toString());
 
         settings.endGroup();
+
+        settings.beginGroup("Fonts");
+        QString loadFontDir (settings.value("loaddir").toString());
+        if (!loadFontDir.isEmpty()) {
+            QDir dir (loadFontDir);
+            if (dir.exists()) {
+                QFileInfoList files (dir.entryInfoList(QDir::Files));
+                for (QFileInfoList::iterator i (files.begin()), i_end (files.end());
+                     i != i_end; ++i)
+                    QFontDatabase::addApplicationFont(i->absoluteFilePath());
+            }
+            else
+                std::cerr << "WARNING: Font directory not found" << std::endl;
+        }
+        settings.endGroup();
+
         settings.beginGroup("Viewer");
 
         pykit::PythonPublisher publisher (settings.value("init").toString().toStdString());