Changing fonts

Adding a font to your system

It is possible to add additional fonts to your system. If you want to add fonts to any of the default subdirectories in /usr/lib/X11/fonts, you must be logged in as root. You should also ensure that /usr/bin/X11 has been added to root's $PATH environment variable.

To add one or more fonts to your X server, perform the following steps. You must be logged onto the system as root.

  1. Place the new font file or files in the directory in which you want to store them.

  2. Run the bdftopcf utility, if desired, to convert BDF font files to PCF files:

    bdftopcf font.bdf > font.pcf

  3. Run the mkfontdir command and indicate the font's directory location, if necessary:

    mkfontdir font_location

  4. If you added fonts to a directory not in the current font path, add the new directory to the font search path:

    xset fp+ font_location

  5. Reset the server's font database with the following command:

    xset fp rehash

Step 1: Placing the font files on your system

When you add new fonts to your system, you need to give some thought to where you want to put the actual font files. Generally, fonts are located in subdirectories of /usr/lib/X11/fonts. You can put your new fonts in one of these subdirectories, perhaps in /usr/lib/X11/fonts/misc, or anywhere else on the system, including subdirectories within individual users' accounts.

New font files can be in Bitmap Display Format (BDF), Server Natural Format (SNF), or Portable Compiled Format (PCF). See Step 2 for more information on these formats.

Step 2: Converting from BDF to PCF format

The standard font format is Bitmap Display Format (BDF). BDF font files are portable and represent the characters of a font in ASCII. These files generally have a .bdf extension. Fonts can also be compiled in the Portable Compiled Format (PCF). PCF font files generally have a .pcf extension.

The X server can use font files that are in BDF, PCF, or SNF format. However, there are several good reasons to convert any BDF files on your system into PCF files:

To convert BDF font files to PCF files, run the following command:

bdftopcf font.bdf > font.pcf

font.bdf refers to the actual name of the BDF font file that you want to convert. The file font.pcf contains the converted font.

If you run the bdftopcf utility from a directory other than the one containing the BDF file you want converted, remember to specify the complete pathname of the file.

NOTE: If you are converting BDF fonts for use with an X terminal, be sure to read the manual that is supplied with your terminal for special instructions on running the bdftopcf utility. Some X terminals require that you specify various flags for the bdftopcf command; other X terminals only support some of bdftopcf's options.

For more information on the flags that you can use with the bdftopcf command, see the bdftopcf(X) manual page.

Step 3: Running mkfontdir

If you add new fonts to an existing fonts directory or create an entirely new fonts directory, you must run the mkfontdir command. This command checks for the existence of a fonts.dir file in the directory that contains the new fonts. If such a file exists, mkfontdir adds an entry for each new font to the file. If the font directory is new and does not already have a fonts.dir file, mkfontdir creates the file for you.

If you run mkfontdir from the directory containing the new fonts, you do not need to specify the directory name. By default, the mkfontdir command operates on the current working directory. If, however, you run mkfontdir from a different location on your system, you must specify the complete path of the directory containing the new files. For example, if you added new fonts to the misc directory, you should enter:

mkfontdir /usr/lib/X11/fonts/misc

NOTE: To run mkfontdir on one of the default font directories (/usr/lib/X11/fonts/misc, /usr/lib/X11/fonts/75dpi, /usr/lib/X11/fonts/100dpi) /usr/lib/X11/fonts/Speedo, or /usr/lib/X11/fonts/Type1), you must be logged in as root.

If you added new fonts to a subdirectory named myfonts within your home directory, you should enter:

mkfontdir $HOME/myfonts

See also:

Step 4: Updating the font search path

If you placed your new font files in a directory that is not part of the font search path, you need to add the font directory to the search path so the X server can locate the new files. You can tell the server of the new directory using xset and the fp+ option:

xset fp+ font_location

For example, if you added fonts to a subdirectory called myfonts in your home directory, the following command appends the directory $HOME/myfonts to the X server's font search path:

xset fp+ $HOME/myfonts

You can add multiple directories to the font path at the same time. After the fp option, each font directory should be separated by commas, as below:

xset fp+ $HOME/myfonts,/usr/lib/X11/fonts/newfonts

Step 5: Resetting the font database

To complete the font installation, you must make the X server aware of the additions to the font database. The font files must be located in a directory included in the font search path. To reset the font database, enter the following:

xset fp rehash

This command tells the X server to reread all of the fonts.dir and fonts.alias files in the current font path. You should now be able to use your new fonts in a resource file or on the command line.

Next topic: Example of setting fonts
Previous topic: Step 2: Resetting the font database

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003