turn off directwrite fonts on Windows prior to Windows 10 (issue https://github.com/crystalidea/qt6windows7/issues/33)

This commit is contained in:
kleuter 2025-03-17 17:22:31 +01:00
parent e92ba4dce4
commit 15d5fb5382

View File

@ -134,29 +134,6 @@ bool parseIntOption(const QString &parameter,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 &paramList,
int *tabletAbsoluteRange,
QtWindows::DpiAwareness *dpiAwareness,
@ -164,12 +141,6 @@ static inline unsigned parseOptions(const QStringList &paramList,
{
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 &param : 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