From 24224f1fe4b8cb6c9e3b1b94f7827305ef4a7040 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 1 Feb 2024 08:33:49 +0100 Subject: [PATCH] Windows: Default to DirectWrite font backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GDI font backend is missing support for certain modern features, and has a lot of work arounds for missing APIs. DirectWrite is the modern way to handle fonts on Windows, so we make this the default now, but keep the old backend as a fail safe. Fixes: QTBUG-119420 Change-Id: I0ea5cdfdcd759ccc894efb01b2410826c44aa1ea Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø Reviewed-by: Lars Knoll --- src/gui/kernel/qguiapplication.cpp | 12 +++++------- .../platforms/windows/qwindowsintegration.cpp | 16 ++++++++-------- .../platforms/windows/qwindowsintegration.h | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c7ae7aaae1a..d8977a5e90e 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -587,13 +587,10 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME \c none disables them. \li \c {fontengine=freetype}, uses the FreeType font engine. - \li \c {fontengine=directwrite}, uses the experimental DirectWrite - font database and defaults to using the DirectWrite font + \li \c {fontengine=gdi}, uses the legacy GDI-based + font database and defaults to using the GDI font engine (which is otherwise only used for some font types - or font properties.) This affects font selection and aims - to provide font naming more consistent with other platforms, - but does not support all font formats, such as Postscript - Type-1 or Microsoft FNT fonts. + or font properties.) (Since Qt 6.8). \li \c {menus=[native|none]}, controls the use of native menus. Native menus are implemented using Win32 API and are simpler than @@ -607,7 +604,8 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME \li \c {nocolorfonts} Turn off DirectWrite Color fonts (since Qt 5.8). - \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). + \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). This implicitly + also selects the GDI font engine. \li \c {nomousefromtouch} Ignores mouse events synthesized from touch events by the operating system. diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f6e377d1076..a2dfc18ce81 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -142,8 +142,8 @@ static inline unsigned parseOptions(const QStringList ¶mList, unsigned options = 0; for (const QString ¶m : paramList) { if (param.startsWith(u"fontengine=")) { - if (param.endsWith(u"directwrite")) { - options |= QWindowsIntegration::FontDatabaseDirectWrite; + if (param.endsWith(u"gdi")) { + options |= QWindowsIntegration::FontDatabaseGDI; } else if (param.endsWith(u"freetype")) { options |= QWindowsIntegration::FontDatabaseFreeType; } else if (param.endsWith(u"native")) { @@ -482,17 +482,17 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const { if (!d->m_fontDatabase) { -#if QT_CONFIG(directwrite3) - if (d->m_options & QWindowsIntegration::FontDatabaseDirectWrite) - d->m_fontDatabase = new QWindowsDirectWriteFontDatabase; - else -#endif #ifndef QT_NO_FREETYPE if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) d->m_fontDatabase = new QWindowsFontDatabaseFT; else #endif // QT_NO_FREETYPE - d->m_fontDatabase = new QWindowsFontDatabase(); +#if QT_CONFIG(directwrite3) + if (!(d->m_options & (QWindowsIntegration::FontDatabaseGDI | QWindowsIntegration::DontUseDirectWriteFonts))) + d->m_fontDatabase = new QWindowsDirectWriteFontDatabase; + else +#endif + d->m_fontDatabase = new QWindowsFontDatabase; } return d->m_fontDatabase; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 3837b658cd7..c2712077413 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -45,7 +45,7 @@ public: DontUseWMPointer = 0x400, DetectAltGrModifier = 0x800, RtlEnabled = 0x1000, - FontDatabaseDirectWrite = 0x2000 + FontDatabaseGDI = 0x2000 }; explicit QWindowsIntegration(const QStringList ¶mList);