Bug 124292 - KDE5: Fractional scaling makes most UI and rendered text look bad
Summary: KDE5: Fractional scaling makes most UI and rendered text look bad
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
6.2.0.3 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.3.0 target:6.2.4
Keywords:
: 123709 (view as bug list)
Depends on:
Blocks: KDE
  Show dependency treegraph
 
Reported: 2019-03-23 14:07 UTC by Buovjaga
Modified: 2019-11-26 13:11 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of badness (65.60 KB, image/png)
2019-03-23 14:07 UTC, Buovjaga
Details
Some good, some bad (125.05 KB, image/jpeg)
2019-03-27 19:03 UTC, Nate Graham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Buovjaga 2019-03-23 14:07:52 UTC
Created attachment 150228 [details]
Screenshot of badness

1. Go to KDE Plasma display settings
2. Change scaling to 1.2 or some other fractional value
3. Launch LibO with kde5 backend

The assumption is that this is a Qt regression. Perhaps version from 5.11.

Arch Linux 64-bit
Version: 6.3.0.0.alpha0+
Build ID: 66b21521a95f7b2053aa99a23e0a4c34438af6c7
CPU threads: 8; OS: Linux 5.0; UI render: default; VCL: kde5; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 22 March 2019
Comment 1 Michael Weghorn 2019-03-24 22:27:28 UTC
What distribution and Qt version are you using?

Looks OK for me on Debian testing (with distro Qt packages at version 5.11.3+dfsg-5) and

Version: 6.3.0.0.alpha0+
Build ID: c18179cf80516f1eca9629a0a8b888e0ca67a020
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: kde5; 
Locale: en-GB (en_GB.UTF-8); UI-Language: en-US
Calc: threaded

Fonts get larger and still look good when I set the scale factor to e.g. 1.2 or 1.6.
Comment 2 Buovjaga 2019-03-25 07:46:57 UTC
As mentioned in desc, distro is Arch Linux. Qt is 5.12.2, but I have had the problem ever since the kde5 backend was buildable, so last year.
I remember there being a report for Calc cell input text rendering, where the result matched mine exactly, but I cannot find it in the meta bug.
Comment 3 Michael Weghorn 2019-03-25 16:54:16 UTC
Thanks for the info and sry for being unable to read the desc properly...
Comment 4 Nate Graham 2019-03-27 19:03:22 UTC
Created attachment 150327 [details]
Some good, some bad

Can confirm with LO 6.2.0.3 using the KDE5 backend. Interestingly enough, menu text is nice looking, but text in the toolbars' comboboxes is bad, and all icons look bad.
Comment 5 Michael Weghorn 2019-03-27 22:30:04 UTC
*** Bug 123709 has been marked as a duplicate of this bug. ***
Comment 6 Nicolas 2019-03-29 13:25:50 UTC
I have the same issue on KDE neon:

Operating System: KDE neon 5.15
KDE Plasma Version: 5.15.3
KDE Frameworks Version: 5.56.0
Qt Version: 5.12.0
Kernel Version: 4.18.0-16-generic
OS Type: 64-bit
Processors: 12 × Intel® Core™ i7-8750H CPU @ 2.20GHz
Memory: 15,2 GiB


However, this issue is not limited to fractional scaling, I also see it with non-fractional scaling (2x) and the fonts look *very* blurry. Using SAL_USE_VCLPLUGIN=gtk3 makes the fonts look good again.
Comment 7 Jan-Marek Glogowski 2019-03-29 21:06:00 UTC
I'm on Debian testing with Qt5 (libqt5core5a = 5.11.3+dfsg1-1). Various qt libraries have their own current version in Debian, so this just lists core.
I generally can reproduce the problem. From all the images and tests I saw it looks like Qt and Cairo render with lower DPI and then scale the image. This matches the qscreen reports.
And I don't know why gtk3 works and neither qt5 nor kde5.
BTW: LO just uses the DPI value internally, no resolution.

I guess it affects kde5 / cairo because of some x setting somewhere (xdpyinfo is still on 96 DPI and 1920x1080 with scale 1.1).

Similar problems are quite probably these:

* bug 124237 - kde5 renders everything aliased
* bug 122263 - Bad resolution for icons in LO Draw

There is a little test program (qscreen) attached to bug 122131.

I'm changing the scaling factor via
$ LANG=C kcmshell5 kcm_kscreen
=> Scale Display

1. If I run my qscreen program without scaling I get:
devicePixelRatio: 1
geometry: QRect(0,0 1920x1080)
logicalDotsPerInch: 96.1263

