# Mysteries of X font path and fontconfig



## grahamperrin@ (Jul 12, 2021)

Amongst the mysteries, this message from urwfonts-1.0_8:



> You'll have to add /usr/local/share/fonts/urwfonts to your X font path by either:
> 
> `$ xset fp+ /usr/local/share/fonts/urwfonts
> $ xset fp rehash`
> ...



With *neither* of the required actions taken, /usr/local/share/fonts/urwfonts *is* recognised by `fc-cache --verbose` (with /usr/local/bin/fc-cache provided by x11-fonts/fontconfig and x11-fonts/linux-c7-fontconfig).

If it's true that I'll _have_ to manually add the path to something: _why_ is it true? 

I can not find an answer under <https://docs.freebsd.org/en/books/handbook/x11/#x-fonts>.


```
% man fc-cache
No manual entry for fc-cache
% fc-cache --help
usage: fc-cache [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]
Build font information caches in [dirs]
(all directories in font configuration by default).

  -E, --error-on-no-fonts  raise an error if no fonts in a directory
  -f, --force              scan directories with apparently valid caches
  -r, --really-force       erase all existing caches, then rescan
  -s, --system-only        scan system-wide directories only
  -y, --sysroot=SYSROOT    prepend SYSROOT to all paths for scanning
  -v, --verbose            display status information while busy
  -V, --version            display font config version and exit
  -h, --help               display this help and exit
%
```


----------



## jmos (Jul 12, 2021)

Afaik that's historic; Since many years the default font paths are searched recursively, and /usr/local/share/fonts is a default font path.

The message is not a message defined in the port itself - without testing I assume that just telling that it is a font inside the Makefile rises that message. And that's not a complete bad idea, as a path shouldn't, but might be out of the automatic scanned directories. But the wording could be improved…


----------



## grahamperrin@ (Jul 12, 2021)

Thanks,



jmos said:


> Afaik that's historic; …



I did wonder.



jmos said:


> … wording could be improved…



A few weeks ago I compiled a list of ports of fonts where package messages were questionable or (at a glance) almost certainly wrong. I don't have it handy, I might revisit the list in a few weeks.

<https://www.freshports.org/x11-fonts/google-fonts/#message> google-fonts is amongst the packages that present a message.

fontconfig

I see google-fonts-related <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252360#c8> "… provide a little help to fontconfig, e.g.: …" but I don't get the big picture:


```
% man fontconfig | more
No manual entry for fontconfig
% apropos fontconfig
apropos: nothing appropriate
% fontconfig --help
fontconfig: Command not found.
% pkg provides fontconfig | grep bin
Desc    : GD bindings for the Lua programming language
%
```

Honestly, I'm in no rush to get it.

(Off-topic: I refrain from installing google-fonts because it can trigger a freaky bug in Firefox. The type of bug that might become easier to troubleshoot without umpteen misleading messages from fonts.)


----------



## Deleted member 30996 (Jul 12, 2021)

I install fonts for use with graphics/gimp by summoning x11-fm/xfe as root, move them directly into the /usr/local/share/gimp/fonts directory, run `rehash` and they are immediately available for use with Gimp.

I also used a couple downloaded from fonts.google.com and used them with Gimp without any problems.

None of them show up when I run `fc-cache --verbose`.


----------



## grahamperrin@ (Jul 12, 2021)

Trihexagonal said:


> … None of them show up when I run `fc-cache --verbose`.



So, that's as expected. True?


----------



## kpedersen (Jul 12, 2021)

Setting the fontpath like that is generally only for bitmap fonts. Most UI toolkits use FreeType now which is a little more dynamic (we also don't need font servers anymore when X11 forwarding!). The main ones that don't are Motif and Xaw.

Do you have `xfontsel` installed? If you run that you can see the (fairly bizarre) way that X11 fonts work.

Some random knowledge you might already know:

FreeType fonts are also sourced from your $HOME/.fonts firectory. So you can just add some .ttf fonts in there and run:


```
$ fc-cache -rv
```

It will then show up in LibreOffice, Gimp, etc.


----------



## grahamperrin@ (Jul 12, 2021)

kpedersen said:


> Do you have `xfontsel` installed?



I didn't, after installing I recognise the application from long ago. Bizarre. 








grahamperrin said:


> ```
> % man fontconfig | more
> No manual entry for fontconfig
> % apropos fontconfig
> ...



I forgot, the binaries for fontconfig don't use the word fontconfig:


```
% pkg info --list fontconfig | grep bin
        /usr/local/bin/fc-cache
        /usr/local/bin/fc-cat
        /usr/local/bin/fc-conflist
        /usr/local/bin/fc-list
        /usr/local/bin/fc-match
        /usr/local/bin/fc-pattern
        /usr/local/bin/fc-query
        /usr/local/bin/fc-scan
        /usr/local/bin/fc-validate
%
```

Also, today I discovered the upstream: <https://gitlab.freedesktop.org/fontconfig>


----------



## jmos (Jul 13, 2021)

kpedersen said:


> FreeType fonts are also sourced from your $HOME/.fonts firectory


I cannot find my source again, but: That's deprecated, the users directory for own fonts now is $HOME/.local/share/fonts/. Both work, but it makes sense to move it to the new place.


----------



## Deleted member 30996 (Jul 13, 2021)

grahamperrin said:


> So, that's as expected. True?


It only parses these directories which is an accurate account of the fonts contained therein.


```
root@bakemono:/ # fc-cache -f
root@bakemono:/ # fc-cache --verbose
Font directories:
    /usr/local/share/fonts
    /usr/local/lib/X11/fonts
    /root/.local/share/fonts
    /root/.fonts
    /usr/local/share/fonts/100dpi
    /usr/local/share/fonts/75dpi
    /usr/local/share/fonts/OTF
    /usr/local/share/fonts/TTF
    /usr/local/share/fonts/Type1
    /usr/local/share/fonts/cyrillic
    /usr/local/share/fonts/dejavu
    /usr/local/share/fonts/encodings
    /usr/local/share/fonts/misc
    /usr/local/share/fonts/util
    /usr/local/share/fonts/encodings/large
```

There is no /root/.fonts in my root directory. There are the fonts Gimp uses:


----------



## Vull (Jul 13, 2021)

I don't know where it puts them, but installing Libreoffice seems to provide most of the fonts I need. I'm lazy like that.


----------



## kpedersen (Jul 13, 2021)

jmos said:


> I cannot find my source again, but: That's deprecated, the users directory for own fonts now is $HOME/.local/share/fonts/. Both work, but it makes sense to move it to the new place.


You are correct. I didn't realise and I had been using this for years 

https://github.com/13rac1/emojione-color-font/issues/14
(The issue also links to the spec).

*Edit:*
However upon further thought, it is a worthless XDG freedesktop "spec" and has Poettering's name on it. I am happy to disregard it completely. The ~/.fonts folder will almost certainly have a longer lifespan.

Also, the ~/.local folder becomes a cluttered mess. I suppose I actually prefer to keep defined configs and files separate from this chaos and keep things a cleaner. I could set up a symlink but then it will source the directory twice


----------

