diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-09-18 17:39:52 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-21 15:13:10 -0700 |
commit | df4fbf7699952eca3d79b732cdedba7c524b024e (patch) | |
tree | 80611ef17bbd88b63a50e4f3cb2112862f0feca8 | |
parent | 9a35519a2a1745ff2f4f23f3561efa8e2bb94b0b (diff) | |
download | subsurface-df4fbf7699952eca3d79b732cdedba7c524b024e.tar.gz |
Android: force different font on OnePlus devices
Those show a very strange font by default.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | subsurface-helper.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index b60d015dc..e924e1267 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -25,6 +25,12 @@ #include "desktop-widgets/mainwindow.h" #endif +#if defined(Q_OS_ANDROID) +QString getAndroidHWInfo(); // from android.cpp +#include <QApplication> +#include <QFontDatabase> +#endif /* Q_OS_ANDROID */ + #ifndef SUBSURFACE_TEST_DATA QObject *qqWindowObject = NULL; @@ -99,6 +105,19 @@ 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); |