Xfce doesn't set GNOME/Gtk3 dconf keys for theme and font

Bug #1769774 reported by Alistair Buxton on 2018-05-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
xfce4-terminal
Fix Released
Medium
terminator (Ubuntu)
Undecided
Unassigned
xfce4-settings (Ubuntu)
Undecided
Unassigned
xfce4-terminal (Ubuntu)
Undecided
Unassigned
xubuntu-default-settings (Ubuntu)
Undecided
Unassigned

Bug Description

tl;dr The part of this bug which applies specifically to Xubuntu is part 2. below. The gsettings.override should match the xfconf default, ie by adding something like:

[org.gnome.desktop.interface]
font-name='Noto Sans 9'
monospace-font-name='Monospace 10'

There will still be a mismatch if the user changes their font setting, but at least the defaults would match. Fixing the rest would require cooperation from GNOME which is unlikely to happen since all this code is deprecated under Wayland.

---

Xfce stores it's idea of the system default font, monospace font, and Gtk theme, icon theme etc into Xfconf:

/xsettings/Gtk/FontName
/xsettings/GtkMonospaceFontName
/xsettings/Gtk/ThemeName
/xsettings/Gtk/IconThemeName

GNOME stores it's idea of these settings in gsettings keys:

/org/gnome/desktop/interface/gtk-font-name
/org/gnome/desktop/interface/monospace-font-name
/org/gnome/desktop/interface/theme-name
/org/gnome/desktop/interface/icon-theme

When a Gtk+3 application is started, the desktop environment is responsible for transfering these settings to Gtk+3 using xsettings. You can see this happening by running:

    GDK_DEBUG=settings <gtk program>

There are several problems here:

1. The apps.

Gtk+3 has no concept of an xsetting for monospace font name. All Gtk+3 software which supports this concept finds the default by looking directly at the GNOME gsettings key. Including xfce4-terminal. This means none of that software pays any attention to Xfce's default. Including xfce4-terminal.

In addition, some apps seem to directly query gsettings to find the proportional font too, and some will even mix up xsettings and gsettings. An example of this is pidgin, where all bold text uses the font defined in gsettings, and all non-bold text uses the font defined in xsettings.

2. The distro defaults.

xubuntu-default-settings supplies default values for the distribution. It sets some of the GNOME gsettings keys to appropriate default values. For example it sets theme-name to Greybird and icon-theme to elementary-xfce. However it does not set defaults for the fonts. Proportional font defaults to Cantrell 11 and monospace is Monospace 11.

2. The settings tool.

Xfce appearance setting sets the Xfconf keys of course. But it does not touch any of GNOME's gsettings keys. So if you change your theme for example, the GNOME gsettings key will remain at the default set by xubuntu-default-settings ie Greybird. The setting is now wrong for both Xfce and GNOME.

Unfortunately the only correct fix for this is to persuade Gtk developers to adopt an xsetting for the monospace font, and anything else that is missing. This is extremely unlikely to happen as they are trying to remove as many cross-desktop features as possible. Also Gtk+3 is in maintenance mode so it wouldn't be available until we port Xfce to Gtk+4 at the earliest.

The only other alternative that will work is to make Xfce appearance settings capable of writing to gsettings, and mirroring all the appearance settings there. This is a horrible solution because those settings are supposed to be private to GNOME, and because appearance settings will need two different settings backends.

The one thing we CAN do is patch all Xfce apps to use Xfconf to read this setting. All GNOME apps and cross-desktop apps like Terminator will continue to use the wrong fonts unless the user install dconf-editor or gnome-tweak.

Screenshot attached. Desktop is Xfce.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: terminator 1.91-1
ProcVersionSignature: Ubuntu 4.15.0-20.21-generic 4.15.17
Uname: Linux 4.15.0-20-generic x86_64
ApportVersion: 2.20.9-0ubuntu7
Architecture: amd64
CurrentDesktop: XFCE
Date: Tue May 8 00:52:18 2018
InstallationDate: Installed on 2018-05-07 (0 days ago)
InstallationMedia: Xubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
PackageArchitecture: all
SourcePackage: terminator
UpgradeStatus: No upgrade log present (probably fresh install)

