Windows: Fix high-dpi text rendering

In change ce2ae6ebd8 we added support for
hinted rendering to the DirectWrite engine. Previously, we would just
use the DirectWrite engine for all text rendering in high-dpi and assume
we would get only vertical hinting, but since the default changed, we
ended up scaling hinted text and the resulting text layouts were a mess.

Task-number: QTBUG-56841
Change-Id: I52101ea264878138de41878d1677c0ef8b522e78
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2016-11-02 12:07:42 +01:00
parent 9930ea92c1
commit 1ba0cfab30

View File

@ -49,6 +49,7 @@
#include <QtCore/private/qsystemlibrary_p.h> #include <QtCore/private/qsystemlibrary_p.h>
#include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#if defined(QT_USE_DIRECTWRITE2) #if defined(QT_USE_DIRECTWRITE2)
# include <dwrite_2.h> # include <dwrite_2.h>
@ -185,6 +186,9 @@ namespace {
static DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(QFont::HintingPreference hintingPreference) static DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(QFont::HintingPreference hintingPreference)
{ {
if (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting)
hintingPreference = QFont::PreferVerticalHinting;
switch (hintingPreference) { switch (hintingPreference) {
case QFont::PreferNoHinting: case QFont::PreferNoHinting:
return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;