Red Hat Bugzilla – Bug 1466254
'xset fp rehash' does not work without X server running
Last modified: 2017-09-01 06:04:19 EDT
Description of problem:
I'm currently preparing new fonts package for Fedora, and I'm following the outdated Fedora Packaging Guidelines (FPG) for fonts (Fonts Policy). Many information there are no longer valid, so I'm using other resources (normal FPG, mailing lists, other information) on how to properly package the fonts.
Which lead me to the use of 'xset fp rehash' - a command to udpate the X11 Logical Font Description database, which is still AFAIK used in Fedora by e.g. older applications that have not switched to fontconfig yet.
I'm crossreferencing the Arch Wiki for this:
In my font package I correctly create the symlink in /etc/X11/fontpath.d/ to point the my fonts folder installation in Fedora. But IIUIC, it still needs the 'xset fp rehash' command to be called for the font database to be correctly updated.
This is where I get to my problem. The 'xset fp rehash' correctly works when I have GUI running (by GUI I actually mean X server, because I'm on F25, using Cinnamon). But it does not work when I try to run the command while the X server is not running.
I realize that it might sound strange to use the X11 utility when no X server is running, but this utility is used just to update the font database. There shouldn't be any need for the X server to be running for the database update.
When user does an update via 'dnf upgrade' when his X server is running, then everything is OK. The problem occurs when the X server is not running for whatever reason user might have. For example:
* Using Wayland instead of X server (?)
* Using different tty which does not have X server running or does not have $DISPLAY set (might happen on both Server or Workstation) - e.g. administrator might connect via SSH and do the 'dnf upgrade' with X11 forwarding
* Using the Gnome Software update utility. This utility prepares all the updates, and do the update itself right after reboot, where the minimal environment is running. AFAIK at that moment not even X server is running.
There might be even more cases where the 'xset fp rehash' might fail because of $DISPLAY not being set or X server not running.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Install Fedora Server into Virtual Machine, or SSH to some Fedora machine without X server running or without X11 forwarding.
2. Install xorg-x11 server-utils if it is not already installed:
> $ sudo dnf install xorg-x11-server-utils
3. Run the command:
> $ xset fp rehash
[root@qeos-166 ~]# xset fp rehash
xset: unable to open display ""
[root@qeos-166 ~]# xset fp rehash; echo $?
(... Command succeeds.)
... Another possible solution might be if the 'xset fp rehash' would be automatically run after the X server is started. In that way, the 'xset fp rehash' could be removed from fonts package completely. However, I'm not sure how big impact on the startup speed it could have in case user had thousand(s) of fonts installed.
Any update on this, guys?
Checking the source of xset fp rehash, it's three lines of code (ignoring
currentList = XGetFontPath(dpy, (int *) &ncurrent);
XSetFontPath(dpy, currentList, (int) ncurrent);
so this absolutely needs to have the server running because whatever
happens in response to this is handled by the server alone, not by xset or Xlib.
I admit I don't know much about fonts but isn't some combination of mkfontdir/mkfontscale sufficient there?
thank you very much for your response. So, digging into this a little bit more, I have found this in man pages:
$ man mkfontdir
fonts.dir List of fonts in the directory and the files they are
stored in. Created by mkfontdir. Read by the X server
and font server each time the font path is set (see
fonts.scale List of scalable fonts in the directory. Contents are
copied to fonts.dir by mkfontdir. Can be created with
fonts.alias List of font name aliases. Read by the X server and
font server each time the font path is set (see
So I've looked at the xset(1) man page again:
> The fp= sets the font path to the entries given in the path
> argument. The entries are interpreted by the server, not by
> the client. Typically they are directory names or font server
> names, but the interpretation is server-dependent.
The default argument causes the font path to be reset to the
> The rehash argument resets the font path to its current value,
> causing the server to reread the font databases in the current
> font path. This is generally only used when adding new fonts
> to a font directory (after running mkfontdir to recreate the
> font database).
So, the X server has to be running for xset to work, and IMO just using the mkfontdir/mkfontscale doesn't do the complete job, because during the font package installation I am adding the symlink into /etc/X11/fontpath.d/ folder, which points to the newly installed font directory (e.g. /usr/share/fonts/urw-base35/). I don't think that just adding the symlink will do the job. IMO that's why the arch linux wiki is saying to run the "xset fp rehash" command.
I would say that running that command really doesn't matter in case the user is running the Fedora without GUI target enabled.
Therefore, the question now remains - does the X server checks for newly added font paths during its startup?
If it does, then everything is okay and we can close this bug. If it does not, then we have a all fonts-wide problem inside Fedora... :D
Could you please check if X server checks for newly added/removed (updated) fonts paths in /etc/X11/fontpath.d/ when it starts? Thank you very much! :)
I wouldn't know why it would store this across invocations. And iirc the mkfont* are the only things we run after installing the other core fonts and that has been enough.
(In reply to Peter Hutterer from comment #4)
> I wouldn't know why it would store this across invocations.
Are you trying to say that the X server automatically scans for new font paths when it starts?
> And iirc the mkfont* are the only things we run after installing the other
> core fonts and that has been enough.
Yes, we use only mkfont* commands, but generally I get the feeling the fonts are quite a mess in Fedora (the FPG wiki for Fonts is mostly completely out of date), and that by itself does not guarantee we are doing it correctly... :) That's why I created this BZ, to try to sort it out. ;)
(In reply to David Kaspar [Dee'Kej] from comment #5)
> (In reply to Peter Hutterer from comment #4)
> > I wouldn't know why it would store this across invocations.
> Are you trying to say that the X server automatically scans for new font
> paths when it starts?
I honestly don't know, sorry.
(In reply to Peter Hutterer from comment #6)
> (In reply to David Kaspar [Dee'Kej] from comment #5)
> > (In reply to Peter Hutterer from comment #4)
> > > I wouldn't know why it would store this across invocations.
> > Are you trying to say that the X server automatically scans for new font
> > paths when it starts?
> I honestly don't know, sorry.
No problem. :) I will assume that is what is going on by default, because I do not have more time to poke into this. Anyway, thanks for your feedback. ;)