Bug 444361

Summary: A lot of GTK based apps have broken fonts
Product: [Plasma] kwin Reporter: Bacteria <dev.bacteriostat>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: dev.bacteriostat, nate, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.23.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Veracrypt
Chromium (Wayland)
Firefox

Description Bacteria 2021-10-25 09:28:43 UTC
Created attachment 142848 [details]
Veracrypt

SUMMARY
A lot of GTK apps have weird broken fonts when launched in wayland. I have added attachments for some applications which include Firefox, Chromium, Veracrypt.

I also have a solution for the fonts which is to use GTK_USE_PORTAL=0. But the theme is still broken.

The apps look fine under X.

I am not sure if this bug goes here. 

STEPS TO REPRODUCE
1. Launch a GTK application in Wayland. You can check if the app is really using wayland using xeyes program.

OBSERVED RESULT
The fonts are broken and the theme looks like the default GTK theme.

EXPECTED RESULT
The application should use Breeze GTK like it does on X.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
(available in About System)
KDE Plasma Version: 5.23.1
KDE Frameworks Version: 5.87
Qt Version: 5.15.2
Comment 1 Bacteria 2021-10-25 09:29:05 UTC
Created attachment 142849 [details]
Chromium (Wayland)
Comment 2 Bacteria 2021-10-25 09:32:08 UTC
Created attachment 142851 [details]
Firefox
Comment 3 Nate Graham 2021-10-25 20:56:30 UTC
Not following the Breze GTK theme is probably because they're either flatpak apps, or using GTK4 with libadwaita, both of which don't work properly with 3rd-party themes.

However that is not related to the issue with text, which could possibly be a KWin issue. I've seen this in the past, but it's not 100% reproducible for me.
Comment 4 Bacteria 2021-10-26 05:05:34 UTC
(In reply to Nate Graham from comment #3)
> Not following the Breze GTK theme is probably because they're either flatpak
> apps, or using GTK4 with libadwaita, both of which don't work properly with
> 3rd-party themes.

All the apps are from the Arch repository and all of them either depend on GTK2 or GTK3. Also, if I force the apps to open using X using env variable GDK_BACKEND=x11, the apps do follow Breeze GTK. This issue only appears on Wayland. 

Do Wayland GTK apps on your machine follow Breeze GTK?

> However that is not related to the issue with text, which could possibly be
> a KWin issue. I've seen this in the past, but it's not 100% reproducible for
> me.

The fonts issue is actually only reproducible when launching GTK apps from terminal which I first did to test chromium and firefox with Wayland. When I added the flags that enable wayland in the application launcher, the fonts issue did not appear. Looks like Plasma is giving some additional info to the application that terminal isn't.
Comment 5 Nate Graham 2021-10-26 16:45:07 UTC
> All the apps are from the Arch repository and all of them either depend on GTK2 or
> GTK3. Also, if I force the apps to open using X using env variable GDK_BACKEND=x11
> the apps do follow Breeze GTK. This issue only appears on Wayland. 
When they use the Breeze GTK style, do the font issues go away?
Comment 6 Bacteria 2021-10-26 17:58:30 UTC
(In reply to Nate Graham from comment #5)
> When they use the Breeze GTK style, do the font issues go away?

Yes, both the font and breeze GTK theme issues go away when using GDK_BACKEND=x11.
Comment 7 Nate Graham 2021-10-26 20:14:49 UTC
Moving back to KWin, then, since the problem is seen when not using the breeze-gtk theme.
Comment 8 Bacteria 2021-10-27 03:38:21 UTC
I managed to fix the issue and I feel like an idiot for not trying it before hand.

I applied the adwaita theme in the system settings and then applied breeze GTK theme again. And the issue got fixed. All the GTK apps are using Breeze-GTK now. Looks like Plasma Wayland was reading the config somewhat differently than X and reapplying it solved it.

But launching any gtk application from the terminal still has the same issues, the apps don't use breeze-gtk and have the broken fonts.

I guess we should probably close this now?
Comment 9 Nate Graham 2021-10-27 04:07:03 UTC
Well, the apps shouldn't be opening with the wrong theme from the command line either. That seems like probably a GTK problem though.
Comment 10 Bacteria 2021-10-28 11:14:08 UTC
The ArchWiki suggests to put GTK_USE_PORTAL=1 to force Firefox to use KDE's file picker instead of GTK one. But this seems to be having a side effect on the Breeze GTK theme.

This was all fine on X but Wayland seems to have altered the behavior. So this might just be an upstream change.

I had set GTK_USE_PORTAL=1 as per ArchWiki's recommendation because of which this was happening and this also explains why GTK_USE_PORTAL=0 fixed the issue.