Bug 487714 - Synchronize more font settings to gtk
Summary: Synchronize more font settings to gtk
Status: CONFIRMED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_style (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-28 21:37 UTC by Ilya Fedin
Modified: 2025-11-24 02:45 UTC (History)
9 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Fedin 2024-05-28 21:37:04 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
I checked gtk settings on my machine and found that kde-gtk-config seem to not to sync anything except of gtk-font-name. But there's more to sync (description / settings.ini key / gsettings key / xsettings key):

Antialiasing (0 / 1): gtk-xft-antialias / org.gnome.desktop.interface.font-antialiasing (none / grayscale / rgba) / Xft/Antialias
Hinting (0 / 1): gtk-xft-hinting / <none> / Xft/Hinting
Hint style (hintnone / hintslight / hintmedium / hintfull): gtk-xft-hintstyle / org.gnome.desktop.interface.font-hinting / Xft/HintStyle
RGB subpixel order (rgba (none) / rgb / bgr / vrgb / vbgr): gtk-xft-rgba / org.gnome.desktop.interface.font-rgba-order / Xft/RGBA
Monospace font: <none> / org.gnome.desktop.interface.monospace-font-name / <none>
Document font (KDE doesn't seem to have this, perhaps set the general one?): <none> / org.gnome.desktop.interface.document-font-name / <none>

STEPS TO REPRODUCE
1. Check settings.ini / org.gnome.desktop.interface section in dconf-editor / dump_xsettings

OBSERVED RESULT
Font settings to be set

EXPECTED RESULT
Font settings aren't set except of gtk-font-name (general font)

SOFTWARE/OS VERSIONS
Operating System: NixOS 24.11
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1
Kernel Version: 6.9.1-zen1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Memory: 5.7 ГиБ of RAM
Graphics Processor: AMD Radeon Vega 8 Graphics
Comment 1 Nate Graham 2024-06-10 23:33:34 UTC
Good idea, wanna submit a patch?
Comment 2 Ilya Fedin 2024-06-27 06:02:21 UTC
No, unlikely I will do that... 😅
Comment 3 Ilya Fedin 2024-09-30 23:09:04 UTC
Since gtk 4.16, one has to set a new setting to 'manual' for other font rendering settings to work: gtk-font-rendering / org.gnome.desktop.interface.font-rendering / <none>

https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7113

The MR also mentions a settings.ini-only gtk-hint-font-metrics setting (which is not new) that control subpixel positioning of text
Comment 4 Björn Bidar (Thaodan) 2025-03-28 05:03:30 UTC
Related to this I found that the font settings don't forward the monospace font setting through to GTK.
I tried to set my fonts in Emacs through gsettings so they can use the KDE settings. gsettings doesn't match with the KDE settings.
Comment 5 Reilly Brogan 2025-09-04 20:28:09 UTC
Plasma 6.5 will support setting monospace-font-name and document-font-name. I didn't implement any of the other settings since I didn't understand them well enough to feel confident messing with them.
Comment 6 Ilya Fedin 2025-09-04 22:05:16 UTC
That's quite sad... Antialiasing/hint settings are the most important as you see the result of them in any GTK application. While for monospace or document font you would need a gnome terminal/editor/etc which I guess isn't used by much users.
Comment 7 Reilly Brogan 2025-09-19 02:38:25 UTC
(In reply to Ilya Fedin from comment #6)
> That's quite sad... Antialiasing/hint settings are the most important as you
> see the result of them in any GTK application. While for monospace or
> document font you would need a gnome terminal/editor/etc which I guess isn't
> used by much users.

I think there are a decent number of people who prefer ptyxis or ghostty over konsole, so this will benefit them. I also prefer meld over any of the Qt diff visualizers and that uses monospace-font.

Really I was surprised at how easy it was to add support for those to kde-gtk-config. The code infra is already in place to update the gtk settings files and gsettings, so if you know how these settings _should_ be mapped you can go ahead and do it yourself easily enough.
Comment 8 Björn Bidar (Thaodan) 2025-10-28 15:08:36 UTC
After the change below I'm no longer able to find the correct font in Emacs when it tries to pick the font configuration from GTK:
https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/133

The main thing I noticed that the "," in between the font name and size seems to be the issue.
When I try to search the relevant setting (org.gnome.desktop.interface monospace-font-name) then the results don't include
a "," between the font name and size.
It usually "<fontname> <size>".

That or no size seems to work fine when setting the value using gsetttings set.
Comment 9 Björn Bidar (Thaodan) 2025-10-28 15:54:21 UTC
The Gesettings schema for org.gnome.desktop.interface confirms that there should be no comma between
the font name and font size. Check the default value for the monospace-font-name property.
Comment 10 Ilya Fedin 2025-10-28 16:24:13 UTC
FWIW, the value of the option isn't just <font name> <font size>, it's a result of https://docs.gtk.org/Pango/method.FontDescription.to_string.html

With some fonts, it could be seen that the value is different from font family name (which was a problem when Qt's QGtk3Theme was attempting to read GTK's font settings with QFont rather than pango_font_description_from_string).
Comment 11 Björn Bidar (Thaodan) 2025-11-03 08:35:29 UTC
Oh that's a good point there.
That does seem to lineup with what I have seen that
the font name in the setting seems off, like it would use the display
name instead of the font name.
Comment 12 Bug Janitor Service 2025-11-08 18:49:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/138
Comment 13 Nate Graham 2025-11-14 15:55:45 UTC
Git commit a12a2a4b13d5400852aa0c12d70755cf87fd2105 by Nate Graham, on behalf of Reilly Brogan.
Committed on 14/11/2025 at 15:55.
Pushed by ngraham into branch 'master'.

Fix formatting for gsettings font configurations

As mentioned in 487714 the new monospace font setting is causing issues with
emacs. This is because the schema for font settings
(https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/blob/gnome-49/schemas/org.gnome.desktop.interface.gschema.xml.in?ref_type=heads#L107
specifies that they should be in the format `$fontFamily $fontStyle $pointSize`

(IE `Hack Bold 14`)

whereas we were adding it as `$fontFamily, $fontStyle $pointSize`

(IE `Hack, Bold 14`).

Fix this by removing the extra comma when inserting font settings into the
gsettings database only. I verified that this format is indeed what it looks
like when the setting is changed via gnome-tweaks.

M  +4    -4    kded/configvalueprovider.cpp
M  +2    -2    kded/configvalueprovider.h
M  +5    -4    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/-/commit/a12a2a4b13d5400852aa0c12d70755cf87fd2105
Comment 14 Nate Graham 2025-11-14 16:36:58 UTC
Git commit adee4741e159c11912629b4a87bb43ede127ac79 by Nate Graham.
Committed on 14/11/2025 at 16:30.
Pushed by ngraham into branch 'Plasma/6.5'.

Fix formatting for gsettings font configurations

As mentioned in 487714 the new monospace font setting is causing issues with
emacs. This is because the schema for font settings
(https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/blob/gnome-49/schemas/org.gnome.desktop.interface.gschema.xml.in?ref_type=heads#L107
specifies that they should be in the format `$fontFamily $fontStyle $pointSize`

(IE `Hack Bold 14`)

whereas we were adding it as `$fontFamily, $fontStyle $pointSize`

(IE `Hack, Bold 14`).

Fix this by removing the extra comma when inserting font settings into the
gsettings database only. I verified that this format is indeed what it looks
like when the setting is changed via gnome-tweaks.


(cherry picked from commit a12a2a4b13d5400852aa0c12d70755cf87fd2105)

593dcb95 Fix formatting for gsettings font configurations

Co-authored-by: Reilly Brogan <site.kde@reillybrogan.com>

M  +4    -4    kded/configvalueprovider.cpp
M  +2    -2    kded/configvalueprovider.h
M  +5    -4    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/-/commit/adee4741e159c11912629b4a87bb43ede127ac79
Comment 15 Daniel Pereira 2025-11-24 02:14:25 UTC
I've recently updated kde-gtk-config to 6.5.3 (where commit adee4741e159c11912629b4a87bb43ede127ac79 was introduced).

This change introduces a new issue, where fonts with spaces in names (eg. "Roboto Condensed") don't get set properly for GTK applications.

When I set it using the "old" pattern (with comma) it seems to work fine and Pango can find it properly. But using the new pattern, it will match the font "Roboto" instead.

```
gsettings set org.gnome.desktop.interface font-name 'Roboto Condensed, 12'  # Renders correctly as expected
gsettings set org.gnome.desktop.interface font-name 'Roboto Condensed  12'  # Renders as Roboto 12
```
Comment 16 Daniel Pereira 2025-11-24 02:45:38 UTC
Reviewing the change aforementioned, it doesn't seem to line up with the comment #10, and that indeed seems to be the cause of the issue above.

Adding a comma or not should probably be delegated to Pango FontDescription#to_string, but I assume adding the dependency might be cumbersome. Using heuristics to generate it might work for now, but it's fragile to future changes or conditions we aren't aware of. If we decide to go down this route, in my tests, it seems that the comma is only added after the font name when it has spaces (ex.: "Roboto Condensed")