Bug 479891 - Some text glyphs in QML software are vertically mis-aligned or squished when using a fractional scale factor
Summary: Some text glyphs in QML software are vertically mis-aligned or squished when ...
Status: CONFIRMED
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: VHI normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords: qt6
: 481233 482633 482720 482746 482928 483112 485647 487899 488623 489101 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-01-16 12:08 UTC by Michel Le Bihan
Modified: 2024-07-14 21:53 UTC (History)
43 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot1 (2.03 MB, image/png)
2024-01-16 12:08 UTC, Michel Le Bihan
Details
Screenshot2 (2.01 MB, image/png)
2024-01-16 12:09 UTC, Michel Le Bihan
Details
In Discover (46.92 KB, image/jpeg)
2024-01-17 00:09 UTC, Nate Graham
Details
In NeoChat (31.84 KB, image/jpeg)
2024-01-18 15:49 UTC, Nate Graham
Details
Yikes in NeoChat (102.79 KB, image/jpeg)
2024-01-18 17:58 UTC, Nate Graham
Details
aligned-scale-test-100% (957.27 KB, image/png)
2024-01-22 10:49 UTC, Michel Le Bihan
Details
aligned-scale-test-125% (812.69 KB, image/png)
2024-01-22 10:50 UTC, Michel Le Bihan
Details
aligned-scale-test-150% (440.08 KB, image/png)
2024-01-22 10:50 UTC, Michel Le Bihan
Details
aligned-scale-test-175% (341.86 KB, image/png)
2024-01-22 10:50 UTC, Michel Le Bihan
Details
1920x1080 125% (System settings dialog) (20.12 KB, image/jpeg)
2024-03-07 15:27 UTC, Alexey
Details
1920x1080 125% (System settings dialog 2) (32.57 KB, image/jpeg)
2024-03-07 15:27 UTC, Alexey
Details
1440p@125% - Normal Settings Window (30.21 KB, image/png)
2024-04-28 15:10 UTC, dft
Details
Kmail horrible font @ 125% 3440x1440 (81.37 KB, image/png)
2024-05-13 18:10 UTC, Lucas
Details
Screenshot of Konsole toolbar on X11, 150% fractional scaling, Qt rounding policy set (6.29 KB, image/png)
2024-06-20 07:30 UTC, gilles
Details
The worst one ive seen @ 150% 1440p (46.57 KB, image/png)
2024-06-23 15:43 UTC, derek
Details
System Settings - Overview (Applications) 1920x1080@125% (41.28 KB, image/png)
2024-06-27 13:31 UTC, Pavel Dobiáš
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Le Bihan 2024-01-16 12:08:26 UTC
SUMMARY
When fractional scaling is enabled, there are some weird artifacts in the text


STEPS TO REPRODUCE
1. Set scaling to 175% (or 125%)
2. Open Kickoff
3. Notice that some letters don't look good

OBSERVED RESULT
Some letters look very ugly. Please see the o in `Dolphin` in Screenshot1 and the `System Monitor` and the m in `Samba Status` in screenshot2.

EXPECTED RESULT
Text should be rendered correctly

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 40
KDE Plasma Version: 5.92.0
KDE Frameworks Version: 5.248.0
Qt Version: 6.6.1
Kernel Version: 6.8.0-0.rc0.20240112git70d201a40823.5.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20TA000EPB
System Version: ThinkPad E14 Gen 2

ADDITIONAL INFORMATION
Please see the screenshots
Comment 1 Michel Le Bihan 2024-01-16 12:08:53 UTC
Created attachment 164944 [details]
Screenshot1
Comment 2 Michel Le Bihan 2024-01-16 12:09:31 UTC
Created attachment 164945 [details]
Screenshot2
Comment 3 Nate Graham 2024-01-17 00:08:34 UTC
At 225% scale, I can't reproduce any text artifacts in Kickoff, but I can reproduce the issue for the letters "i" and "l" in Discover's sidebar. 

Discover is using qqc2-desktop-style while Plasma is using the Plasma style; the common denominator is QtQuick Label itself, so the issue might be in there.
Comment 4 Nate Graham 2024-01-17 00:09:37 UTC
Created attachment 164964 [details]
In Discover

Now that I zoom in on that screenshot, I see the letter "c" in "All Applications" exhibits the issue as well.
Comment 5 Nate Graham 2024-01-18 15:49:01 UTC
Created attachment 165011 [details]
In NeoChat

Found some more examples in NeoChat today. Still 225% scale.
Comment 6 Nate Graham 2024-01-18 17:58:28 UTC
Created attachment 165015 [details]
Yikes in NeoChat

