diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-09-28 12:03:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-02 08:04:49 -0700 |
commit | fdfa540747e70e245b3c721dffa31b7c8470e187 (patch) | |
tree | fbb74fc33a439147f7d001f414e608102c3cd5cc | |
parent | c90050f4494e1a051a628b19d02d6ef39a0d4327 (diff) | |
download | subsurface-fdfa540747e70e245b3c721dffa31b7c8470e187.tar.gz |
Android: move OnePlus font hack earlier
We want the new default font in place before the QML engine is
initialized.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | subsurface-helper.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 2f8ed8c21..11b98611a 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -61,8 +61,20 @@ void exit_ui() void run_ui() { - #ifdef SUBSURFACE_MOBILE +#if defined(Q_OS_ANDROID) + if (getAndroidHWInfo().contains("/OnePlus/")) { + QFontDatabase db; + int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf"); + QString family = QFontDatabase::applicationFontFamilies(id).at(0); + QFont newDefaultFont; + newDefaultFont.setFamily(family); + (static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont); + qDebug() << "Detected OnePlus device, trying to force bundled font" << family; + QFont defaultFont = (static_cast<QApplication *>(QCoreApplication::instance()))->font(); + qDebug() << "Qt reports default font is set as" << defaultFont.family(); + } +#endif QQmlApplicationEngine engine; register_qml_types(&engine); LOG_STP("run_ui qml engine started"); @@ -105,19 +117,6 @@ void run_ui() ctxt->setContextProperty("connectionListModel", &connectionListModel); ctxt->setContextProperty("logModel", MessageHandlerModel::self()); -#if defined(Q_OS_ANDROID) - if (getAndroidHWInfo().contains("/OnePlus/")) { - QFontDatabase db; - int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf"); - QString family = QFontDatabase::applicationFontFamilies(id).at(0); - QFont newDefaultFont; - newDefaultFont.setFamily(family); - (static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont); - qDebug() << "Detected OnePlus device, trying to force bundled font" << family; - QFont defaultFont = (static_cast<QApplication *>(QCoreApplication::instance()))->font(); - qDebug() << "Qt reports default font is set as" << defaultFont.family(); - } -#endif engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); LOG_STP("run_ui qml loaded"); qqWindowObject = engine.rootObjects().value(0); |