Windows QPA: Introduce command line options for DirectWrite
Add option "nodirectwrite" to turn off DirectWrite fonts and "nocolorfonts" to turn off DirectWrite for colored fonts. Task-number: QTBUG-55096 Task-number: QTBUG-55097 Change-Id: If12133fbd20dc7657b3616eff833a8e8c116e070 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
ac9d19c986
commit
7f66289f9d
@ -40,6 +40,7 @@
|
|||||||
#include "qwindowsfontdatabase.h"
|
#include "qwindowsfontdatabase.h"
|
||||||
#include "qwindowsfontdatabase_ft.h" // for default font
|
#include "qwindowsfontdatabase_ft.h" // for default font
|
||||||
#include "qwindowscontext.h"
|
#include "qwindowscontext.h"
|
||||||
|
#include "qwindowsintegration.h"
|
||||||
#include "qwindowsfontengine.h"
|
#include "qwindowsfontengine.h"
|
||||||
#include "qwindowsfontenginedirectwrite.h"
|
#include "qwindowsfontenginedirectwrite.h"
|
||||||
#include "qtwindows_additional.h"
|
#include "qtwindows_additional.h"
|
||||||
@ -112,6 +113,18 @@ static void createDirectWriteFactory(IDWriteFactory **factory)
|
|||||||
|
|
||||||
*factory = static_cast<IDWriteFactory *>(result);
|
*factory = static_cast<IDWriteFactory *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool useDirectWrite(QFont::HintingPreference hintingPreference, bool isColorFont = false)
|
||||||
|
{
|
||||||
|
const unsigned options = QWindowsIntegration::instance()->options();
|
||||||
|
if (Q_UNLIKELY(options & QWindowsIntegration::DontUseDirectWriteFonts))
|
||||||
|
return false;
|
||||||
|
if (isColorFont)
|
||||||
|
return (options & QWindowsIntegration::DontUseColorFonts) == 0;
|
||||||
|
return hintingPreference == QFont::PreferNoHinting
|
||||||
|
|| hintingPreference == QFont::PreferVerticalHinting
|
||||||
|
|| (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting);
|
||||||
|
}
|
||||||
#endif // !QT_NO_DIRECTWRITE
|
#endif // !QT_NO_DIRECTWRITE
|
||||||
|
|
||||||
// Helper classes for creating font engines directly from font data
|
// Helper classes for creating font engines directly from font data
|
||||||
@ -1163,11 +1176,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
|
|||||||
QFontEngine *fontEngine = 0;
|
QFontEngine *fontEngine = 0;
|
||||||
|
|
||||||
#if !defined(QT_NO_DIRECTWRITE)
|
#if !defined(QT_NO_DIRECTWRITE)
|
||||||
bool useDirectWrite = (hintingPreference == QFont::PreferNoHinting)
|
if (!useDirectWrite(hintingPreference))
|
||||||
|| (hintingPreference == QFont::PreferVerticalHinting)
|
|
||||||
|| (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting);
|
|
||||||
|
|
||||||
if (!useDirectWrite)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
GUID guid;
|
GUID guid;
|
||||||
@ -1804,12 +1813,13 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
|
|||||||
isColorFont = true;
|
isColorFont = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
const QFont::HintingPreference hintingPreference =
|
||||||
bool useDirectWrite = (request.hintingPreference == QFont::PreferNoHinting)
|
static_cast<QFont::HintingPreference>(request.hintingPreference);
|
||||||
|| (request.hintingPreference == QFont::PreferVerticalHinting)
|
const bool useDw = useDirectWrite(hintingPreference, isColorFont);
|
||||||
|| (QHighDpiScaling::isActive() && request.hintingPreference == QFont::PreferDefaultHinting)
|
qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize
|
||||||
|| isColorFont;
|
<< "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont
|
||||||
if (useDirectWrite) {
|
<< dpi << "dpi" << "useDirectWrite=" << useDw;
|
||||||
|
if (useDw) {
|
||||||
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
||||||
request.pixelSize,
|
request.pixelSize,
|
||||||
data);
|
data);
|
||||||
|
@ -199,6 +199,10 @@ static inline unsigned parseOptions(const QStringList ¶mList,
|
|||||||
}
|
}
|
||||||
} else if (param == QLatin1String("gl=gdi")) {
|
} else if (param == QLatin1String("gl=gdi")) {
|
||||||
options |= QWindowsIntegration::DisableArb;
|
options |= QWindowsIntegration::DisableArb;
|
||||||
|
} else if (param == QLatin1String("nodirectwrite")) {
|
||||||
|
options |= QWindowsIntegration::DontUseDirectWriteFonts;
|
||||||
|
} else if (param == QLatin1String("nocolorfonts")) {
|
||||||
|
options |= QWindowsIntegration::DontUseColorFonts;
|
||||||
} else if (param == QLatin1String("nomousefromtouch")) {
|
} else if (param == QLatin1String("nomousefromtouch")) {
|
||||||
options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch;
|
options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch;
|
||||||
} else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose)
|
} else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose)
|
||||||
|
@ -60,7 +60,9 @@ public:
|
|||||||
DisableArb = 0x4,
|
DisableArb = 0x4,
|
||||||
NoNativeDialogs = 0x8,
|
NoNativeDialogs = 0x8,
|
||||||
XpNativeDialogs = 0x10,
|
XpNativeDialogs = 0x10,
|
||||||
DontPassOsMouseEventsSynthesizedFromTouch = 0x20 // Do not pass OS-generated mouse events from touch.
|
DontPassOsMouseEventsSynthesizedFromTouch = 0x20, // Do not pass OS-generated mouse events from touch.
|
||||||
|
DontUseDirectWriteFonts = 0x40,
|
||||||
|
DontUseColorFonts = 0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QWindowsIntegration(const QStringList ¶mList);
|
explicit QWindowsIntegration(const QStringList ¶mList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user