You are not logged in.

#1 2020-03-14 18:37:12

miomio
Member
Registered: 2016-01-17
Posts: 167

[SOLVED] Xorg or fontconfig for new font dir?

My root partition is too small to have installed the 2GB of data for nerd fonts under /usr so I modified the AUR PKGBUILD to install to a dir on /opt (which I am mounting as a separate partition on the disk). This solved the installation but now I'm trying to figure out how to have the /opt/nerd-fonts-complete dir recognised as an extra system-wide font directory and the fonts known to applications.

After installing to /opt I executed:

  fc-cache -s
  mkfontscale /opt/nerd-fonts/otf
  mkfontdir /opt/nerd-fonts/otf
  mkfontscale /opt/nerd-fonts/ttf
  mkfontdir /opt/nerd-fonts/ttf

I followed the docs to have an extra config file under /etc/X11/xorg.conf.d/ with the nerd-font OTF and TTF dirs configured. This is successful and being picked up by X:

$ xset -q | grep -i opt
  /opt/nerd-fonts/ttf,/opt/nerd-fonts/otf,/usr/share/fonts/TTF,/usr/share/fonts/OTF,/usr/share/fonts/100dpi,/usr/share/fonts/75dpi,built-ins

I do not however see the nerd fonts in xfontsel. There's also a disparity between the following numbers:

xfontsel says 10092 (presumably) fonts detected
fc-list | wc -l gives 1839
xlsfonts | wc -l gives 7016

Questions:

Do I use fontconfig, or xorg to configure the new /opt/nerd-fonts dir?
If xfontsel is detecting >10000 fonts, why doesn't fc-list or xlsfonts? Will this cause an issue?

What I'm trying to achieve is to have xfontsel give me the correct string to configure nerd fonts for DWM via dwm's config.h file.

EDIT:

Created symlinks from the otf and ttf /opt/nerd-fonts dirs to /usr/share/fonts/{OTF,TTF} and now fontconfig recognises the nerd fonts, however, this isn't really the solution I was after. Also, xfontsel still does not recognise nerd fonts.

Last edited by miomio (2020-03-28 14:00:52)

Offline

#2 2020-03-23 09:31:21

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

Anyone?

Offline

#3 2020-03-23 14:04:50

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

Do I use fontconfig, or xorg to configure the new /opt/nerd-fonts dir?

"s/or/and/" - fontconfig isn't universally used, some processes might still rely on the fonts known by the X11 server.

why doesn't fc-list or xlsfonts?

Because you didn't suggest to have added the font path to fontconfig, https://wiki.archlinux.org/index.php/Fo … Font_paths

Will this cause an issue?

Fonts not being available through config…

xfontsel still does not recognise nerd fonts.