2. If I change the scaling to 1.1 and log in again I get:
devicePixelRatio: 1.1
geometry: QRect(0,0 1745x982)
logicalDotsPerInch: 96.3636

3. If I have scaling on login set to 1.1 and unset QT_SCREEN_SCALE_FACTORS, I get
devicePixelRatio: 1
geometry: QRect(0,0 1920x1080)
logicalDotsPerInch: 106

4. If I have scaling on login set to 1.1 and set it to 1.0, I get:
devicePixelRatio: 1.1
geometry: QRect(0,0 1745x982)
logicalDotsPerInch: 87.3876

As you can see, nothing seem really consistent. Factors in this bug are:
* Scaling on session start
* Current scaling setting
* QT_SCREEN_SCALE_FACTORS value

I also get various graphic problems in other KDE application with scaling set to 1.1 FWIW.

What fixes LO for me is simply this: unset QT_SCREEN_SCALE_FACTORS before starting LO with scaling to 1.1.

Quoting from https://doc.qt.io/qt-5/highdpi.html: "QT_SCREEN_SCALE_FACTORS [list] specifies scale factors for each screen. This will not change the size of point sized fonts. This environment variable is mainly useful for debugging, or to work around monitors with wrong EDID information(Extended Display Identification Data)."

Which makes it highly suspicious for me to set this value.
Actually I started a good old wmaker session with scaling 1.0 from KDE.
The environment had no QT settings, but I don't know how scaling is actually set.
Then I set QT_SCREEN_SCALE_FACTORS to 1.1 and started LO qt5 / kde5.
Result was a bigger LO window on startup (expected), but the fonts were actually smaller and also just glibberish.

qscreen outupt was:
devicePixelRatio: 1.1
geometry: QRect(0,0 1745x982)
logicalDotsPerInch: 87.3876

Anyway: the solution for me is 3. That fixes both qt5 and kde5 for me and actually scales the font correctly.
It kind of seems logical, because it simply increases the DPI value and devicePixelRatio is 1, so no need to scale.

Solution 3 matches this patch, which works for me: https://gerrit.libreoffice.org/#/c/69941/

Bit since I have massive other graphics problems in KDE when scaling is enabled, I would like to get some feedback before merging.
Comment 8 Buovjaga 2019-03-29 21:15:39 UTC
(In reply to Jan-Marek Glogowski from comment #7)
> Solution 3 matches this patch, which works for me:
> https://gerrit.libreoffice.org/#/c/69941/

I built with it and it seems to fix the issues indeed. Thanks!
Comment 9 Michael Weghorn 2019-03-30 20:28:12 UTC
(In reply to Jan-Marek Glogowski from comment #7)
> [...]
> As you can see, nothing seem really consistent. Factors in this bug are:
> * Scaling on session start
> * Current scaling setting
> * QT_SCREEN_SCALE_FACTORS value
> [...]

This also explains why I couldn't reproduce. The QT_SCREEN_SCALE_FACTORS env variable is set on login only.

When logging out and in again between steps 2 and 3 of the original description, I can also reproduce when using a LibO version that doesn't have the patch yet.
Comment 10 Michael Weghorn 2019-03-30 20:38:30 UTC
The patch has been cherry-picked to master in the meanwhile. It wasn't referenced here automatically (probably because TDF bugzilla had some issues last night)

https://gerrit.libreoffice.org/plugins/gitiles/core/+/b4698a2241ec26d796c66da3a814f7cc693785b6

commit b4698a2241ec26d796c66da3a814f7cc693785b6
Author: Jan-Marek Glogowski <glogow@fbihome.de>
Date:   Fri Mar 29 02:58:59 2019 +0100

    tdf#124292 Qt5 / KDE5 disable Qt's HiDPI scaling
    
    LO does its own layouting and also all the scaling, so disable
    the automatic HiDPI scaling explicitly. Otherwise fonts will be
    rendered in LoDPI and just scaled as an image, if UI scaling is
    enabled in KDE, resulting in really blocky / ugly fonts.
    
    Change-Id: I38503ce27c1671e80d0749d21c6c6dcff1a808a6
    Reviewed-on: https://gerrit.libreoffice.org/69941
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>

-> fixed now, s.a. comment 8

Backport for 6.2: https://gerrit.libreoffice.org/#/c/69984/
Comment 11 Commit Notification 2019-03-30 22:46:57 UTC
Jan-Marek Glogowski committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/c3eeb421526f284419e90d2c4c4da5b0d7bbcc0e%5E%21

tdf#124292 Qt5 / KDE5 disable Qt's HiDPI scaling

It will be available in 6.2.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.