Page 1 of 1

How To: Quick New Font Guide

Posted: Mon May 04, 2015 11:40 am
by dkeg
Fonts can be unnecessarily difficult. We all know this to be true. The following are the steps I take when I grab a new font.

Please note this is what I do. This is what works for me. If you have something to add that will add value, please do.


Step 1:
Download the font and extract if necessary.

Step 2:
cp the appropriate .pcf (preferrably) or .bdf file to

Code: Select all

/usr/share/fonts/local
Note that you may need to create that directory first. Also note that we are not using ~/.font. That does not seem to consistently work and apparently is now deprecated.

Step 3:

Run the following commands as root (thanks to GekkoP)

Code: Select all

sudo fc-cache -fs
sudo mkfontscale /usr/share/fonts/local
sudo mkfontdir /usr/share/fonts/local
Step 4:
Log out and back in

Step 5:
In your terminal run

Code: Select all

xlsfonts | grep [your new font]
Step 6:
Paste in your .Xresources (or where applicable)

Step 7:
Now, to trick your system and like your font directory, place the following in your .xinitrc

Code: Select all

# font bullshit
xset +fp /usr/share/fonts/local
xset fp rehash 
Bonus:
Of course it is hard to remember the commands. Please do the following
  • Subscribe to this thread
    Make a quick script and place in your $PATH. I named mine newFont

    Code: Select all

    #! /bin/bash
    ## Run this script for new fonts
    sudo fc-cache -fs
    sudo mkfontscale /usr/share/fonts/local
    sudo mkfontdir /usr/share/fonts/local
    
Now, when you add your new fonts to the proper directory (above), simply run newFont. And b/c its in your $PATH, you can run from anywhere.

Now adding fonts is not a headache. Enjoy!

Reference: http://linuxbbq.org/bbs/viewtopic.php?f ... &hilit=pcf

Re: How To: Quick New Font Guide

Posted: Mon May 04, 2015 11:52 am
by machinebacon
important and helpful post, thanks a lot drew!

Re: How To: Quick New Font Guide

Posted: Mon May 04, 2015 1:02 pm
by GekkoP
Very useful, especially for fonts addicts such as many honest men and women here. Thanks a lot.

Re: How To: Quick New Font Guide

Posted: Mon May 04, 2015 1:07 pm
by rhowaldt
thanks drew!

Re: How To: Quick New Font Guide

Posted: Mon May 04, 2015 1:09 pm
by ChefIronBelly
Very nice Thank You - bookmarked

Re: How To: Quick New Font Guide

Posted: Mon May 04, 2015 5:41 pm
by wuxmedia
good stuff, better than install it all and hope ;)

Re: How To: Quick New Font Guide

Posted: Tue May 05, 2015 3:35 am
by dkeg
I experimented and it is indeed necessary to add the snippets I had in the 'troubleshooting' section in your .xinitrc. I have edited the OP and changed the troubleshooting to a step 6 as it appears to be required. When I commented out, my beautiful fonts were gone.

Re: How To: Quick New Font Guide

Posted: Tue May 05, 2015 4:10 am
by Dr_Chroot
Wonderfully helpful post; something I really needed help with when I started playing with wm's. Thanks, dkeg!

Re: How To: Quick New Font Guide

Posted: Tue May 05, 2015 4:36 am
by pidsley
Thank you for the how-to dkeg.

Deprecated or not, I always put my user fonts in ~/.fonts/<font-name>, then run mkfontscale and mkfontdir on the individual directory. Keeping them in separate directories lets me add and remove fonts more easily, and only load the font I want to use.

Then as in your example, I add code to .xinitrc:

Code: Select all

xset +fp ~/.fonts/tamsyn-font-1.10
xset fp rehash
And the font becomes available at the next X start. The xset code can also be run with X already running (to load a new font) and then a modified Xresources can be reloaded with "xrdb ~/.Xresources" to change the terminal font. This seems to always work for me without problem.

As you say "Please note this is what I do. This is what works for me."

Of course these fonts are only available to my user; putting fonts in /usr/share/fonts/local (as in your example) makes them available to all users, and putting them all in one directory means you can load them all at once and not worry about reloading if you decide to change. Different paths to the same end.

Wherever you put the fonts, The important steps are as you showed -- running mkfontscale and mkfontdir, then "xset +fp <dir>" and "xset fp rehash".

The Arch wiki has some useful font information. It appears to be possible to use xorg.conf to tell X where fonts are located, but I have not tried this (as xset works well for me).

https://wiki.archlinux.org/index.php/Fonts

Re: How To: Quick New Font Guide

Posted: Tue May 05, 2015 9:44 am
by GekkoP
@dkeg: yes, as Pidsley said, I too put those lines in my .xinitrc. Always works for me. :)

(two steps 6?)

Re: How To: Quick New Font Guide

Posted: Tue May 05, 2015 11:09 am
by dkeg
Thanks GP fixed.

Pidsley, thanks for the tip to pick up new fonts while in X. Funny how you don't see what's right in front of you. And yes, ~/.fonts does work for me *sometimes*, well mostly, but I wrote the tut this way b/c this particular method been my no fail route. Maybe its something I'm doing wrong (probably), but finally fonts are not an issue for me. And I hope others too now.