Fix default hinting with dpr scaling on Wayland
When high-dpi scaling is enabled, we default to HintNone currently, since otherwise text layouts (and widget layouts and anything depending on text size) will have to be updated when the window is dragged onto a screen with a different dpr. The check for whether scaling is enabled was based on QHighDpiScaling::isActive(), which is technically incorrect since this does not return whether there is a scale on the painting, rather whether the coordinate system in Qt matches the one of the platform. Now that we support agreeing on fractional scale factors with the Wayland compositor, this issue has become visible, since QHighDpiScaling::isActive() will now return false for these compositors, even for fractional scales. For integer scales, the issue existed before as well, but the kerning issues are less noticeable in that case. Fixes: QTBUG-122910 Change-Id: Ic82b07d57a06a351255619f9227dd60396903ade Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de> (cherry picked from commit e7ddd490cf44ecd1c59b3798294ed2812fc5a940) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit cdee812bdbe1d39941ff6303048c7191385ad39d)
This commit is contained in:
parent
cc10e712cb
commit
2079949b46
@ -16,7 +16,6 @@
|
||||
#include <qpa/qplatformservices.h>
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <QtGui/qguiapplication.h>
|
||||
|
||||
@ -528,6 +527,11 @@ static void populateFromPattern(FcPattern *pattern, QFontDatabasePrivate::Applic
|
||||
|
||||
}
|
||||
|
||||
static bool isDprScaling()
|
||||
{
|
||||
return !qFuzzyCompare(qApp->devicePixelRatio(), 1.0);
|
||||
}
|
||||
|
||||
QFontconfigDatabase::~QFontconfigDatabase()
|
||||
{
|
||||
FcConfigDestroy(FcConfigGetCurrent());
|
||||
@ -626,7 +630,7 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
|
||||
break;
|
||||
}
|
||||
|
||||
if (QHighDpiScaling::isActive())
|
||||
if (isDprScaling())
|
||||
return QFontEngine::HintNone;
|
||||
|
||||
int hint_style = 0;
|
||||
@ -925,7 +929,7 @@ QFont QFontconfigDatabase::defaultFont() const
|
||||
void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const
|
||||
{
|
||||
bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
|
||||
bool forcedAntialiasSetting = !antialias || QHighDpiScaling::isActive();
|
||||
bool forcedAntialiasSetting = !antialias || isDprScaling();
|
||||
|
||||
const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services();
|
||||
bool useXftConf = false;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||
#include <QtGui/private/qtgui-config_p.h>
|
||||
|
||||
#include <QtCore/qmath.h>
|
||||
@ -57,7 +56,7 @@ static inline bool useDirectWrite(QFont::HintingPreference hintingPreference,
|
||||
|
||||
return hintingPreference == QFont::PreferNoHinting
|
||||
|| hintingPreference == QFont::PreferVerticalHinting
|
||||
|| (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting);
|
||||
|| (!qFuzzyCompare(qApp->devicePixelRatio(), 1.0) && hintingPreference == QFont::PreferDefaultHinting);
|
||||
}
|
||||
#endif // !QT_NO_DIRECTWRITE
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <QtCore/private/qwinregistry_p.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <qpa/qplatformintegration.h>
|
||||
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||
#include <QtGui/qpainterpath.h>
|
||||
|
||||
#include <dwrite_2.h>
|
||||
@ -161,7 +160,7 @@ static DWRITE_MEASURING_MODE renderModeToMeasureMode(DWRITE_RENDERING_MODE rende
|
||||
static DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(const QFontDef &fontDef)
|
||||
{
|
||||
QFont::HintingPreference hintingPreference = QFont::HintingPreference(fontDef.hintingPreference);
|
||||
if (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting) {
|
||||
if (!qFuzzyCompare(qApp->devicePixelRatio(), 1.0) && hintingPreference == QFont::PreferDefaultHinting) {
|
||||
// Microsoft documentation recommends using asymmetric rendering for small fonts
|
||||
// at pixel size 16 and less, and symmetric for larger fonts.
|
||||
hintingPreference = fontDef.pixelSize > 16.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user