After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 786398 - System font weight and style ignored
System font weight and style ignored
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: .General
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-08-17 07:21 UTC by simon
Modified: 2017-10-07 22:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to read system font weight and style from Xsettings daemon (3.87 KB, patch)
2017-08-17 07:23 UTC, simon
none Details | Review

Description simon 2017-08-17 07:21:36 UTC
The way the system font setting is handled by Xsettings in GTK+3 is incomplete.

If a system font is set as part of the theme files, in gtk.css or similar, then the font is displayed correctly as per the font-family, font-size, font-weight and font-style settings in the CSS.

However, the settings in here can be overridden if an Xsettings daemon is running, and in this case, the gtk-font-name field from the Xsettings daemon is used to provide the system font.

GTK+3 correctly reads the font family and size from the Xsettings daemon, but it makes no attempt to read other modifiers for the font, such as weight and style; this means that it is only possible to correctly display a system font which has no modifiers to weight or style, so bold or italic fonts cannot be used.
Comment 1 simon 2017-08-17 07:23:15 UTC
Created attachment 357768 [details] [review]
Patch to read system font weight and style from Xsettings daemon

This patch is a proposed fix for the issue; this has been tested to work on GTK+3.22 running under Raspbian Stretch.
Comment 2 Benjamin Otte (Company) 2017-08-17 19:17:58 UTC
This is by design.

GTK uses CSS for styling and the CSS spec defines a default weight and style. And I decided to respect the specification here so that theme writers can be sure that setting a different style or weight actually changes the font.
Comment 3 simon 2017-08-17 19:23:47 UTC
In that case, you need to remove the ability to override the font defined in the CSS with the value from the Xsettings daemon.

At the moment, if there is a gtk-font-name set in a running Xsettings daemon, the font set in the CSS file (including weight and style) is ignored, and the font family and size are read from Xsettings.

The current mechanism is broken in an environment with Xsettings; either get rid of support for gtk-font-name in Xsettings completely so that the font is correctly read from the CSS file, or properly support reading the entire font spec from Xsettings. It doesn't really matter which you do, but it is broken at the moment.
Comment 4 simon 2017-08-17 19:30:11 UTC
This is particularly relevant in an environment where there are both GTK+2 and GTK+3 applications running, because GTK+2 applications read the entire font specification from the Xsettings daemon, so one is assumed to be running with GTK+2. Therefore the chances are that in any environment where both GTK+2 and GTK+3 applications are being used, the font specification used for the GTK+2 applications will be partially read, causing the GTK+3 CSS font setting to be overridden.
Comment 5 Benjamin Otte (Company) 2017-08-17 20:14:25 UTC
CSS defines that the default font-name and default font-size are system-defined, so this is how GTK3 treats it.

I would have changed GTK2, too, but decided against it both because it's supposed to be stable and because people writing themes for GTK2 had to expect style and weight changes.

And yes, it would be preferable if settings daemons would only allow you to pick font + size, but they usually just use the default font chooser...
Comment 6 simon 2017-08-17 21:00:26 UTC
"CSS defines that the default font-name and default font-size are system-defined, so this is how GTK3 treats it."

Then why does the CSS allow you to set font-weight and font-style? You end up with a situation where you can select all attributes of a font using the CSS, but they are then overridden (and broken) by the Xsettings daemon only setting font-family and font-size.

I have GTK+2 and GTK+3 themes which are designed to be visually as close to identical as possible. My chosen system font uses a Light weight. With GTK+3 in the state it is in, it is impossible to correctly display a Light system font in GTK+3 applications, while it displays correctly in GTK+2 applications. This ruins any attempt to maintain a consistent appearance. This is surely not desirable behaviour, whatever the CSS specification says?

I disagree that it would be preferable if settings daemons restricted you to font and size only - it is perfectly valid to want to use a system font with a different weight. The weight is part of the full description of a font - arbitrarily ignoring it is not acceptable.

This behaviour is fundamentally broken at present. There should be some way to select a system font for GTK+3 applications which includes weight and style settings; at present, there is not. How can this be regarded as correct behaviour?
Comment 7 Benjamin Otte (Company) 2017-08-17 21:24:16 UTC
When I said "default" I meant the value that will be used when the theme does not override it. CSS themes are absolutely free to hardcode a font and then your xsettings will not have any effect at all.