Found another in NeoChat that downright qualifies as software gore. This is at 110% scale on a 1080p screen.
Comment 7 Nate Graham 2024-01-18 19:23:36 UTC
In that screenshot, the top message exhibits the issue, and the bottom message doesn't. However that's only because I selected the text in the bottom message. Before I selected it, it looked like in the top message. This shows that it doesn't have to always be that way, even on this challenging scale factor and screen resolution combination.
Comment 8 Michel Le Bihan 2024-01-22 10:48:31 UTC
Isn't there a subsurface alignment issue in KWin? I run the subsurface test client mentioned in https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/143#note_1343171 and there is clearly a misalignment. I run the same test client in Mutter with fractional scaling and it looked fine. It seems that it was corrected in Mutter in https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726.
Comment 9 Michel Le Bihan 2024-01-22 10:49:54 UTC
Created attachment 165120 [details]
aligned-scale-test-100%
Comment 10 Michel Le Bihan 2024-01-22 10:50:16 UTC
Created attachment 165121 [details]
aligned-scale-test-125%
Comment 11 Michel Le Bihan 2024-01-22 10:50:32 UTC
Created attachment 165122 [details]
aligned-scale-test-150%
Comment 12 Michel Le Bihan 2024-01-22 10:50:47 UTC
Created attachment 165123 [details]
aligned-scale-test-175%
Comment 13 David Edmundson 2024-01-22 15:54:56 UTC
>Isn't there a subsurface alignment issue in KWin?

