From a7d1dbd013a049593941995883c29853743c2d42 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 9 Feb 2020 16:43:08 -0800 Subject: [PATCH] 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 --- mobile-widgets/themeinterface.cpp | 8 +++++--- 1 file 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 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;