Bug 416001 - konsole (and other QWidgets based applications) don't respect font hinting configuration
Summary: konsole (and other QWidgets based applications) don't respect font hinting co...
Status: RESOLVED UPSTREAM
Alias: None
Product: konsole
Classification: Applications
Component: font (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-08 13:40 UTC by Andrzej Rybczak
Modified: 2020-02-04 12:14 UTC (History)
5 users (show)

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


Attachments
Demonstration of different rendering of Dejavu Sans Mono 10pt in konsole (357.69 KB, image/png)
2020-01-08 13:40 UTC, Andrzej Rybczak
Details
hinting_comparison_among_apps.png (404.00 KB, image/png)
2020-01-10 11:09 UTC, Matt Whitlock
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrzej Rybczak 2020-01-08 13:40:38 UTC
Created attachment 124973 [details]
Demonstration of different rendering of Dejavu Sans Mono 10pt in konsole

SUMMARY

After a system update (a bunch of plasma apps were upgraded from 5.17.4 to 5.17.5) konsole (and kwrite btw) renders fonts differently than the rest of applications (see attached screenshot for details).

STEPS TO REPRODUCE
1. Check out DejaVu Sans Mono font in system settings and in konsole settings.

OBSERVED RESULT
Fonts are rendered differently in konsole/kwrite than the rest of apps.

EXPECTED RESULT
Fonts are rendered the same way in konsole/kwrite as the rest of apps.

SOFTWARE/OS VERSIONS
Linux: Arch Linux, kernel 5.4.8-arch1-1
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.65.0
Qt Version: 5.14.0
Comment 1 Mariusz Glebocki 2020-01-08 17:10:46 UTC
@Nate Graham please elaborate on this new title. Font preview on the screenshot is monospace (because the font is). Looks like different hinting.
Comment 2 Nate Graham 2020-01-08 17:42:59 UTC
So they are, my mistake, sorry.
Comment 3 Andrzej Rybczak 2020-01-09 05:49:25 UTC
Indeed. I compared hintings and it looks like hintnone fontconfig setting (even though I'm using hintfull systemwide).
Comment 4 Mariusz Glebocki 2020-01-09 07:09:05 UTC
I think that's not Konsole bug - it affects other Qt Widget apps. System settings uses QtQuick/Kirigami. Can you verify other QtQuick app? E.g. plasma discover (with main system font set to monospace one). Maybe system settings applies selected hinting for its own preview but for some reason does not apply it system-wide.
Comment 5 Matt Whitlock 2020-01-10 11:09:50 UTC
Created attachment 125011 [details]
hinting_comparison_among_apps.png

I just rebooted my system after some updates, and now I too am seeing that Konsole no longer respects my hinting configuration for DejaVu Sans Mono.

I have hinting disabled system-wide except for small sizes of DejaVu Sans Mono.


Here is my ~/.config/fontconfig/fonts.conf:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <dir>~/.fonts</dir>
 <match target="font">
  <edit mode="assign" name="embeddedbitmap">
   <bool>false</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>false</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintnone</const>
  </edit>
 </match>
 <match target="font">
  <test name="family">
   <string>DejaVu Sans Mono</string>
  </test>
  <test compare="less_eq" name="weight">
   <const>normal</const>
  </test>
  <test compare="less_eq" name="size">
   <double>15</double>
  </test>
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
  <edit mode="assign" name="hintstyle">
   <const>hintfull</const>
  </edit>
 </match>
</fontconfig>


Fontconfig definitely picks up my override:

$ fc-match -v 'Consolas' | fgrep -e hint -e file
        hintstyle: 0(i)(w)
        hinting: False(w)
        autohint: False(s)
        file: "/usr/local/share/fonts/win10/consola.ttf"(w)
$ fc-match -v 'Noto Sans Mono' | fgrep -e hint -e file
        hintstyle: 0(i)(w)
        hinting: False(w)
        autohint: False(s)
        file: "/usr/share/fonts/noto/NotoSansMono-Regular.ttf"(w)
$ fc-match -v 'DejaVu Sans Mono' | fgrep -e hint -e file
        hintstyle: 3(i)(w)
        hinting: True(w)
        autohint: False(s)
        file: "/usr/share/fonts/dejavu/DejaVuSansMono.ttf"(w)


But Konsole ignores my override and renders DejaVu Sans Mono without hinting.

Some other KDE applications, such as KCharSelect, do respect my hinting override, but others, such as Kate, do not. Chromium does. See my attached screen shot for comparisons.
Comment 6 Matt Whitlock 2020-01-10 11:22:20 UTC
These reports appear to regard the exact same issue:

https://phabricator.kde.org/D26185
https://bugreports.qt.io/browse/QTBUG-80967
Comment 7 Matt Whitlock 2020-01-10 11:31:17 UTC
Adding the following to a script in ~/.config/plasma-workspace/env/ and restarting my KDE session makes my Konsole behave correctly again:

# work around https://bugreports.qt.io/browse/QTBUG-80967
export QT_ENABLE_HIGHDPI_SCALING=0
Comment 8 Christoph Feck 2020-01-20 12:40:48 UTC
The referenced Qt bug was fixed for Qt 5.14.1. Is there anything that needs to be done in Konsole?
Comment 9 Matt Whitlock 2020-01-20 16:15:29 UTC
I haven't upgraded Qt yet, but my expectation is that this bug is no more.
Comment 10 Wolfgang Bauer 2020-02-04 12:14:46 UTC
On my (non-HiDPI) system with Qt 5.14.1, the fonts in konsole now look exactly the same again regardless whether QT_AUTO_SCREEN_SCALE=0 (or QT_ENABLE_HIGHDPI_SCALING=0) is set or not, while there were noticable differences (i.e. distortions without QT_AUTO_SCREEN_SCALE=0) with Qt 5.14.0.

So AFAICT, the problem is indeed fixed, and that probably also confirms that it really was an upstream problem in Qt... ;-)