Alistair Buxton (a-j-buxton) wrote :
Stephen Boddy (stephen-j-boddy) wrote :

I'm pretty sure that you are tripping over the fact that terminator is gtk3 and checks in the gnome standard location. I'm not sure if xfce attempts to set the right fonts for the various desktops (i.e. gnome gtk2 and gtk3, kde, etc). I would argue that it is better to have the desktop set these values, rather than have every application trying to detect every desktop and parse their various ways of setting default fonts.

Changed in terminator (Ubuntu):
status: New → Opinion
Alistair Buxton (a-j-buxton) wrote :

I agree. Can you tell me where Gtk3 sets those standards, so that I can check?

Stephen Boddy (stephen-j-boddy) wrote :

$ dconf read /org/gnome/desktop/interface/monospace-font-name
'Hack Regular 10'

Hope that helps.

Alistair Buxton (a-j-buxton) wrote :

dconf command has no output for that. I assume because the value is set to the default.

dconf-editor does show it though, and after I changed it to match the rest of the desktop, dconfcli shows it too.

This makes Terminator show the right font.

I have added xfce4-settings because Xfce Appearance settings should set this key if the user changes font, and xubuntu-default-settings because the default doesn't match the Xubuntu default.

The same applies to /org/gnome/desktop/interface/font-name which is set to Cantrell by default in Xubuntu.

There is also the theme: /org/gnome/desktop/interface/gtk-theme

By default in Xubuntu this is set to Greybird which is correct as the default. But changing the theme in Appearance does not change this key.

summary: - Terminator uses the wrong font when system default is selected
+ Xfce doesn't set GNOME/Gtk3 dconf keys for theme and font
Alistair Buxton (a-j-buxton) wrote :

Here is the code which tries to figure out the system default font: https://bazaar.launchpad.net/~gnome-terminator/terminator/gtk3/view/head:/terminatorlib/config.py#L368

I went and asked on #gtk+ about this and this is what they said about the dconf/gsettings keys:

(20:20:58) ali1234: so why doesn't gtk2 use either of those? [font-name and monospace-font-name gsettings keys]
(20:21:16) Company: neither does GTK3
(20:21:28) Company: unless you use Wayland
(20:21:35) Company: and GTK2 doesn't support Wayland
(20:21:44) Company: gnome-settings-daemon uses them
(20:22:17) Company: which is why it's originally an /org/gnome/... setting - it's for the GNOME settings daemon
(20:22:47) Company: could also be gnome-session or whatever
(20:23:04) TingPing: gsd-xsettings reads them and converts it to xsettings
(20:23:19) Company: well, the setting is transfered to GTK apps by means of Xsettings
(20:27:19) Company: also: GDK_DEBUG=settings prints the XSettings on startup I think

So it is my understanding that Terminator should look at xsettings rather than going directly to gsettings/dconf over DBus, since gsettings may not even be in use at all.

The GDK_DEBUG variable shows that the correct xsettings fonts are being passed to Terminator, it just ignores them.

Stephen Boddy (stephen-j-boddy) wrote :

On my Ubuntu / Unity desktop neither Terminator, the default gnome-terminal, or tilix display anything related to monospaced fonts with the GDK_DEBUG=settings prefix. (There is a proportional system font returned, but that's not what we're interested in here.)

In the gnome-terminal source (which is effectively the bible so far as Terminator is concerned for how to do things)...
https://github.com/GNOME/gnome-terminal/blob/master/src/terminal-app.h#L33
and
https://github.com/GNOME/gnome-terminal/blob/master/src/terminal-app.c#L1135

