Customizing the Fonts For Your X-Window Environment

by Anu Rao


Set Up

We will use a Cyrillic font as an example. First, we need to set up some preliminaries:
  1. Either cp /usr/common/starts/RUS/xinitrc.rus ~/.xinitrc
    OR add the following lines to your .xinitrc file: /usr/bin/X11/xset fp+ /usr/local/lib/X11/fonts/CYR,/usr/local/lib/X11/fonts/OW &

    {This will append the above directories to the current font path for your X applications. Each font directory contains the font definitions and two files, fonts.dir and fonts.alias.

    The fonts.dir file consists of two columns, the first is the name of the font file, the second is the name by which you would reference it in your X applications (more on this below). The fonts.alias file contains aliases for the very long names by which we reference the fonts (in fact, you can define your own fonts.alias file. More on this below). }

    /usr/bin/X11/xmodmap /usr/local/lib/X11/CYR/jcuken.iso.xmm &

    {This defines a keyboard map for font defined in the file specified. In this example, we use the map file jcuken.iso.xmm , which allows the keyboard to emulate a Russioan typewritter by hitting the CAPS LOCK key, once we have executed an application which is to use the Cyrillic font we have chosen.}

  2. We need to set our terminal to read 8-bit fonts. In order to do this, on a SUN, add the following to your .profile file (if using ksh; if using csh, add to your .cshrc file):

    stty pass8

    On an SGI, add the following line instead:

    stty cs8 -istrip

    To check that your terminal has the cs8 and -istrip settings, type

    stty -a

    which will display your terminal settings.

  3. If you would like to use the Cyrillic font with Netscape, either

    cp /usr/common/starts/RUS/Xdefaults.rus ~/.Xdefaults
    OR add the following lines to the end of your .Xdefaults file:

    
    Netscape*documentFonts.latin1*registry:        koi8r
    Netscape*documentFonts.latin1*encoding:        *
    
    

    {This adds the Cyrillic fonts to Netscape's repetoire of fonts.}

Now we are all set to run an X-Window application using our Cyrillic font!

Xterm

To open an xterm with a Cyrillic font, at the UNIX prompt type

xterm -fn bob &

where "bob" is an alias defined by our favorite system administrator in the file /usr/local/lib/X11/fonts/CYR/fonts.alias. This will pop up a window. To activate the Cyrillic keyboard, hit the CAPS LOCK key, and type away!


Netscape

To view Netscape documents written in a Cyrillic font, instead of running netscape, run netscape_rus. Check out the Russia On-Line or Moscow Sate University web sites, both of which support Cyrillic fonts.

Create Your Own Font Alias

To create your own font aliases, choose a font from the fonts.dir file. For example, I'd like to define my own alias myfont for the font

cronyxcorrmdmnrml8807575m50k8r18.pcf

in the directory /usr/local/lib/X11/fonts/CYR. I would do the following:

  1. Find the corresponding string entry in the fonts.dir file for this font. In this case, the corresponding string entry is

    -cronyx-courier-medium-o-normal--8-80-75-75-m-50-koi8r-1-8

  2. I then create a subdirectory in my own directory, called, say, myfontdir (it can be named anything I like). In this directory I create a file called fonts.alias with one line in it:
    myfont -cronyx-courier-medium-o-normal--8-80-75-75-m-50-koi8r-1-8
    
  3. I then need to add this directory to the current fontpath and update it:
    
    xset fp+ /aplm/rao/myfontdir
    xset fp rehash
    
    

    To display the new current fontpath, type

    xset -q

  4. Now I'm ready to use this font. Example:

    xterm -fn myfont &

    will pop up an xterm that will use myfont when the CAPS LOCK key as been activated.

http://math.arizona.edu/~swig/documentation/fonts/index.php
Last modified: Fri, 14 Dec 2007 15:50:51 -0700
E-mail: swig@math.arizona.edu
Valid XHTML 1.0! Valid CSS!