# X.org and Fontpath



## freezr (Dec 3, 2021)

Hi guys,

it is strictly necessary these days adding the "fontpath" to Xorg as the handbook suggests or this is something that can be ignored?

Thanks in advance,

TGL


----------



## Geezer (Dec 4, 2021)

Generally you do not have to touch (or even have) xorg.conf. Fonts work perfectly without doing anything.


----------



## T-Daemon (Dec 4, 2021)

Some fonts font path need to be set explicitely in a xorg configuration file. Without setting it xorg won't detect them. For example:

```
Section "Files"
    FontPath "/usr/local/share/fonts/GentiumBasic/"
    FontPath "/usr/local/share/fonts/GentiumPlus/"
    FontPath "/usr/local/share/fonts/Caladea/"
    FontPath "/usr/local/share/fonts/Carlito/"
    FontPath "/usr/local/share/fonts/dejavu/"
    FontPath "/usr/local/share/fonts/Liberation/"
    FontPath "/usr/local/share/fonts/LinLibertineG/"
    FontPath "/usr/local/share/fonts/powerline-fonts/"
    FontPath "/usr/local/share/fonts/terminus-font/"
    FontPath "/usr/local/share/fonts/webfonts/"
EndSection
```

If a font needs font path set or not can be seen in the post-installation message of the package. If you missed the messages run `pkg info -aD | grep FontPath`.

That output can also redirected into a xorg configuration file instead of writing ever line manually: On all installed font packages `pkg info -aD | grep FontPath >> /usr/local/etc/X11/xorg.conf.d/files.conf`

Or on individual font packages: `pkg info -D <font_package_name> | grep FontPath >> /usr/local/etc/X11/xorg.conf.d/files.conf`

Afterwards edit files.conf accordingly.


----------



## Geezer (Dec 4, 2021)

Running X with xfce4 (which may be pertinent), any fonts that I add to /usr/local/share/fonts and any ~/.fonts are automatically found and appear in X without ceremony.

Reference: 
`13.0-RELEASE-p5
xorg-7.7_3
xfce4-wm-4.16.1`


----------



## Alain De Vos (Dec 4, 2021)

Which raises the following question. How do you and for which fonts you should edit xorg.conf ?


----------



## T-Daemon (Dec 4, 2021)

Those fonts mentioned in post #3 are not automatically detected by xorg without setting a font path, those need a font path set.

Xorg.0.log with `FontPath` set:

```
[    46.267] (**) FontPath set to:
        /usr/local/share/fonts/GentiumBasic/,
        /usr/local/share/fonts/GentiumPlus/,
        /usr/local/share/fonts/Caladea/,
        /usr/local/share/fonts/Carlito/,
        /usr/local/share/fonts/dejavu/,
        /usr/local/share/fonts/Liberation/,
        /usr/local/share/fonts/LinLibertineG/,
        /usr/local/share/fonts/powerline-fonts/,
        /usr/local/share/fonts/terminus-font/,
        /usr/local/share/fonts/urwfonts/,
        /usr/local/share/fonts/urwfonts-ttf/,
        /usr/local/share/fonts/webfonts/,
        /usr/local/share/fonts/TTF/,
        /usr/local/share/fonts/OTF/,
        catalogue:/usr/local/etc/X11/fontpath.d
```

Xorg.0.log without `FontPath` set:

```
[   259.959] (==) FontPath set to:
        /usr/local/share/fonts/TTF/,
        /usr/local/share/fonts/OTF/,
        catalogue:/usr/local/etc/X11/fontpath.d
```



Alain De Vos said:


> How do you and for which fonts you should edit xorg.conf ?





T-Daemon said:


> On all installed font packages `pkg info -aD | grep FontPath >> /usr/local/etc/X11/xorg.conf.d/files.conf`
> 
> Or on individual font packages: `pkg info -D <font_package_name> | grep FontPath >> /usr/local/etc/X11/xorg.conf.d/files.conf`
> 
> Afterwards edit files.conf accordingly.


----------



## Alain De Vos (Dec 4, 2021)

Any idea for sway(wayland) ? If you don't have xorg installed but still want to use Liberation fonts.


