kde-frameworks/qqc2-desktop-style: Qt text rendering w highDPI scaling

Upstream commit e82957f5e6fc72e446239e2ee5139b93d3ceac85

See also:
https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/429

KDE-bug: https://bugs.kde.org/show_bug.cgi?id=479891

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
This commit is contained in:
Andreas Sturmlechner
2024-11-23 00:09:28 +01:00
parent 14afce8ff4
commit c5b3d781b1
3 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
From e82957f5e6fc72e446239e2ee5139b93d3ceac85 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Fri, 22 Nov 2024 21:57:01 +0000
Subject: [PATCH] Use Qt text rendering when high DPI scaling
It is known that native rendering performs badly with scaling and an
existing workaround is in place.
The current check does not work on Wayland that has per-window rather
than per-screen scaling. Given Qt changes hinting preferences when any
scaling is used anyway, we may as well commit to using the non-native
rendering throughout.
For QtQuick the Qt renderer is more performant, handles transformations
better and avoids this issue. Given the results look basically
identical, we can simplify the existing code.
BUG: 479891
---
.../plasmadesktoptheme.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp
index 51a3241f..fac0831f 100644
--- a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp
+++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp
@@ -50,14 +50,15 @@ public:
connect(qGuiApp, &QGuiApplication::fontDatabaseChanged, this, &StyleSingleton::notifyWatchersConfigurationChange);
qGuiApp->installEventFilter(this);
- // Use NativeTextRendering as the default text rendering type when the scale factor is an integer.
- // NativeTextRendering is still distorted sometimes with fractional scale factors,
- // despite https://bugreports.qt.io/browse/QTBUG-67007 being closed.
- qreal devicePixelRatio = qGuiApp->devicePixelRatio();
- QQuickWindow::TextRenderType defaultTextRenderType =
- int(devicePixelRatio) == devicePixelRatio ? QQuickWindow::NativeTextRendering : QQuickWindow::QtTextRendering;
- QQuickWindow::setTextRenderType(defaultTextRenderType);
-
+ // NativeTextRendering is still distorted sometimes with fractional scale factors
+ // Given Qt disables all hinting with native rendering when any scaling is used anyway
+ // we can use Qt's rendering throughout
+ // QTBUG-126577
+ if (qApp->devicePixelRatio() == 1.0) {
+ QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
+ } else {
+ QQuickWindow::setTextRenderType(QQuickWindow::QtTextRendering);
+ }
smallFont = loadSmallFont();
}
--
GitLab

View File

@@ -0,0 +1,40 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
ECM_QTHELP="false"
PVCUT=$(ver_cut 1-2)
QTMIN=6.6.2
inherit ecm frameworks.kde.org
DESCRIPTION="Style for QtQuickControls 2 that uses QWidget's QStyle for painting"
LICENSE="|| ( GPL-2+ LGPL-3+ )"
KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
IUSE=""
# Qt_6_PRIVATE_API matches org.kde.desktop.so, see also:
# https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/379
DEPEND="
>=dev-qt/qtbase-${QTMIN}:6[dbus,gui,widgets]
>=dev-qt/qtdeclarative-${QTMIN}:6=
=kde-frameworks/kcolorscheme-${PVCUT}*:6
=kde-frameworks/kconfig-${PVCUT}*:6
=kde-frameworks/kiconthemes-${PVCUT}*:6
=kde-frameworks/kirigami-${PVCUT}*:6
=kde-frameworks/sonnet-${PVCUT}*:6[qml]
"
RDEPEND="${DEPEND}
>=dev-qt/qt5compat-${QTMIN}:6
"
BDEPEND=">=dev-qt/qttools-${QTMIN}:6[linguist]"
PATCHES=(
"${FILESDIR}/${P}-use-qt-textrendering-w-highdpi.patch" # KDE-bug #479891
)
CMAKE_SKIP_TESTS=(
# bug 926509
animationspeedmodifiertest
)

View File

@@ -0,0 +1,40 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
ECM_QTHELP="false"
PVCUT=$(ver_cut 1-2)
QTMIN=6.7.2
inherit ecm frameworks.kde.org
DESCRIPTION="Style for QtQuickControls 2 that uses QWidget's QStyle for painting"
LICENSE="|| ( GPL-2+ LGPL-3+ )"
KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
IUSE=""
# Qt_6_PRIVATE_API matches org.kde.desktop.so, see also:
# https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/379
DEPEND="
>=dev-qt/qtbase-${QTMIN}:6[dbus,gui,widgets]
>=dev-qt/qtdeclarative-${QTMIN}:6=
=kde-frameworks/kcolorscheme-${PVCUT}*:6
=kde-frameworks/kconfig-${PVCUT}*:6
=kde-frameworks/kiconthemes-${PVCUT}*:6
=kde-frameworks/kirigami-${PVCUT}*:6
=kde-frameworks/sonnet-${PVCUT}*:6[qml]
"
RDEPEND="${DEPEND}
>=dev-qt/qt5compat-${QTMIN}:6
"
BDEPEND=">=dev-qt/qttools-${QTMIN}:6[linguist]"
PATCHES=(
"${FILESDIR}/${PN}-6.7.0-use-qt-textrendering-w-highdpi.patch" # KDE-bug #479891
)
CMAKE_SKIP_TESTS=(
# bug 926509
animationspeedmodifiertest
)