How do I install a font in Linux so that it's usable by xterm?
Solution 1
Ubuntu has a package:
apt-get install xfonts-terminus xfonts-terminus-oblique
Note that this is in the universe
repository, so you may have to add that to /etc/apt/sources.list
.
Solution 2
After installing xfonts-terminus in Debian Wheezy I needed to do:
$ xset fp rehash
also, my ~/.Xresources
says:
xterm*utf8: 1
xterm*font: -xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1
, where -xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1
is taken from the fonts.dir
file where the font is installed. In my case it's /usr/share/fonts/X11/misc/fonts.dir
.
You use xterm*utf8: 1
and choose iso10646-1
if you want utf-8. You might also need to call the wrapper script uxterm
instead of xterm
for utf-8 to work properly in your terminal.
All changes in ~/.Xresources
require you to do:
$ xrdb ~/.Xresources
to make them register in the current X session.
The xterm*font
rule may be also written with wildcard asterisks like that:
xterm*font: -xos4-terminus-medium-r-*--20-*-*-*-*-*-iso10646-*
I hope this will be helpful to anybody who stumbles upon a similar problem.
Solution 3
Are the fonts listed in the encodings.dir, fonts.alias, and fonts.dir files under /usr/share/fonts/X11/misc?
Its been quite a while since I needed to add fonts on a linux host but there are helper utils, named mkfontdir, update-fonts-alias, update-fonts-dir, and update-fonts-scale, that should be installed by default. They handle updating the metainfo that tells the X server about fonts installed on the system. See the man pages for them.
On Debian based systems (Ubuntu has a Debian heritage), when a font .deb package is added a helper normally calls mkfontdirs automatically. Installing the font using make may not have set things up the way your system expects.
Related videos on Youtube
raldi
Updated on September 17, 2022Comments
-
raldi almost 2 years
I came across a question today asking for good Linux xterm fonts, and an answer suggests one called Terminus. I've been looking for a new terminal font for a while now, so I downloaded it (BTW, I'm running Ubuntu Intrepid) and read the README:
1.1. Quick installation. The commands: $ ./configure [--prefix=PREFIX] $ make # make install compile and install the Linux console and X11 Window System fonts, and # make fontdir updates fonts.dir for X11 (if you don't know what fonts.dir is, execute the command). 1.2. Legend. The file names are structured as follows: ter-u<SIZE><STYLE>.bdf where <SIZE> is 12, 14, 16, 20, 24, 28 or 32, and <STYLE> is n for normal (all sizes), b for bold (all sizes except 6x12) and v for EGA/VGA bold (8x14 and 8x16 only, makes use of the eight character matrix column).
So I ran:
$ ./configure $ make $ sudo make install $ sudo make fontdir
...and I restarted X11 just to be sure, and the new font was nowhere to be found:
$ xterm -font ter-u14n xterm: unable to open font "ter-u14n", trying "fixed"....
Sigh. Back to the README. Later in this file, I saw:
4. X11 Window System. 4.1. Installation. $ ./configure [--prefix=PREFIX | --x11dir=DIRECTORY] $ make pcf # make install-pcf
Well, I know that "xterm -font 8x16" works, so I ran "locate 8x16" and saw that this font seemed to live in /usr/share/fonts/X11/misc, so that seemed like a good --x11dir to use. So I ran:
$ ./configure --x11dir=/usr/share/fonts/X11/misc $ make pcf $ make install-pcf $ sudo make fontdir
...and I restarted X11 again, and even my whole computer just for good measure, and I even verified that there were now a bunch of files like /usr/share/fonts/X11/misc/ter-u14n.pcf.gz on my system, but still:
$ xterm -font ter-u14n xterm: unable to open font "ter-u14n", trying "fixed"....
What is the magical incantation I have to perform in order to get this font working with xterm?