----------



## Geezer (Dec 4, 2021)

T-Daemon said:


> Those fonts mentioned in post #3 are not automatically detected by xorg without setting a font path, those need a font path set.



I have got those exact same fonts, and had _not_ set a font path.

With _previous_ versions of X, it seemed necessary.


----------



## Alain De Vos (Dec 4, 2021)

Bye the way, i have an almost emty xorg.conf and using sway(wayland) i can choose Liberation fonts in firefox.
So someway,somehow they are automaticly known.


----------



## freezr (Dec 4, 2021)

Alain De Vos said:


> Which raises the following question. How do you and for which fonts you should edit xorg.conf ?



Sorry I made confusion, I didn't find it in the handbook but in a message after installing some packages as explained here:

https://forums.freebsd.org/threads/x-org-and-fontpath.83202/post-545140
For instance after installing LibreOffice you got the message to add these fonts:


```
FontPath "/usr/local/share/fonts/LinLibertineG/"
FontPath "/usr/local/share/fonts/Liberation/"
FontPath "/usr/local/share/fonts/GentiumBasic/"
FontPath "/usr/local/share/fonts/Carlito/"
FontPath "/usr/local/share/fonts/Caladea/"
```


----------



## Alain De Vos (Dec 4, 2021)

I don't have those lines but i can select font liberation in openoffice under sway window manager.
[Libreoffice has a fontselection problem on my pc]


----------



## T-Daemon (Dec 4, 2021)

Geezer said:


> Generally you do not have to touch (or even have) xorg.conf. Fonts work perfectly without doing anything.


I confirm!

I only checked Xorg.0.log, without looking into the application. Despite the fact Xorg.0.log doesn't show the font path detection, the fonts are detected by the applications itself.

Without this thread I would not have noticed. Bottom line: No FontPath configuration needed.


----------



## T-Daemon (Dec 4, 2021)

Alain De Vos said:


> Any idea for sway(wayland) ? If you don't have xorg installed but still want to use Liberation fonts.


Maybe this page is of some help. See under "Font config":








						GitHub - Madic-/Sway-DE: 🏠 Sway desktop environment dotfile installation for Arch Linux
					

🏠 Sway desktop environment dotfile installation for Arch Linux - GitHub - Madic-/Sway-DE: 🏠 Sway desktop environment dotfile installation for Arch Linux




					github.com


----------



## Geezer (Dec 4, 2021)

Over the last couple of years, X and setting up a desktop in general has become a lot more streamlined.


----------



## grahamperrin@ (Dec 20, 2021)

The phrase _fontpath_ appears in numerous package messages, for example <https://www.freshports.org/search.p...sc&search=Search&format=plaintext&branch=head>.

I don't have a point of reference handy, but I'm reliably informed that many such messages are outdated. I drafted part of what's required for a bug report, but I'm in no rush to make the report; without patch files, it might languish.



Geezer said:


> Generally you do not have to touch (or even have) xorg.conf. Fonts work perfectly without doing anything.



Generally true.

Unfortunately, the port of *Google Fonts* has a package message <https://www.freshports.org/x11-fonts/google-fonts/#message> that: 

advises the user to do something that's (probably) no longer required
omits a requirement that involves ~/.config/fontconfig/fonts.conf


----------



## free-and-bsd (Dec 20, 2021)

T-Daemon said:


> I confirm!
> 
> I only checked Xorg.0.log, without looking into the application. Despite the fact Xorg.0.log doesn't show the font path detection, the fonts are detected by the applications itself.


Always had that problem with terminus fonts. The system did not _always_ detect it smoothly. So, upon the ports update I'd end up with system not being able to use terminus fonts for my urxvt app _every other time_. And this is the worst scenario -- when things don't ALWAYS work the same way. So I ended up adding font path config file to xorg.conf.d directory.


----------



## kpedersen (Dec 20, 2021)

For fonts I really want to exist on the machine, I put in my $HOME/.fonts directory and run

`fc-cache -rv`

I believe the freedesktop have new ideas on where the .fonts folder should be but it still works. Also, the command also seems to scan system fonts too so it might be enough just to run and get your terminus font discovered.


