diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-03-24 12:25:55 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-03-30 19:55:21 +0100 |
commit | 3188615db63fcd8b975690144bb711544266f864 (patch) | |
tree | faedf481e211ce2b36a21e1eba6ec649633030e0 /src/plugins/platforms/ios | |
parent | d84018616a24fa66502cf62f5ebbcf5ed4ca0742 (diff) |
iOS: Handle changes in user font preferences by invalidating font database
The user may tweak the appearance of text rendering on iOS to aid a11y,
by making the text larger or smaller, or bold. This feature, known as
Dynamic Type, will be reflected in the preferred content size category
of the application.
When we detect changes in this preferred content size category we respond
by invalidating the font database, which will trigger the application
to re-evaluate the sizes and weights of the theme fonts.
Unfortunately we do not currently pick up or propagate the scaled font
metrics when an explicit point or pixel size has been set on a QFont,
but this problem exists regardless of whether we dynamically handle
changes to dynamic types or only pick them up after an application
restart.
Change-Id: I8c722d0bfb4b76eade47ebfb6512e6676a910d6a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qiostheme.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostheme.mm | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiostheme.h b/src/plugins/platforms/ios/qiostheme.h index 400637eca1..b457151b1c 100644 --- a/src/plugins/platforms/ios/qiostheme.h +++ b/src/plugins/platforms/ios/qiostheme.h @@ -44,6 +44,8 @@ #include <QtGui/QPalette> #include <qpa/qplatformtheme.h> +#include <QtCore/private/qcore_mac_p.h> + QT_BEGIN_NAMESPACE class QIOSTheme : public QPlatformTheme @@ -71,6 +73,7 @@ public: private: static QPalette s_systemPalette; + QMacNotificationObserver m_contentSizeCategoryObserver; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index 69416ec24a..588cf3f22d 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -66,6 +66,12 @@ const char *QIOSTheme::name = "ios"; QIOSTheme::QIOSTheme() { initializeSystemPalette(); + + m_contentSizeCategoryObserver = QMacNotificationObserver(nil, + UIContentSizeCategoryDidChangeNotification, [] { + qCDebug(lcQpaFonts) << "Contents size category changed to" << UIApplication.sharedApplication.preferredContentSizeCategory; + QPlatformFontDatabase::handleAvailableFontsChanged(); + }); } QIOSTheme::~QIOSTheme() |