Adding Fonts

The default fonts that come with Xorg leave a lot to be desired. Needless to say, you will likely want to add your own fonts in one way or another. The means through which you do so will necessarily depend on your needs. For the core Microsoft truetype fonts we can install webfonts. This is the simplest and quickest route. I recommend it unless you have any special needs for your fonts. For instance, if you need to view characters in a foreign language you may wish to download the proper fonts from the internet, and add them to your system (in my case I wanted to display Devanagari). On the other hand, you may wish to use your fonts from a Mac OSX or Windows installation you have on another partition or computer. This could be particularly useful because both of these systems have attractive Japanese fonts (like in Kevin's case). If you install your fonts from any source other than the webfonts port, it will be necessary to run some commands such that Xorg can see your new fonts. That is the final section of this page.

Webfonts
Devanagari
Mac OS X Fonts
Windows Fonts
Adding Fonts to Xorg

Webfonts

This is the quickest route to getting a decent set of truetype fonts on your computer.

cd /usr/ports/x11-fonts/webfonts
make install clean

Now that we have the fonts, we need to use them. For that we need to add a line to our xorg.conf

vi /etc/X11/xorg.conf

Scroll down to the "Files" section and add this line:

FontPath "/usr/local/lib/X11/fonts/webfonts/"

That was relatively painless, now when we start X we will have some good fonts at our disposal.

Devanagari

These directions are for displaying Devanagari, but could be easily enough substituted with another character set of choice. We only need one font for a relatively attractive set of characters. here is a nice compilation of indic fonts. My font of choice is Raghu. Download this font and unzip it. Now we need to create a directory to house this font (or any others you decide to add).

mkdir /usr/local/lib/X11/fonts/user

Put all of your user added fonts to this directory, and they will be in one convenient place. Now move raghu to the proper directory:

mv raghu.ttf /usr/local/lib/X11/fonts/user/

Now that the font is in place, all we need to do is add it to Xorg.

Mac OS X

First things first. Copy the Fonts directory in Mac OS X to your FreeBSD system. (On Mac OS X 10.3.x "Panther", the Fonts directory you probably want is found in "/Users/reinholz/Library/Fonts", where "reinholz" is your username in OS X). Put the Fonts directory in /usr/local/lib/X11/fonts/ on FreeBSD. Now we'll want to properly rename the directory:

cd /usr/local/lib/X11/fonts
mv reinholz user

Replace reinholz with the name of the directory you copied from Mac OS X. We renamed the directory user, to show that it is for our user added fonts.

Xorg can understand .bdf, .otf and .ttf fonts by default. (You'll probably have some of these in the Fonts directory you copied from OS X). However, you should also have some .dfont formatted fonts, which Xorg cannot understand. To use these, we'll have to download a little command line app that converts them to formats understandable by Xorg. Unfortunately, it's not in Ports so we'll have to download the app manually from the project homepage.

Go to http://fondu.sourceforge.net and download the source version of fondu in a gzipped tarball. For example, "http://fondu.sourceforge.net/fondu_src-051010.tgz". Then,

tar -xzf fondu_src-051010.tgz && cd fondu
./configure
make
make install

Using fondu is a breeze:

cd /usr/local/lib/X11/fonts/user
fondu *.dfont
rm *.dfont

Now that our fonts are in place, all we need to do is add them to Xorg.

Windows

Copy your Windows Fonts directory to FreeBSD. (On Windows 2000, the Fonts directory is in "/WINNT/Fonts"). Place the Fonts directory in /usr/local/lib/X11/fonts/ on FreeBSD. Now we'll properly remain the directory:

cd /usr/local/lib/X11/fonts
mv Fonts user

Now that our fonts are in place, all we need to do is add them to Xorg.

Adding Fonts to Xorg

Now that we've placed our fonts, we need to inform Xorg of the fonts we have added to our system.

vi /etc/X11/xorg.conf

First scroll down to where you see Section "Files" Add this line to the bottom:

FontPath "/usr/local/lib/X11/fonts/user"

Now scroll down to Section "Module" and add:

Load "freetype"

In case you had to create those sections (which is unlikely) here's what it should look like:

Section "Files
        (Other FontPath lines)
        FontPath "/usr/local/lib/X11/fonts/user"
EndSection

Section "Module"
        Load "freetype"
        (Other Load lines)
EndSection

Now that our X Server is properly configured, we need to get it a file to tell it what new TrueType fonts we have available to it. Now we need to get ttmkfdir in order to create that file for us.

cd /usr/ports/x11-fonts/ttmkfdir
make install clean

Now that we've installed ttmkfdir we can run it to create a fonts.dir file:

cd /usr/local/lib/X11/fonts/user
/usr/local/bin/ttmkfdir > fonts.dir

The new fonts should be immediately available to X apps. (You'll have to restart any apps that were running prior to the installation of new fonts before these apps will be able to use the new fonts).