Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

2. X Server Configuration

There are a few simple configuration tweaks that will help X do its job better.

2.1. Setting The FontPath

The first place to look for curing font problems is the XF86Config file. /usr/X11/lib/X11/XF86Config or /etc/X11/XF86Config are the common locations. (This may be XF86Config-4 for XFree86 4.x.) If you haven't guessed already, the most important part of this file relating to fonts is the FontPath. Before we get into that, this would be a good time to check the other parts of your X configuration. Bad monitor settings can be even more of a headache than bad fonts, so make sure your refresh rate is as high as your monitor can handle (85 Hz is great, 75 Hz is OK, 60 Hz is painful.)

Use your favorite text editor and edit XF86Config. Near the top of the file in the "Files" section, you should see something vaguely like this:

FontPath        "/usr/X11R6/lib/X11/fonts/misc/"
FontPath        "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath        "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath        "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath        "/usr/X11R6/lib/X11/fonts/100dpi/"
   

This much should be the same, or at least similar, for both XFree86 3.x and 4.x. The FontPath tells X where to find the fonts it uses to render text on your display. Order is important -- when an X application asks X to render some text, the X server usually has some leeway to choose the font that is used. The X server then goes through the FontPath and grabs the first font it sees that matches the X client's criteria, and then displays it. (Note that Red Hat's xfs for versions 6.x and later has a different way of setting the FontPath. See the Section A.2 below for more on xfs.)

If the 100dpi fonts are not listed, they probably did not get installed for whatever reason, so you may want install them now. Default installations may put 75dpi fonts before the 100dpi fonts. If you have a high resolution display (1024x768 or higher), this means very tiny fonts. If this is the case, the first tweak you'll use is to switch the 75dpi and 100dpi FontPath lines:

FontPath        "/usr/X11R6/lib/X11/fonts/misc/"
FontPath        "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath        "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath        "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath        "/usr/X11R6/lib/X11/fonts/75dpi/"
    

Next, specify that you prefer to use unscaled bitmap fonts. If you've ever used Netscape or any other program that displays titles using big fonts, you might have noticed that those fonts were pixelized. This is ugly and needs to be corrected. So add :unscaled to the ends of the misc, 100dpi and 75dpi fonts. You can even use both unscaled and scaled fonts if you want, just put the unscaled FontPath lines first to tell X you prefer unscaled fonts if possible:

FontPath        "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath        "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath        "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath        "/usr/X11R6/lib/X11/fonts/Type1"
FontPath        "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath        "/usr/X11R6/lib/X11/fonts/misc"
FontPath        "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath        "/usr/X11R6/lib/X11/fonts/75dpi"
    

After making these changes, restart X (and your font server, if installed). Doesn't the desktop look better already?

2.2. X Server Command Line Options

The next thing you might need to do is adjust the command line options for the X server. It is important that the dpi resolution be accurate. Run this command:

   $ xdpyinfo | grep resolution resolution: 111x111 dots per inch
 

If this does not look to match what your monitor can do, or if it is unbalanced (e.g 98x95), you will need to use the -dpi switch which specifies the display resolution in dots per inch. As a lot of systems use high resolution displays these days, chances are they'll be working at 100 dpi, or better. While an unbalanced setting reportedly can really play havoc with some fonts.

If you start X from the console command prompt, type:

$ startx -- -dpi 100 -depth 16 # v4.x syntax

Or these options can be stored in ~/.xserverrc. See the startx and xinit man pages for more on this.

If you use xdm (or friends such as gdm) for graphical logins, you'll want to edit your /usr/X11/lib/X11/xdm/Xservers file (or possibly /etc/X11/xdm/Xservers) which will have the command line for the Xserver in it. Mine has the line:

:0 local /usr/X11R6/bin/X -dpi 100 -gamma 1.6

You want to specify a value that is compatible with your monitor's output.

More information is in the X, Xserver, xdm, xinit, and startx man pages.