Skip to content

Commit

Permalink
Windows: Default to DirectWrite font backend
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
eskilblomfeldt committed Feb 6, 2024
1 parent bd6d7d4 commit 24224f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 5 additions & 7 deletions src/gui/kernel/qguiapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/platforms/windows/qwindowsintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/windows/qwindowsintegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class QWindowsIntegration : public QPlatformIntegration
DontUseWMPointer = 0x400,
DetectAltGrModifier = 0x800,
RtlEnabled = 0x1000,
FontDatabaseDirectWrite = 0x2000
FontDatabaseGDI = 0x2000
};

explicit QWindowsIntegration(const QStringList &paramList);
Expand Down

0 comments on commit 24224f1

Please sign in to comment.