Bug 1943794

Summary: GTK4 font rendering quality worse than GTK3
Product: [Fedora] Fedora Reporter: James <james>
Component: gtk4Assignee: Kalev Lember <klember>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 34CC: fedora, gnome-sig, joshas, katyaberezyaka, klember, mcatanza, mclasen
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-16 21:33:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Screenshots comparing GTK4 and GTK3 font rendering
none
Same comparison with GTK 4.0.3 on F33 none

Description James 2021-03-27 13:17:52 UTC
Created attachment 1766890 [details]
Screenshots comparing GTK4 and GTK3 font rendering

Description of problem:
The font rendering of GTK4 is unexpectedly worse than GTK3. Primarily, the anti-aliasing does not respect hinting (or it is not hinting the same way as before) resulting in 'fuzziness' most visible on horizontal strokes.

The attached image compares GTK4 and GTK3 with their respective demo programs. Note the crisper rendering on the GTK3-side.

This is with RGB subpixel anti-aliasing and slight hinting enabled in both dconf and fonts.conf (reproduced below).

Version-Release number of selected component (if applicable):
gtk4-4.1.2-1.fc34.x86_64
gtk3-3.24.27-1.fc34.x86_64
pango-1.48.3-1.fc34.x86_64
freetype-2.10.4-3.fc34.x86_64
harfbuzz-2.7.4-3.fc34.x86_64

Expected results:
Glyphs rendered identically to GTK3.

fonts.conf content:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>True</bool>
  </edit>
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
  <edit mode="assign" name="lcdfilter">
   <const>lcddefault</const>
  </edit>
 </match>
 <dir>~/.fonts</dir>
</fontconfig>

Comment 1 James 2021-03-27 22:28:35 UTC
Created attachment 1766990 [details]
Same comparison with GTK 4.0.3 on F33

Screenshots added for comparison: gtk4-4.0.3-1.fc33.x86_64 on Fedora 33 has what I consider the correct rendering behaviour.

Comment 2 Kalev Lember 2021-03-27 22:47:03 UTC
Could you file this upstream https://gitlab.gnome.org/GNOME/gtk, please?

Comment 3 Kalev Lember 2021-03-27 22:48:39 UTC
Actually, looks like there's already a ticket upstream: https://gitlab.gnome.org/GNOME/gtk/-/issues/3787

Comment 4 James 2021-03-27 22:52:06 UTC
(In reply to Kalev Lember from comment #3)
> Actually, looks like there's already a ticket upstream:
> https://gitlab.gnome.org/GNOME/gtk/-/issues/3787

Ah yes. Noted, I'll keep an eye on it.

Comment 5 Christian Stadelmann 2021-06-06 15:00:02 UTC
(In reply to Kalev Lember from comment #3)
> Actually, looks like there's already a ticket upstream:
> https://gitlab.gnome.org/GNOME/gtk/-/issues/3787

It seems like upstream denies the existence of this bug.

Comment 6 James 2021-06-25 23:24:09 UTC
Are all stakeholders/CCs here happy for me to close this bug as UPSTREAM (and subscribe to GNOME Gitlab #3787)? I don't think there's much point cluttering RHBZ by keeping it open here.

Comment 7 Michael Catanzaro 2022-08-16 21:09:41 UTC
We will deviate from upstream here.

Comment 8 Michael Catanzaro 2022-08-16 21:50:56 UTC
Well this is built for rawhide as gtk4-4.7.2-2.fc38. I'm having trouble building for F37 due to koji availability issues, but the patch is applied to the dist-git repo so it will get picked up next time somebody manages to build it.