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/")) {
|
||||
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();
|
||||
QStringList fontFamilies = QFontDatabase::applicationFontFamilies(id);
|
||||
if (fontFamilies.count() > 0) {
|
||||
QString family = fontFamilies.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();
|
||||
} else {
|
||||
qDebug() << "Detected OnePlus device, but can't determine font family used";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
QScreen *appScreen = QApplication::screens().at(0);
|
||||
|
|
Loading…
Reference in a new issue