back

Installing X fonts

Introduction

This page describes step-by-step how you can install X fonts on a UNIX system running X-windows. As an example I use the jiskan16 font which contains 16x16 bitmaps of the Japanese kanji glyphs. I assume you already fetched jiskan16.bdf.

Step by step instructions

  1. Place the bdf font(s) files in a separate directory and run the X program bdftopcf over each of them:
    bdftopcf jiskan16.bdf > jiskan16.pcf

    The pcf fonts will load much faster than the bdf sources since they are compiled.

  2. Compress the fonts (optional but advisable) using the UNIX program compress:
    compress jiskan16.pcf

    This replaces jiskan16.pcf with a smaller file named jiskan16.pcf.Z.

  3. Create a font index file using the X program mkfontdir:
    mkfontdir .

    assuming that your current directory is the directory with the fonts. This command will create a file called fonts.dir in the directory containing the fonts. The fonts.dir file contains ASCII so you can display its contents with "more fonts.dir". It will look similar to:

    1
    jiskan16.pcf.Z -jis-fixed-medium-r-normal--16-150-75-75-c-160-jisx0208.1983-0

    The first line indicates how many fonts are stored in this directory (in this case just one font). The remaining lines in the file have two fields per line. The first field is the file name of the font. The second field is the X font name of the font.

    Although this might not be the best time and place to explain all these strings and numbers in the font name let me mention the most important ones (you can skip this if you're not interested):
    75-75
    The screen resolution this font was designed for. If your screen has a different resolution (like 100 dpi) you can still use this font, it just looks smaller.
    16
    The pointsize of the font. If your screen is 100 dpi the font will not display at 16 point but at 75*16pt/100 (~=12pt).
    jisx0208.1983-0
    The encoding of the font. The encoding of a font relates input character codes to glyphs in the font.
  4. Add the directory with the fonts to your X-server's font path (the list of directories from which the X-server will collect its fonts resources). You do this with the command:
    xset fp+ /full/path/to/font/directory

    Check the current font path with the X command:

    xset -q
  5. Finally, inform your X-server about the changes in the font resources by asking it to rescan all fonts.dir files:
    xset fp rehash

And Now Try It Out...

To check if the new fonts are known to the X-server check the fonts.dir file for the name (second column) of one of the newly installed fonts and next execute:

xfd -fn -jis-fixed-medium-r-normal--16-150-75-75-c-160-jisx0208.1983-0

This should display the 16 point kanji font in the font browser.
If you don't have the xfd program try the command:

xlsfonts | grep jis

and see if the new fonts are listed.


Page creation: Jan van der Steen