Bug 1466254 - 'xset fp rehash' does not work without X server running
'xset fp rehash' does not work without X server running
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: xorg-x11-server-utils (Show other bugs)
25
All Linux
unspecified Severity medium
: ---
: ---
Assigned To: X/OpenGL Maintenance List
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 1458840
  Show dependency treegraph
 
Reported: 2017-06-29 07:06 EDT by David Kaspar [Dee'Kej]
Modified: 2017-09-01 06:04 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-09-01 06:04:19 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
dkaspar: fedora_requires_release_note-


Attachments (Terms of Use)

  None (edit)
Description David Kaspar [Dee'Kej] 2017-06-29 07:06:15 EDT
Hello folks!

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:
https://wiki.archlinux.org/index.php/X_Logical_Font_Description#Font_search_path

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):
xorg-x11-server-utils-7.7-20.fc25.x86_64

How reproducible:
Always

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

Actual results:
---------------
[root@qeos-166 ~]# xset fp rehash
xset:  unable to open display ""

Expected results:
-----------------
[root@qeos-166 ~]# xset fp rehash; echo $?
0
(... Command succeeds.)

Additional info:
... 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.
Comment 1 David Kaspar [Dee'Kej] 2017-08-18 08:38:34 EDT
Any update on this, guys?
Comment 2 Peter Hutterer 2017-08-23 01:16:09 EDT
Checking the source of xset fp rehash, it's three lines of code (ignoring
error handling):

              currentList = XGetFontPath(dpy, (int *) &ncurrent);
              XSetFontPath(dpy, currentList, (int) ncurrent);
              XFreeFontPath(currentList);

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?
Comment 3 David Kaspar [Dee'Kej] 2017-08-23 05:57:33 EDT
Hello Peter,

thank you very much for your response. So, digging into this a little bit more, I have found this in man pages:

$ man mkfontdir
...
FILES
       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
                      xset(1)).

       fonts.scale    List  of  scalable fonts in the directory.  Contents are
                      copied to fonts.dir by mkfontdir.   Can be created  with
                      mkfontscale(1).

       fonts.alias    List  of  font  name  aliases.  Read by the X server and
                      font  server  each  time  the  font  path  is  set  (see
                      xset(1)).

So I've looked at the xset(1) man page again:

OPTIONS

       fp= path,...
>              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.

       fp default
               The default argument causes the font path to be  reset  to  the
               server's default.

       fp rehash
>              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! :)

Dee'Kej
Comment 4 Peter Hutterer 2017-08-25 01:53:46 EDT
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.
Comment 5 David Kaspar [Dee'Kej] 2017-08-29 07:10:01 EDT
(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. ;)
Comment 6 Peter Hutterer 2017-08-31 19:47:45 EDT
(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.
Comment 7 David Kaspar [Dee'Kej] 2017-09-01 06:04:19 EDT
(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. ;)

Note You need to log in before you can comment on or make changes to this bug.