Font Addition Guide Joshua Saddler This guide shows you how to add new fonts to your system and display them properly in X11. 1.0 2005-10-09 Preparing and installing Xorg-X11

Don't you hate it when you're given a document with characters that don't display correctly, or come across a website that has words and letters replaced by strange symbols or ?s? This guide will show you how to properly add fonts to your system so that you can see the text as it was meant to be.

Since we want to be able to use fonts that are not included in a default installation of Xorg-X11, we need to emerge it with certain USE flags enabled: bitmap-fonts, truetype-fonts, and type1-fonts. You can place these flags in /etc/make.conf or in /etc/portage/package.use. If you want to use them globally, edit your make.conf to include them:

USE="bitmap-fonts truetype-fonts type1-fonts"

Or, if you prefer to set these USE flags just for the Xorg-X11 package, do this:

# echo "x11-base/xorg-x11 bitmap-fonts truetype-fonts type1-fonts" >> /etc/portage/package.use

Next, we emerge Xorg-X11. The --newuse flag ensures that Portage is made aware of our USE flag changes. This is especially good if you already have X11 installed on your system. In that case, --newuse re-emerges it with the new USE flags.

# emerge --newuse xorg-x11

This will take some time, so go find something to occupy your mind. Once Xorg-X11 is properly installed and initially configured (see The X Server Configuration HowTo), we can move on to adding and configuring fonts.

Font paths

By default, X11 stores all fonts in /usr/share/fonts. Take few minutes to explore this directory. You'll need to be familiar with its contents.

$ ls /usr/share/fonts

Next, let's look at /etc/X11/xorg.conf. X11 keeps track of the possible font locations in the "Files" section. Here's mine:

Section "Files"
        RgbPath      "/usr/lib/X11/rgb"
        ModulePath   "/usr/lib/modules"
        FontPath     "/usr/share/fonts/misc/"
        FontPath     "/usr/share/fonts/TTF/"
        FontPath     "/usr/share/fonts/Type1/"
        FontPath     "/usr/share/fonts/CID/"
        FontPath     "/usr/share/fonts/75dpi/"
        FontPath     "/usr/share/fonts/100dpi/"
        FontPath     "/usr/share/fonts/cyrillic/"
        FontPath     "/usr/share/fonts/intlfonts/"
        FontPath     "/usr/share/fonts/kochi-substitute/"
EndSection

You can specify new font paths in the "Files" section. As we will soon see, this is often necessary when you have installed a new font package.

Let's look at some of these directories in more detail. /misc/ contains many different fonts in various ISO-8859 locales, among other things. /TTF/ contains TrueType fonts, which end in a .ttf extension. TrueType fonts are used extensively in operating systems such as Windows. /Type1/ contains Type 1 fonts, although Type 1 fonts generally aren't as pretty as TrueType fonts, as the latter allows for better hinting. /75dpi/ and /100dpi/ contain standard fonts in 75 dots per inch and 100 dots per inch, respectively. /cyrillic/, /intlfonts/, and /kochi-substitute/ contain fonts added by certain font packages, as we shall see later.

/usr/share/fonts is not the only place to store fonts. Sometimes it's beneficial to place fonts in a user's home directory, for example /home/youruser/.fonts/. Some graphical desktops, such as fluxbox, don't always use the /usr/share/fonts/ paths specified in xorg.conf. In such cases, put fonts in the .fonts/ folder of a home directory and then add that path to xorg.conf.

Installing fonts
Installing font packages with Portage

One of the most common font packages Gentoo users will need (or want) is corefonts. This package contains many of the standard TrueType fonts that are part of Microsoft Windows, including Arial, Verdana, Times New Roman, Courier New, and Helvetica. These fonts are commonly used on many websites, as well. A few years ago, Microsoft made these fonts available to the public. The open source community quickly added these fonts to their package repositories, and just in time, too: shortly after making them available, Microsoft rethought their decision and removed the download from their pages. Now, corefonts is only available in Windows or in the package repositories for the various flavors of *nix and other operating systems. However, it is still legally free distributable, so let's emerge it.

# emerge corefonts

corefonts is one of the few font packages that needs no additional configuration in xorg.conf. In fact, you might not even need to restart the any applications you are running for them to make use of it. Gnome, for example, immediately makes the new fonts available under "Desktop --> Preferences --> Font". Mozilla Firefox also allows you to use the new fonts immediately. However, if an application (that supports the fonts) doesn't list them initially, you can restart your X session, or press Ctrl-Alt-Backspace to kill it. Start it again by typing startx.

Next, let's add international font packages, so that our web browsers can correctly display the various characters for pages that contain them. We'll emerge Japanese fonts and some European fonts.

# emerge intlfonts kochi-substitute

Now that we've installed the fonts, we need to edit xorg.conf to make the fonts available to the applications that depend on them. kochi-substitute and intlfonts have added several subdirectories to /usr/share/fonts, so we need to add them to the "Files" section of xorg.conf.

        FontPath     "/usr/share/fonts/ukr/"
        FontPath     "/usr/share/fonts/cyrillic/"
        FontPath     "/usr/share/fonts/intlfonts/"
        FontPath     "/usr/share/fonts/kochi-substitute/"
Manually installing fonts

Sometimes there aren't any font packages in the Portage repository, or you might have some fonts from an operating system on another partition that you'd like to use, or you've discovered a fantastic new font freely available on a website. Let's take a look at some of the ways you can manually add these fonts.

If you have a TrueType font (.ttf), you can move it to /usr/share/fonts/TTF. Otherwise, you can drop it into /usr/share/fonts/misc. If only certain users need a certain font, you can move the font to their home folder, /home/user/.fonts. However, moving fonts to /usr/share/fonts makes them available to everyone, which is a much better idea. It never hurts to have the fonts available just in case.

Once you've added fonts to a home directory, you may need to restart the X server and rebuild its font cache in order to use them:

# fc-cache -fv
# /etc/init.d/xdm restart
Once you've added fonts to a directory, be sure to add the path to them in xorg.conf, otherwise your X server won't know about them.
Conclusion

Now that you've finished setting up your system with many more useful fonts, go explore Portage to see all the other pretty fonts you can use to make your desktop a little bit nicer. For example, you can spice up your terminal windows with terminus-font. Or you can browse the web a little bit easier with a full set of TrueType Chinese, Japanese, and Korean fonts in Unicode: cjkuni-fonts. Happy font hunting!