Fixing the GTK UI font in my Fedora 23 setup
When I upgraded my office machine from Fedora 22 to Fedora 23, one thing I noticed immediately is that some of the fonts in a number of my applications had changed. After I looked at things for a while, it was clear that the font used for UI elements in GTK based applications had shrunk between Fedora 22 and Fedora 23. This font is used, for example, for Firefox's URL bar and in much of Liferea's interface, although in both cases the actual content (web pages and feed entries) was not affected. Trying to fix this sent me down a whole bunch of rabbit holes, because I don't use an existing desktop environment that has all of this solved and integrated; instead I have my own minimal desktop, which leaves me on my own to solve this sort of thing.
The first thing I discovered is that changing font settings in gnome-tweak-tool (for GTK 3) or gconf-editor (for GTK 2) didn't seem to do anything. The changes clearly got saved, but they didn't change how Firefox, Liferea, and so on looked (even when set to absurd values that should have forced clear changes). It turns out that GTK applications don't seem to look this information up directly (or at least not things like global font settings); instead they have an entire protocol to communicate with a settings daemon. If you do not have a settings daemon running, at least in Fedora 23 your applications use default values and ignore your theoretical changes. So it turned out that the first thing I needed was a settings daemon.
Gnome has one of these, gnome-settings-daemon, but it turns out
that there are better options, because of course this is actually
a freedesktop standard
called XSettings. I wound up with xsettingsd, which is a simple daemon
with a simple configuration system, and apparently XFCE also has
a relatively lightweight daemon that can be
configured via a GUI.
Part of what I like about xsettingsd
is that it can be told to
only make a very few settings available, which is what I want
here; I only really want to fix my font issues, not start having
to maintain lots of GTK configuration options.
(I stumbled over this via the ArchWiki page on font configuration; see also their page on GTK+. One issue with just running gnome-settings-daemon is that it has a whole bunch of side effects, since it expects to be run as part of an integrated Gnome environment.)
Fiddling with the Gtk/FontName
XSetting got me close to the Fedora
22 appearance but not quite on it; my best result was setting the
font to 'Sans 11' (which made things not obnoxiously small or
constantly bold). To solve the mystery of what actual font and font
size my applications were using on Fedora 22, I resorted to brute
force using my home machine (which is still running Fedora 22) via
fontconfig debugging options:
FC_DEBUG=1025 liferea
Per the fontconfig documentation, this dumps out enough information that you can determine what fonts the application is using at what font sizes. You get reports like:
Match Pattern has 25 elts (size 32) family: [...] [...] size: 10.4443(f)(s) [...] Best score [...] Pattern has 23 elts (size 23) family: "DejaVu Sans"(w) familylang: "en"(w) style: "Book"(w) [...]
Although someone who understands fontconfig can probably get a lot more out of these messages, for me this says that Liferea wound up getting DejaVu Sans at size '10.4443' [sic].
That weird fractional size turned out to be the missing piece of the puzzle. Although the Fedora default GTK UI font is apparently 'Sans 10' in both Fedora versions, in my Fedora 22 setup this was being scaled up just a bit and so it became Sans at 10.4443. In Fedora 23, it was no longer getting scaled up; 'Sans 10' was 10 points and so shrunk compared to Fedora 22. 'Sans 11' was of course just a bit bigger still.
(I suspect that Fedora 22 GTK was doing some DPI related scaling, although I can't make the numbers come out exactly right for scaling from 96 DPI. Fedora 23 may have dropped this scaling or it may have changed some DPI related thing in the environment so that no scaling gets done.)
Somewhat to my happy surprise, you can actually set Gtk/FontName
to "Sans 10.4443" and have it work. On my Fedora 22 machine, the
resulting font sizes are exactly the same with and without xsettingsd
running, so I expect that when I get back to work tomorrow this
will make Fedora 23 be completely happy.
On the whole this has been a very educational experience, even if it did basically eat up much of my day and frustrated me during chunks of it. I've learned a bunch more about how the Gnome and GTK environment operate, got a potentially useful surprise about Xft fonts and in the process I wound up stumbling over several other issues that are going to improve my environment a bit.
(I have some stuff to write about on XSettings and related issues, but this entry is already long enough so that's going in another entry.)
|
|