----------



## free-and-bsd (Dec 23, 2021)

Well, that's the problem of it. There is ~/.fonts folder. Then there is the fc-cache command. Which, BTW, is supposed to run automatically whenever X server starts or smth to that effect... isn't it? I mean, ALL these things are actually supposed to silently _just_ work...

Only, every time I rebuild ports and freetype2 gets rebuilt (it's Synth), terminus-fonts can't be found by system and my urxvt pops up with some ugly big font instead. The only remedy is putting that fonts.conf file with FontPath into /usr/local/etc/X11/xorg.conf.d.

MAYBE the "problem" is in my using simple FVWM3 + startx to start X? Maybe. But I don't see why startx should fail to trigger ALL the processes and subprograms needed for running X smoothly. And with these multiple ways to make sure fonts are found & loaded, I'm still not sure which of them is THE one and only _absolutely _necessary.

...And yes, probably, now that I'm all set up, if I remove this FontPath config file, terminus font will still be found by the system. Until the next time freetype2 or terminus-fonts get rebuilt. 
This is all rather confusing.


----------



## grahamperrin@ (Dec 23, 2021)

free-and-bsd said:


> terminus fonts



x11-fonts/terminus-font | x11-fonts/terminus-ttf

For me, both fonts became available after installation. *Ignoring* the `FontPath` advice in their package messages. 

`terminus-font` results in `xos4 Terminus`:


----------



## free-and-bsd (Dec 23, 2021)

grahamperrin said:


> x11-fonts/terminus-font | x11-fonts/terminus-ttf
> 
> For me, both fonts became available after installation. *Ignoring* the `FontPath` advice in their package messages.
> 
> ...


You seem to be using some DE. That must be all the difference that counts.


----------



## kpedersen (Dec 23, 2021)

free-and-bsd said:


> This is all rather confusing.



Compared to macOS or Windows (where I have no idea of what is happening behind the scenes when I drag fonts around), I find it fairly straight forward.


```
mkdir ~/.fonts
cp gallant-demi-19.bdf ~/.fonts
fc-cache -rv
```

It should then show in fc-list (`fc-list | grep Gallant`)

And finally, you can use it with, i.e `xterm -fa Gallant`

Admittedly the documentation can be hard to find because every desktop environment does it in a different, non-standard way. The above is the way standard Xorg/fontconfig does it *underneath* the clutter.

(works with bdf and ttf fonts as far as I have tested)


----------



## grahamperrin@ (Dec 23, 2021)

free-and-bsd said:


> … some DE …



KDE Plasma on slightly outdated FreeBSD 14.0-CURRENT (1400043, should be 1400045); no problem. <https://bsd-hardware.info/?computer=6fbb1f806232>

No problem with a minimal set of packages on 12.3-RELEASE:



I switched to ttyv3, logged in as root, installed terminus-ttf, switched immediately back to ttyv9, quit then restarted QTerminal, found the font available:


----------



## free-and-bsd (Dec 25, 2021)

grahamperrin said:


> KDE Plasma on slightly outdated FreeBSD 14.0-CURRENT (1400043, should be 1400045); no problem. <https://bsd-hardware.info/?computer=6fbb1f806232>
> 
> No problem with a minimal set of packages on 12.3-RELEASE:
> View attachment 12358
> ...


Yes. That "Terminal settings" application of yours seems to offer a choice of fonts. Meaning it pulls in with it some minimal DE  utilities & scripts. So, fonts recognition WILL work all right. 
My problem, however, is with urxvt relying solely on ~/.Xresources for fonts. And the problem with that is, for one thing, that X notation for terminus fonts (non-TTF) sometimes changes with every other pkg rebuild like this:


> !URxvt*font: xft:xos4 Terminus:size=12:style=regular





> !URxvt*font: -xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1


Sometimes the one is recognized, sometimes the other one.


----------



## grahamperrin@ (Dec 26, 2021)

free-and-bsd thanks for clarifying your use case. 



free-and-bsd said:


> … That "Terminal settings" application …



I should have made clearer what I used for the comparison. From the (screenshotted) result of `pkg prime-origins | sort`:

x11/qterminal


----------