Same in tilix...
https://github.com/gnunn1/tilix/blob/master/source/gx/tilix/preferences.d#L26
and
https://github.com/gnunn1/tilix/blob/master/source/gx/tilix/terminal/terminal.d#L2330

Those are only querying gsettings exactly the same as we are.

If there was an easy way to query xsettings then I suppose it could be added as a fallback but, so far as I can tell, there is no commonly used/accepted python module for querying xsettings.

Alistair Buxton (a-j-buxton) wrote :

For extra fun, even xfce4-terminal queries gsettings directly for the system monospace font, which means it doesn't follow the xfce default font setting either:

https://github.com/xfce-mirror/xfce4-terminal/blob/5a8581ff9cf2b300c3be5278652d7051517a88da/terminal/terminal-screen.c#L2658

Alistair Buxton (a-j-buxton) wrote :

Xfce sets the xsetting for monospace font, but Gtk+3 ignores it:

Gdk-Message: 23:32:18.664: Gtk/MonospaceFontName = "Monospace 9.5"
Gdk-Message: 23:32:18.664: ==> unknown to GTK

So Gtk+3 doesn't have any way to get the monospace font from xsettings, contrary to what I was told on IRC. :(

description: updated
description: updated
description: updated

Should this be added to xubuntu-default-settings.gsettings-override to match the Xfce font settings?

[org.gnome.desktop.interface]
gtk-theme='Greybird'
icon-theme='elementary-xfce-darker'
font-name='Noto Sans 9'
monospace-font-name='Monospace 10'

description: updated
description: updated
description: updated
Sean Davis (bluesabre) wrote :
Changed in xubuntu-default-settings (Ubuntu):
status: New → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xubuntu-default-settings - 19.04

---------------
xubuntu-default-settings (19.04) disco; urgency=medium

  * Add Terminal (F4) and Find (Primary+Shift+F) shortcuts to Thunar (LP: #1793395)
    - etc/xdg/xdg-xubuntu/Thunar/accels.scm
    - etc/xdg/xdg-xubuntu/Thunar/uca.xml.in
  * debian/xubuntu-default-settings.gsettings-override:
    - Set GNOME/GTK 3 dconf keys for fonts (LP: #1769774)
  * etc/xdg/xdg-xubuntu/autostart/xfce4-tips-autostart.desktop
    - Removed, obsolete (LP: #1805005)
  * etc/xdg/xdg-xubuntu/Thunar/uca.xml.in:
    - Enable startup-notify in Thunar's uca.xml (LP: #1794118)
  * etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml:
    - Add shortcut for xfce4-screenshooter region capture (Shift+Print) (LP: #1812234)
  * etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml:
    - Set default inactivity mode to Suspend on AC and battery (LP: #1768038)
  * etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfprint.xml
    - Removed, obsolete (LP: #1805007)
  * usr/share/xubuntu/applications/defaults.list:
    - Replace invalid macroEnabled mimetypes (LP: #1802582)
    - Remove invalid x-scheme-handler/file handler (LP: #1778069)

 -- Sean Davis <email address hidden> Mon, 28 Jan 2019 22:44:14 -0500

Changed in xubuntu-default-settings (Ubuntu):
status: Fix Committed → Fix Released

Terminal uses dconf org.gnome.desktop.interface.monospace-font-name font rather than xsettings one.

Related topic:
https://forum.xfce.org/viewtopic.php?id=12277

Changed in xfce4-terminal:
importance: Unknown → Medium
status: Unknown → Confirmed
In , Gitbot (gitbot) wrote :

Igor referenced this bugreport in commit 4119272d6e64de6b95a89f03c7176ac6cc6869ec

Respect Xfce monospace font setting

https://git.xfce.org/apps/xfce4-terminal/commit?id=4119272d6e64de6b95a89f03c7176ac6cc6869ec

Added support for xsettings, thanks!

Changed in xfce4-terminal:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.