Did you rehas the database? (See the bottom of https://wiki.archlinux.org/index.php/X_ … escription )

Online

#4 2020-03-23 21:49:46

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

why doesn't fc-list or xlsfonts?

Because you didn't suggest to have added the font path to fontconfig, https://wiki.archlinux.org/index.php/Fo … Font_paths

xfontsel still does not recognise nerd fonts.

Did you rehas the database? (See the bottom of https://wiki.archlinux.org/index.php/X_ … escription )

As the first wiki link says: "The font paths initially known to Fontconfig are: /usr/share/fonts/ ..."

I sym linked to the /usr/share/fonts/{OTF,TTF} dirs the files in otf and ttf dirs of /opt/nerd-fonts. Hence `fc-list : file` is picking up the nerd fonts, e.g.:

$ fc-list : file | grep -i nerd | wc -l
1162

Yes, I've rehashed the X font database and the nerd-font dir on /opt is being picked up in Xorg.0.log.

Last edited by miomio (2020-03-23 21:51:42)

Offline

#5 2020-03-23 22:44:01

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

Yes, but you said

however, this isn't really the solution I was after

about the symlink approach.

About xfontsel: what's the ouput of

xlsfonts | grep -i nerd

?

Online

#6 2020-03-24 00:04:14

YCH
Member
Registered: 2014-01-28
Posts: 53

Re: [SOLVED] Xorg or fontconfig for new font dir?

you can make `/etc/fonts/conf.d/00-my-font-dir.conf` include this,

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <dir>/opt/your/font/dir</dir>
</fontconfig>

don't know about xfontsel. do you use old X apps that does not support fontconfig?


YCH

Offline

#7 2020-03-24 12:59:22

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

Yes, but you said

however, this isn't really the solution I was after

about the symlink approach.

About xfontsel: what's the ouput of

xlsfonts | grep -i nerd

?

It's been a while since I wrote that, and haven't updated my preference there, now I'm not too fussed - whatever works at this point!...

`xlsfonts | grep -i nerd` outputs nothing.

YCH wrote:

you can make `/etc/fonts/conf.d/00-my-font-dir.conf` include this,

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <dir>/opt/your/font/dir</dir>
</fontconfig>

don't know about xfontsel. do you use old X apps that does not support fontconfig?

The configuration of dwm in config.h has two lines at 8 and 9 whereby you specify the font, see: https://dwm.suckless.org/customisation/font/

To get that same string but for a nerd-font I need to use xfontsel to generate it (right?).

Offline

#8 2020-03-24 13:21:42

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

YCH is equivalent to the fontconfig wiki link I posted.

If xlsfont doesn't list the fonts, they're not known to the server.
Post your xorg log, the xorg.conf.d snippet you created and the output of "ls -lR /opt/nerd-fonts" (this is probably going to be A LOT OF TEXT, use the tip from https://wiki.archlinux.org/index.php/Pastebin )

Edit: xlsfont is what's going to matter for dwm.

Last edited by seth (2020-03-24 13:22:18)

Online

#9 2020-03-25 10:15:55

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

YCH is equivalent to the fontconfig wiki link I posted.

If xlsfont doesn't list the fonts, they're not known to the server.
Post your xorg log, the xorg.conf.d snippet you created and the output of "ls -lR /opt/nerd-fonts" (this is probably going to be A LOT OF TEXT, use the tip from https://wiki.archlinux.org/index.php/Pastebin )

Edit: xlsfont is what's going to matter for dwm.


Xorg.0.log: https://pastebin.com/8XChzKcv
xorg.conf.d/30-fonts.conf:

Section "Files"
    FontPath "/opt/nerd-fonts/ttf"
    FontPath "/opt/nerd-fonts/otf"
    FontPath "/usr/share/fonts/liberation"
EndSection

`ls -LR /opt/nerd-fonts`: https://pastebin.com/1rS4rBQT

Offline

#10 2020-03-25 15:05:03

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

That's basically fine - since the otf/ttf fonts seem copies, what if you remove "/opt/nerd-fonts/otf" from the path?

Online

#11 2020-03-25 15:19:56

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Xorg or fontconfig for new font dir?

Are you sure the font names should contain "nerd"? Look in /opt/nerd-fonts/ttf/*/fonts.dir what names xorg detected for the fonts.
Edit: Sorry, disregard that. Somehow I totally missed that word in my sample mkfontdir output.

Last edited by progandy (2020-03-25 15:32:37)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#12 2020-03-25 15:43:58

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

That's basically fine - since the otf/ttf fonts seem copies, what if you remove "/opt/nerd-fonts/otf" from the path?

In the FontPath ?

Offline

#13 2020-03-25 16:12:15

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Xorg or fontconfig for new font dir?

I got around to testing different combinations. Xorg does not like spaces in file names, so you'd have to remove or replace them with slashes or underscores.

Last edited by progandy (2020-03-25 16:13:37)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#14 2020-03-25 17:17:05

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

progandy wrote:

I got around to testing different combinations. Xorg does not like spaces in file names, so you'd have to remove or replace them with slashes or underscores.

Thanks. In which files have I added spaces in file names? Or, in which files did you find the issue for you?

Offline

#15 2020-03-25 17:39:58

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Xorg or fontconfig for new font dir?

All font files in the nerd-fonts package have spaces in the filenames. You'll have to fix that in the PKGBUILD, either with a find/rename command or "detox -s safe".


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#16 2020-03-25 20:30:50

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

progandy wrote:

All font files in the nerd-fonts package have spaces in the filenames. You'll have to fix that in the PKGBUILD, either with a find/rename command or "detox -s safe".

Thanks for the tip... Although xfontsel still not detecting the nerd fonts.

Offline

#17 2020-03-25 20:50:09

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Xorg or fontconfig for new font dir?

This is my sucessful test procedure:

... download terminess nerd fonts
$ mkcd /tmp/foo
$ cp "/tmp/terminess/Terminess (TTF) Bold Italic Nerd Font Complete.ttf" terminess.ttf
$ mkfontscale
$ mkfontdir
$ xset +fp /tmp/foo
$ xset fp rehash
$ xlsfonts|grep --max-count 1 nerd
-misc-terminessttf nerd font-bold-i-normal--0-0-0-0-m-0-ascii-0

Last edited by progandy (2020-03-25 20:54:16)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#18 2020-03-25 21:12:04

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

I give up.

Offline

#19 2020-03-26 07:28:07

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

Why?

I can actually confirm progandy's findings. None of my (suspiciously few) fonts w/ a whitespace in their name shows up in X11, but in fontconfig.
All you have to do is to rename the font files, like

for name in *\ *; do echo ${name// /_}; done

and rebuild the font database as in comment #17

Online

#20 2020-03-26 13:09:34

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

Why?

I can actually confirm progandy's findings. None of my (suspiciously few) fonts w/ a whitespace in their name shows up in X11, but in fontconfig.
All you have to do is to rename the font files, like

for name in *\ *; do echo ${name// /_}; done

and rebuild the font database as in comment #17

Sorry I wasn't clear: I have followed the suggestion by removing the sym links in /usr/share/fonts/{OTF,TTF}, then renamed the nerd-font files in /opt/nerd-fonts/{ttf,otf} by replacing all spaces with underscores, then recreated the sym links in /usr/share/fonts/{OTF,TTF} and re-running mkfontdir and mkfontscale, then xset fp rehash. Since I already have the xorg.conf.d FontPath's for /usr/share/fonts{OTF,TTF} I didn't do xset +fp ... because X already knows about the dirs, but xlsfonts doesn't give any results to `xlsfonts | grep -i nerd`.

What if you use sym links from a different dir in your test case? How do your results differ, if at all? E.g.

... download terminess nerd fonts
$ mkcd /tmp/foo
$ cp "/tmp/terminess/Terminess (TTF) Bold Italic Nerd Font Complete.ttf" /tmp/terminess/terminess.ttf
$ ln -s /tmp/terminess/terminess.ttf ./
$ mkfontscale
$ mkfontdir
$ xset +fp /tmp/foo
$ xset fp rehash
$ xlsfonts|grep -i nerd

?

Last edited by miomio (2020-03-26 13:27:20)

Offline

#21 2020-03-26 15:17:03

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] Xorg or fontconfig for new font dir?

Symlinks aren't picked up, a copy of the font is.
=> Add the path instead of symlinking stuff.

Online

#22 2020-03-26 20:45:20

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

seth wrote:

Symlinks aren't picked up, a copy of the font is.
=> Add the path instead of symlinking stuff.

Which is exactly what I've done.

miomio wrote:

xorg.conf.d/30-fonts.conf:

Section "Files"
    FontPath "/opt/nerd-fonts/ttf"
    FontPath "/opt/nerd-fonts/otf"
    FontPath "/usr/share/fonts/liberation"
EndSection

The fact that I symlink stuff to /usr/share/fonts/{OTF,TTF} is a backup of the above since X should already be looking in /usr/share/fonts{OTF,TTF}, but good to know symlinks aren't picked up finally, but before you tell me to copy everything to /usr/share/fonts/{OTF,TTF} please see my inital post that brought me here (disk space).

Still, `xlsfonts | grep -i nerd | wc -l` = 0

Last edited by miomio (2020-03-26 20:47:10)

Offline

#23 2020-03-26 20:55:54

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Xorg or fontconfig for new font dir?

Did you check if your fonts.dir file contains the correct filenames? If you ran the commands in the order from post #20, then it was wrong.

and re-running mkfontdir and mkfontscale, then xset fp rehash

mkfontscale has to be run before mkfontdir.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#24 2020-03-26 21:14:53

miomio
Member
Registered: 2016-01-17
Posts: 167

Re: [SOLVED] Xorg or fontconfig for new font dir?

progandy wrote:

Did you check if your fonts.dir file contains the correct filenames? If you ran the commands in the order from post #20, then it was wrong.

and re-running mkfontdir and mkfontscale, then xset fp rehash

mkfontscale has to be run before mkfontdir.

That was it.

Offline

Board footer

Powered by FluxBB