-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (44 loc) · 1.22 KB
/
main.cpp
File metadata and controls
51 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QFontDatabase>
#include <QtDebug>
#include <QResource>
#include <QQuickView>
#include <vector>
#include <QString>
#include <QDir>
#include <QDirIterator>
std::vector<QString> GetFontPaths(QString family)
{
std::vector<QString> fonts;
QDirIterator it(":font/" + family.remove(' '), QDir::Files|QDir::NoDotAndDotDot);
while (it.hasNext())
{
fonts.push_back(it.next());
}
qDebug() << fonts.size() << "loaded.";
return fonts;
}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QString fontPath = QCoreApplication::applicationDirPath() + "/fonts/Roboto.rcc";
qDebug() << "Loading font family from" << fontPath;
if (!QResource::registerResource(fontPath))
{
qDebug() << "Loading of font Roboto failed.";
}
for (const QString &font : GetFontPaths("Roboto"))
{
qDebug() << "Loading font" << font;
QFontDatabase::addApplicationFont(font);
}
qDebug() << "BANANA1";
QGuiApplication::setFont(QFont("Roboto"));
qDebug() << "BANANA2";
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}