Turn off font hinting when we do high DPI scaling

Font hinting depends on the specific pixel size, and ends up very
wrong when the painter is scaled.

Change-Id: I2007ec7e7ad8d52358d76e88e030ea4df7e91455
Task-number: QTBUG-43809
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
Paul Olav Tvete 2015-01-13 12:45:28 +01:00
parent c1d08afd31
commit a8a00f646b
5 changed files with 21 additions and 2 deletions

View File

@ -521,6 +521,11 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
break;
}
if (QGuiApplication::platformNativeInterface()->nativeResourceForScreen("nofonthinting",
QGuiApplication::primaryScreen())) {
return QFontEngine::HintNone;
}
if (useXftConf) {
void *hintStyleResource =
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle",

View File

@ -78,7 +78,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
QByteArrayLiteral("rootwindow"),
QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled")
QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"),
QByteArrayLiteral("nofonthinting")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@ -283,6 +284,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
case GetTimestamp:
result = getTimestamp(xcbScreen);
break;
case NoFontHinting:
result = xcbScreen->noFontHinting() ? this : 0; //qboolptr...
break;
default:
break;
}

View File

@ -67,7 +67,8 @@ public:
X11Screen,
RootWindow,
ScreenSubpixelType,
ScreenAntialiasingEnabled
ScreenAntialiasingEnabled,
NoFontHinting
};
QXcbNativeInterface();

View File

@ -62,6 +62,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
, m_forcedDpi(-1)
, m_devicePixelRatio(1)
, m_hintStyle(QFontEngine::HintStyle(-1))
, m_noFontHinting(false)
, m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))
, m_antialiasingEnabled(-1)
, m_xSettings(0)
@ -86,6 +87,12 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
readXResources();
// disable font hinting when we do UI scaling
static bool dpr_scaling_enabled = (qgetenv("QT_DEVICE_PIXEL_RATIO").toInt() > 1
|| qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto");
if (dpr_scaling_enabled)
m_noFontHinting = true;
#ifdef Q_XCB_DEBUG
qDebug();
qDebug("Screen output %s of xcb screen %d:", m_outputName.toUtf8().constData(), m_number);

View File

@ -98,6 +98,7 @@ public:
void readXResources();
QFontEngine::HintStyle hintStyle() const { return m_hintStyle; }
bool noFontHinting() const { return m_noFontHinting; }
QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; }
int antialiasingEnabled() const { return m_antialiasingEnabled; }
@ -132,6 +133,7 @@ private:
int m_forcedDpi;
int m_devicePixelRatio;
QFontEngine::HintStyle m_hintStyle;
bool m_noFontHinting;
QFontEngine::SubpixelAntialiasingType m_subpixelType;
int m_antialiasingEnabled;
QXcbXSettings *m_xSettings;