From b7d4af3586f777a436302d81d77995b46f48be68 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Mon, 23 Nov 2020 16:44:17 +0100 Subject: [PATCH] Add font function to OffscreenTheme to run unit tests with offscreen Two unit tests fail at the moment with the offscreen theme because the font function of the offscreen theme does not return a monospace font when asked for a monospace font. This patch fixes it. Change-Id: Id682c75e2a94b246cffe97b342b1b562bac82a68 Reviewed-by: Qt CI Bot Reviewed-by: Andy Shaw Reviewed-by: Shawn Rutledge --- .../platforms/offscreen/qoffscreenintegration.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index cc457763971..99a1f7fd51e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -275,6 +275,20 @@ public: } return QPlatformTheme::themeHint(h); } + + virtual const QFont *font(Font type = SystemFont) const override + { + static QFont systemFont(QLatin1String("Sans Serif"), 9); + static QFont fixedFont(QLatin1String("monospace"), 9); + switch (type) { + case QPlatformTheme::SystemFont: + return &systemFont; + case QPlatformTheme::FixedFont: + return &fixedFont; + default: + return nullptr; + } + } }; QPlatformTheme *QOffscreenIntegration::createPlatformTheme(const QString &name) const