mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
android: avoid crash with failed font load
Check that we found font families before accessing them. But the larger issue is likely that bundling the font failed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e6804152e5
commit
4c3b6e6df2
1 changed files with 12 additions and 7 deletions
|
@ -67,13 +67,18 @@ void run_ui()
|
||||||
if (getAndroidHWInfo().contains("/OnePlus/")) {
|
if (getAndroidHWInfo().contains("/OnePlus/")) {
|
||||||
QFontDatabase db;
|
QFontDatabase db;
|
||||||
int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf");
|
int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf");
|
||||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
QStringList fontFamilies = QFontDatabase::applicationFontFamilies(id);
|
||||||
QFont newDefaultFont;
|
if (fontFamilies.count() > 0) {
|
||||||
newDefaultFont.setFamily(family);
|
QString family = fontFamilies.at(0);
|
||||||
(static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont);
|
QFont newDefaultFont;
|
||||||
qDebug() << "Detected OnePlus device, trying to force bundled font" << family;
|
newDefaultFont.setFamily(family);
|
||||||
QFont defaultFont = (static_cast<QApplication *>(QCoreApplication::instance()))->font();
|
(static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont);
|
||||||
qDebug() << "Qt reports default font is set as" << defaultFont.family();
|
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();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Detected OnePlus device, but can't determine font family used";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QScreen *appScreen = QApplication::screens().at(0);
|
QScreen *appScreen = QApplication::screens().at(0);
|
||||||
|
|
Loading…
Reference in a new issue