mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
407b6ce43f
commit
a7d1dbd013
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue