https://bugs.kde.org/show_bug.cgi?id=501715

--- Comment #19 from lucazade <[email protected]> ---
**Plasma 6.8: plasmashell text lost native rendering as a side effect of
`d7a43134` (libplasma)**

Plasma 6.8.1, Qt 6.12.0, KF 6.31.0, EndeavourOS, Wayland, 100% scale. Seen on
two machines:
NVIDIA GTX 1050 Ti (Qt Quick uses an OpenGL ES context, so Qt's distance-field
text is
grayscale) and Intel UHD 620 (subpixel, but unhinted). In both cases panel,
launcher,
tooltips and notifications look blurry compared to 6.7, while Qt Widgets apps
look fine.

### Root cause (as far as I can tell)

`QQuickWindow::setTextRenderType()` is a process-wide static and only affects
items created
afterwards. In the Plasma stack it is only called from the Kirigami platform
plugins
`org.kde.desktop` and `org.kde.breeze` (in the `StyleSingleton` constructor,
native rendering
when the device pixel ratio is an integer). `KirigamiPlasmaStyle` does not call
it.

In 6.7.5 the shared QML engine only got `_kirigamiTheme=KirigamiPlasmaStyle`
when the first
`AppletQuickItem` was created (`Plasma::setupPlasmaStyle()` in
`AppletQuickItem::itemForApplet`).
Anything using Kirigami (`Kirigami.Theme` / `Kirigami.Units`) on that engine
before that, e.g. the
shell's own `Panel.qml` / `Desktop.qml`, fell back to `QQuickStyle::name()` =
`org.kde.desktop`,
which loaded that plugin early and switched the whole process to native text as
a side effect.

`d7a43134` ("Apply Plasma::setupPlasmaStyle in globalEngine()") applies the
style when the engine
is created, so `org.kde.desktop.so` is never loaded and plasmashell stays on
Qt's default
(`QtTextRendering`), which ignores the hinting and subpixel settings. I did not
trace 6.7.5 at
runtime; the early load is inferred from the 6.7.5 and 6.8.1 sources.

### Evidence

* 6.8.1 plasmashell right after login: only `KirigamiPlasmaStyle.so` is mapped.
* Opening "Configure Digital Clock..." loads `org.kde.desktop.so`. From then
on, in the same
  process, new text is native: a clock widget added afterwards, its tooltip and
a notification
  show colored subpixel fringes on 67-77% of text edge pixels. Items created
before (panel, old
  clock) stay at 0% (grayscale).
* Plain QtQuick test: `QtRendering` 0% fringes, `NativeRendering` 86%. Setting
the default with
  `setTextRenderType` before loading the QML gives the same result. Qt 6.11.2
and 6.12.0 behave
  the same, so this is not a Qt regression.

### Workaround that confirms it

A 12-line `LD_PRELOAD` library that calls
`QQuickWindow::setTextRenderType(NativeTextRendering)`
at load time and unsets `LD_PRELOAD` (so children do not inherit it), added to
`plasma-plasmashell.service` via a drop-in. Panel and launcher text goes from
0% to 71-85%
fringed edge pixels on both machines.

```cpp
#include <QQuickWindow>
#include <stdlib.h>
__attribute__((constructor)) static void init()
{
    unsetenv("LD_PRELOAD");
    QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
}
```

### Suggested fix

Set the default explicitly instead of relying on a plugin side effect, for
example in the
`KirigamiPlasmaStyle` platform plugin or in plasmashell's `main()`, with the
same logic as
qqc2-breeze-style (native for integer scale factors, Qt rendering otherwise
because of
QTBUG-126577), and honouring `QT_QUICK_DEFAULT_TEXT_RENDER_TYPE`.

This is separate from the long-standing problem in this bug (Plasma items
always using
`QtRendering` on fractional scales), but it explains why 6.8 made it visible on
100% scale.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to