From 15d5fb5382d4c234fc738d425b6ff28836afe713 Mon Sep 17 00:00:00 2001 From: kleuter Date: Mon, 17 Mar 2025 17:22:31 +0100 Subject: [PATCH] turn off directwrite fonts on Windows prior to Windows 10 (issue https://github.com/crystalidea/qt6windows7/issues/33) --- .../platforms/windows/qwindowsintegration.cpp | 38 ++++--------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/qtbase/src/plugins/platforms/windows/qwindowsintegration.cpp b/qtbase/src/plugins/platforms/windows/qwindowsintegration.cpp index 547ca57d..b96715f1 100644 --- a/qtbase/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/qtbase/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -134,29 +134,6 @@ bool parseIntOption(const QString ¶meter,const QLatin1StringView &option, using DarkModeHandlingFlag = QNativeInterface::Private::QWindowsApplication::DarkModeHandlingFlag; using DarkModeHandling = QNativeInterface::Private::QWindowsApplication::DarkModeHandling; -typedef LONG (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); - -bool isWindows81() { - HMODULE hNtdll = GetModuleHandleA("ntdll.dll"); - if (!hNtdll) { - return false; // Failed to load ntdll.dll - } - - RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hNtdll, "RtlGetVersion"); - if (!RtlGetVersion) { - return false; // Failed to get RtlGetVersion - } - - RTL_OSVERSIONINFOW rovi = {0}; - rovi.dwOSVersionInfoSize = sizeof(rovi); - - if (RtlGetVersion(&rovi) == 0) { // STATUS_SUCCESS - return (rovi.dwMajorVersion == 6 && rovi.dwMinorVersion == 3); - } - - return false; // Unknown version -} - static inline unsigned parseOptions(const QStringList ¶mList, int *tabletAbsoluteRange, QtWindows::DpiAwareness *dpiAwareness, @@ -164,12 +141,6 @@ static inline unsigned parseOptions(const QStringList ¶mList, { unsigned options = 0; - // for some reason DirectWrite fonts don't work on Windows 8.1 - // https://github.com/crystalidea/qt6windows7/issues/26 - - if (isWindows81()) - options |= QWindowsIntegration::DontUseDirectWriteFonts; - for (const QString ¶m : paramList) { if (param.startsWith(u"fontengine=")) { if (param.endsWith(u"gdi")) { @@ -515,7 +486,14 @@ QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const else #endif // QT_NO_FREETYPE #if QT_CONFIG(directwrite3) - if (!(d->m_options & (QWindowsIntegration::FontDatabaseGDI | QWindowsIntegration::DontUseDirectWriteFonts))) + + /* IDWriteFontFace3 is only reportedly available starting with Windows 10. This change is necessary starting + with Qt 6.8, where DirectWrite is used by default to populate the font database. + More info: https://github.com/videolan/vlc/blob/master/contrib/src/qt/0001-Use-DirectWrite-font-database-only-with-Windows-10-a.patch + */ + + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10 && + !(d->m_options & (QWindowsIntegration::FontDatabaseGDI | QWindowsIntegration::DontUseDirectWriteFonts))) d->m_fontDatabase = new QWindowsDirectWriteFontDatabase; else #endif