diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-02-09 16:43:08 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-02-09 16:45:04 -0800 |
commit | a7d1dbd013a049593941995883c29853743c2d42 (patch) | |
tree | 17d2d8dd91b5edef09d3c70e95f8016135ea3bb8 /mobile-widgets/themeinterface.cpp | |
parent | 407b6ce43f413d0d4e8aed8379a66bd7a8cd3687 (diff) | |
download | subsurface-a7d1dbd013a049593941995883c29853743c2d42.tar.gz |
mobile UI: fix font size breakage on Android
The pointSize() of a font can return -1 if the font was originally specificied
with a pixelSize. Work around this by using QFontInfo to calculate the correct
value.
Additionally, don't use the pointSize() of a font when we can instead use the
calculated size.
This fixes the problem with the missing star ratings on Android.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/themeinterface.cpp')
-rw-r--r-- | mobile-widgets/themeinterface.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mobile-widgets/themeinterface.cpp b/mobile-widgets/themeinterface.cpp index e6254c6de..3e8544bdb 100644 --- a/mobile-widgets/themeinterface.cpp +++ b/mobile-widgets/themeinterface.cpp @@ -3,6 +3,7 @@ #include "qmlmanager.h" #include "core/metrics.h" #include "core/settings/qPrefDisplay.h" +#include <QFontInfo> QColor themeInterface::m_backgroundColor; QColor themeInterface::m_contrastAccentColor; @@ -80,8 +81,9 @@ void themeInterface::setup(QQmlContext *ct) m_currentTheme = qPrefDisplay::theme(); update_theme(); - // check system font - m_basePointSize = defaultModelFont().pointSize(); + // check system font and create QFontInfo in order to reliably get the point size + QFontInfo qfi(defaultModelFont()); + m_basePointSize = qfi.pointSize(); // set initial font size set_currentScale(qPrefDisplay::mobile_scale()); @@ -110,7 +112,7 @@ void themeInterface::set_currentScale(double newScale) defaultModelFont().setPointSize(m_basePointSize * qPrefDisplay::mobile_scale()); // adjust all used font sizes - m_regularPointSize = defaultModelFont().pointSize(); + m_regularPointSize = m_basePointSize * qPrefDisplay::mobile_scale(); emit instance()->regularPointSizeChanged(m_regularPointSize); m_headingPointSize = m_regularPointSize * 1.2; |