Windows: Default to vertical hinting when high-dpi scaling is enabled

Since hinted text layouts are not scalable, we should disable
hinting by default when the high-dpi scaling is active.

This is the Windows version of 0f7bc885aa,
which solved the same issue for the fontconfig database.

Change-Id: I48b5da5b045dec195fd257743175017f39cf9620
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2015-11-02 12:28:35 +01:00
parent 115f303352
commit 6a6c14626d

View File

@ -40,6 +40,7 @@
#include <QtGui/QFont>
#include <QtGui/QGuiApplication>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtCore/qmath.h>
#include <QtCore/QDebug>
@ -1100,8 +1101,11 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
QFontEngine *fontEngine = 0;
#if !defined(QT_NO_DIRECTWRITE)
if (hintingPreference == QFont::PreferDefaultHinting
|| hintingPreference == QFont::PreferFullHinting)
bool useDirectWrite = (hintingPreference == QFont::PreferNoHinting)
|| (hintingPreference == QFont::PreferVerticalHinting)
|| (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting);
if (!useDirectWrite)
#endif
{
GUID guid;
@ -1704,7 +1708,8 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
#if !defined(QT_NO_DIRECTWRITE)
bool useDirectWrite = (request.hintingPreference == QFont::PreferNoHinting)
|| (request.hintingPreference == QFont::PreferVerticalHinting);
|| (request.hintingPreference == QFont::PreferVerticalHinting)
|| (QHighDpiScaling::isActive() && request.hintingPreference == QFont::PreferDefaultHinting);
if (useDirectWrite && initDirectWrite(data.data())) {
const QString fam = QString::fromWCharArray(lf.lfFaceName);
const QString nameSubstitute = QWindowsFontEngineDirectWrite::fontNameSubstitute(fam);