Windows: Default to DirectWrite font backend

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 <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2024-02-01 08:33:49 +01:00
parent bd6d7d4d74
commit 24224f1fe4
3 changed files with 14 additions and 16 deletions

View File

@ -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.

View File

@ -142,8 +142,8 @@ static inline unsigned parseOptions(const QStringList &paramList,
unsigned options = 0;
for (const QString &param : 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;
}

View File

@ -45,7 +45,7 @@ public:
DontUseWMPointer = 0x400,
DetectAltGrModifier = 0x800,
RtlEnabled = 0x1000,
FontDatabaseDirectWrite = 0x2000
FontDatabaseGDI = 0x2000
};
explicit QWindowsIntegration(const QStringList &paramList);