Even if there was, the examples above aren't used subsurfaces
Comment 14 S 2024-03-06 16:33:16 UTC
I experience the same issue on 6.0.1, with deformed and misplaced letters around most of the Plasma UI and System Settings, at 150% scaling. Looks like there are no issues in Widgets apps, GTK apps and Firefox. Most icons are also either blurry or pixelated, and even some UI elements. Some icons "unblur" for a short period of time when hovering over them with the cursor.
Comment 15 Marco Martin 2024-03-07 15:23:33 UTC
*** Bug 482720 has been marked as a duplicate of this bug. ***
Comment 16 Alexey 2024-03-07 15:27:14 UTC
Created attachment 166602 [details]
1920x1080 125% (System settings dialog)
Comment 17 Alexey 2024-03-07 15:27:38 UTC
Created attachment 166603 [details]
1920x1080 125% (System settings dialog 2)
Comment 18 Alexey 2024-03-07 15:32:44 UTC
(In reply to Marco Martin from comment #15)
> *** Bug 482720 has been marked as a duplicate of this bug. ***

Bug 482722 may also be related to this issue but the artifacts described there achieved through certain actions.
Comment 19 Nate Graham 2024-03-07 21:38:31 UTC
*** Bug 482633 has been marked as a duplicate of this bug. ***
Comment 20 Nate Graham 2024-03-07 22:12:05 UTC
*** Bug 482746 has been marked as a duplicate of this bug. ***
Comment 21 Nate Graham 2024-03-10 20:56:04 UTC
*** Bug 482928 has been marked as a duplicate of this bug. ***
Comment 22 Nate Graham 2024-03-13 18:00:58 UTC
*** Bug 481233 has been marked as a duplicate of this bug. ***
Comment 23 Nate Graham 2024-03-13 18:01:51 UTC
Apparently setting QT_SCALE_FACTOR_ROUNDING_POLICY=RoundPreferFloor in the environment works around this.
Comment 24 Dāvis 2024-03-13 19:32:37 UTC
(In reply to Nate Graham from comment #23)
> Apparently setting QT_SCALE_FACTOR_ROUNDING_POLICY=RoundPreferFloor in the
> environment works around this.

Indeed, that makes it look WAY better.
Comment 25 David Edmundson 2024-03-14 14:11:38 UTC
*** Bug 483112 has been marked as a duplicate of this bug. ***
Comment 26 NW 2024-03-16 17:09:14 UTC
Qt 6 apparently sets the "QT_SCALE_FACTOR_ROUNDING_POLICY" environment variable to "PassThrough" by default, according to:

https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference

And manually changing the "QT_SCALE_FACTOR_ROUNDING_POLICY" environment variable to "RoundPreferFloor" indeed seems to fix the issue:

https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum

Can "RoundPreferFloor" be made the new default for KDE Plasma and/or can a setting for it be added to the KDE Plasma GUI system settings?
Comment 27 NW 2024-03-16 18:10:25 UTC
PS:

Actually any value, other than the Qt 6 default value "PassThrough", seems to fix the issue:

https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum

Because the "Round", "Ceil" and "Floor" settings also seem to solve the issue (not just the "RoundPreferFloor" setting).

According to the documentation, "Round" was the default setting for Qt 5 and "PassThrough" is the default setting for Qt 6:

https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference

And only the "PassThrough" setting seems to cause the issue.

The documentation also seems to suggest that using any of the non-default settings ("Round", "Ceil", "Floor", "RoundPreferFloor") would round fractional values either up or down to the next integer value:

https://doc.qt.io/qt-6/qguiapplication.html#setHighDpiScaleFactorRoundingPolicy

But the size of the items on the screen do not seem to change at first glance. The only effect that those non-default settings seem to have is that the font rendering issue is fixed when using them.
Comment 28 drokergeek 2024-03-19 07:32:38 UTC
For me, I get this issue under 150% scaling and not under 125% scaling (neither i get https://bugs.kde.org/show_bug.cgi?id=459373 under 125%)

Operating System: Arch Linux 
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.8.1-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 30.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A7
Comment 29 Cameron Smith 2024-04-11 12:37:01 UTC
I made a post a few days back regarding this bug (https://discuss.kde.org/t/kde-6-upgrade-broke-fonts-in-wayland/13254) and am delighted to report that setting the "QT_SCALE_FACTOR_ROUNDING_POLICY" environment variable to "RoundPreferFloor" indeed seems to fix all issues I had.

Hopefully this can be resolved in a release soon, as it seems (to me at least) to be a straightforward fix. I've got no idea what implications setting this variable might have on niche situations elsewhere in KDE, but so far all good on my end. Thanks Nate for the solution!

My setup:
Thinkpad T480s
Arch linux
KDE 6.0.3
Wayland session (ofc)
Comment 30 Vasily Khoruzhick 2024-04-16 22:27:48 UTC
*** Bug 485647 has been marked as a duplicate of this bug. ***
Comment 31 dft 2024-04-28 15:10:24 UTC
Created attachment 168973 [details]
1440p@125% - Normal Settings Window
Comment 32 Lucas 2024-05-13 18:10:21 UTC
Created attachment 169453 [details]
Kmail horrible font @ 125% 3440x1440

My contribution. Hope this is resolved soon.
Comment 33 Nate Graham 2024-06-11 23:00:43 UTC
*** Bug 487899 has been marked as a duplicate of this bug. ***
Comment 34 Nate Graham 2024-06-17 17:02:45 UTC
*** Bug 488623 has been marked as a duplicate of this bug. ***
Comment 35 gilles 2024-06-20 07:30:33 UTC
Created attachment 170663 [details]
Screenshot of Konsole toolbar on X11, 150% fractional scaling, Qt rounding policy set

I can confirm that setting QT_SCALE_FACTOR_ROUNDING_POLICY to RoundPreferFloor indeed fixes the bad glyph rendering, however it also seems to disable fractional scaling on X11 for all graphical elements (fonts seem to still be properly scaled though ?), for instances icons are either scaled to 2x or to 1x depending on the ratio.

In the attached screenshot, the icons are too small compared to the text with 150% scaling factor. With scaling factors <=150%, it also makes plasma panels to be sized at 1x (but with text scaled at 150% !).
Comment 36 Nate Graham 2024-06-20 13:31:29 UTC
This is a Qt issue. Multiple patches have gone in recently that make this better:
- https://github.com/qt/qtbase/commit/e7ddd490cf44ecd1c59b3798294ed2812fc5a940 (in 6.7.1)
- https://github.com/qt/qtbase/commit/a5953d20e27ab73774058dd06ac514f9310a41e8 (in 6.8.0)

...But none fully fix it. 

Of note, this specific glitch only seems to affect QML labels using Text.NativeRendering. Switching to Text.QtRendering makes the issue go away — at the cost of introducing two new ones: blurrier text and excessive boldness at the topr or bottoms of all characters on a single line.

Work and investigation are ongoing.
Comment 37 Nate Graham 2024-06-20 14:10:56 UTC
Minimum reproducible case for me:

import QtQuick

ListView {
    width: 200
    height: 400

    model: 50

    delegate: Text {
        text: "I might be misaligned"
        renderType: Text.NativeRendering
    }
}

Scroll on that while it's located on a screen with fractional scaling, and the issue will quickly show up.
Comment 38 derek 2024-06-23 15:43:24 UTC Comment hidden (spam)
Comment 39 Nate Graham 2024-06-25 15:38:48 UTC
*** Bug 489101 has been marked as a duplicate of this bug. ***
Comment 40 Nate Graham 2024-06-25 15:39:42 UTC Comment hidden (spam)
Comment 41 Pavel Dobiáš 2024-06-27 13:31:56 UTC
Created attachment 171084 [details]
System Settings - Overview (Applications) 1920x1080@125%

Idk if this is related exactly to this specific bug, but I have 125% fractional scaling set on my 1080p display and my System Monitor Applications section in Overview looks terrible.