Bug 482481

Summary: Konsole forces full hinting (hintfull) despite both fontconfig and KDE settings
Product: [Applications] konsole Reporter: Boris B. <borisb.bgd>
Component: fontAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: normal CC: andrea.ippo, christian, CoelacanthusHex, kde, ninjalj, vasyl.demin, yumpusamongus+kde, zawertun
Priority: NOR Keywords: qt6
Version: 24.02.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Discrepancy between font rendering in the selection dialog vs the actual Konsole (in the background).
konsole with forced hinting vs foot with hintnone
an alternative fix that doesn't override fontconfig

Description Boris B. 2024-03-05 17:44:59 UTC
SUMMARY
I upgraded to KDE 6 today and found that Konsole now renders terminal fonts with full hinting. This looks awful with some fonts. The rest of the OS (even Konsole's own Appearance window) is respecting my global fontconfig (/usr/share/local.conf) and KDE System Settings -> Fonts, both of which set the font hinting to Slight.

STEPS TO REPRODUCE
1. Make sure your system configuration is set to slight hinting.
2. Start Konsole and go to "Edit Current Profile" -> "Appearance" -> "Select Font".

OBSERVED RESULT
Observe live the difference between font rendering in the Appearance preview sample and the actual terminal font behind it. Bold fonts with higher sizes show more difference. Not all fonts are affected the same.

EXPECTED RESULT
Konsole should follow the system settings and fontconfig for font hinting.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.8-arch1-1 (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Globally turning on autohinting makes it somewhat better (as in at least the rendering is the same as for the rest of the system) but is not a solution. However it does indicate that not _all_ settings are overridden by Konsole.
Comment 1 Andrea Ippolito 2024-03-18 11:18:45 UTC
Oh, maybe this explains why some of my favorite monospaced fonts look crappy now.

E.g. Red Hat Mono, Source Code Pro
Comment 2 ninjalj 2024-03-20 00:02:31 UTC
This was done because Qt6 removed QFont::ForceIntegerMetrics, which was what previous konsole versions used to force glyphs to conform to the character cell grid of a terminal.

Now, on Qt6, we enable full hinting for the same reason, see https://invent.kde.org/utilities/konsole/-/merge_requests/911
Comment 3 christian 2024-05-31 17:55:08 UTC
Ah, maybe this is what I'm seeing then. I upgraded to Fedora 40, so Plasma 6, and the Konsole rendering of my go-to font (Inconsolata) has changed a fair bit and no longer matches the preview in the font selection dialog. It looks like bold got turned on by accident. I'm attaching a screenshot.
Comment 4 christian 2024-05-31 17:55:56 UTC
Created attachment 170021 [details]
Discrepancy between font rendering in the selection dialog vs the actual Konsole (in the background).
Comment 5 Russell Haley 2024-06-02 21:19:43 UTC
Created attachment 170072 [details]
konsole with forced hinting vs foot with hintnone

In that MR, the comparison screenshot looks to have been made at 2x scale. For those of us with fewer pixels to throw at the problem, the effect of hinting is rather drastic. Observe the misshapen "f", the slight heaviness to the horizontal strokes (including double-thicc bold "n"), and the vague sense that everything is struck-through. The attached screenshot is *after* I increased the line spacing setting to 1px to make the vertical height match the unhinted Foot terminal.

Anyhow, I though Freetype removed full hinting several years ago, and only supports "none" and "slight", which is hinting in the vertical axis only. That might explain why Nate encountered bug 476768?
Comment 6 Matt Whitlock 2024-07-14 22:26:44 UTC
(In reply to ninjalj from comment #2)
> https://invent.kde.org/utilities/konsole/-/merge_requests/911

I reverted this misguided hack, and now my Konsole respects my fontconfig again. Thanks for the tip.

Now I'm wondering if Kate/KWrite's newly uglified font rendering in KDE 6 has the same root causeā€¦
Comment 7 Matt Whitlock 2024-07-15 00:24:04 UTC
Created attachment 171664 [details]
an alternative fix that doesn't override fontconfig

To fix the original issue without overriding the user's font configuration, the letter spacing can be adjusted to force the horizontal advance to be an integer. See the attached patch, which completely fixes the issue on my system. I now have a normal terminal font with full hinting, a bold variant of it with no hinting, and no weird space issues. In other words, Konsole's appearance now matches how it was in KDE 5.