XFree86 Font Deuglification Mini HOWTO Doug Holland, meldroc@frii.com v1.0, 23 November 1999 How to fix ugly and unreadable X Window fonts. ______________________________________________________________________ Table of Contents 1. Introduction 1.1 Change Log 2. The XF86Config File 2.1 Setting The FontPath 3. X Server Command Line Options 4. TrueType Fonts (One of the few things Windows is good for) 4.1 xfstt 4.1.1 Installation 4.1.2 Adjusting the default font size 4.2 xfs 4.2.1 Installation 5. KDE 5.1 Applying KDE fonts & colors to non-KDE apps 6. Adjusting fonts in specific applications 6.1 Netscape Navigator/Communicator 6.2 WordPerfect 6.3 StarOffice 7. Credits 8. Legalities ______________________________________________________________________ 1. Introduction One of the most annoying sets of problems I have had to deal with is the abysmal default fonts and font settings of X (I'm talking specifically about XFree86, other versions of X may be better.) Many programs use fixed width default fonts when a variable width font would be more appropriate. Other programs use fonts that are ridiculously tiny and unreadable. The fonts that are bundled with XFree86 are barely adequate for the job. It does come with a halfway decent courier font, but its Times and Helvetica fonts are simple bitmap fonts that pixelize when they are scaled. Yuck! This HOWTO attempts to show how to adjust various font settings, install new fonts, and do other things that will greatly improve the appearance and readability of fonts on the X Window Desktop. This is done by adjusting the FontPath in the XF86Config file, by adding switches to X server command line in startx or xdm, by adding new fonts, by installing the TrueType font server xfstt, and by using a feature in the K Desktop Environment 1.1 that automagically adjusts font settings in many applications, including non-KDE apps to set their fonts and colors to match KDE's style settings. Comments, corrections, additions and critiques are always welcome. You can reach me at meldroc@frii.com . 1.1. Change Log 0.1: Feb. 21, 1999: First release. 0.11: Feb. 27, 1999: Added copyright info to protect my butt. 0.12: Jun. 10, 1999: Added A Plea for Help. 0.20: Sep. 14, 1999: Added section on xfs for Redhatters. Many thanks to Hal Burgiss for his contribution. 1.0: Nov. 23, 1999: Converted document to SGML, for submission to the Linux Documentation Project. Removed Plea for Help. 2. The XF86Config File The first place to look when seeking to cure font problems is the XF86Config file. (/usr/X11/lib/X11/XF86Config or /etc/X11/XF86Config are the usual locations.) 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.) 2.1. Setting The FontPath Use your favorite text editor and edit XF86Config. Near the top of the file, you should see something 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/" 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 renders. The default FontPath typically puts 75dpi fonts before the 100dpi fonts. If you have a high resolution display, this means very tiny fonts. The first tweak you'll use is to switch the 75dpi & 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'll notice that those fonts are pixelized. This is very ugly and needs to be fixed. So add :unscaled to the ends of the misc, 100dpi & 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. Doesn't the desktop look better already? 3. X Server Command Line Options The next thing you need to do is adjust the command line options for the X server. You'll want 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. If you start X from the console command prompt, type startx -dpi 100. If you use xdm for graphical logins, you'll want to edit your /usr/X11/lib/X11/xdm/Xservers file, 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 More information is in the X and Xserver man pages. 4. TrueType Fonts (One of the few things Windows is good for) Because the boys at Redmond are very concerned with the appearance of their software (as opposed to the internal workings ;) they built TrueType font support into Windows. Windows 95 and nearly every other variety of Windows comes with Arial, Times New Roman, and Courier New, which are roughly equivalant to Helvetica, Times and Courier. TrueType fonts are scalable, so they look good in large sizes, and they are well hinted, so they are readable at small sizes. Many windows applications come with dozens of TrueType fonts. Don't microwave your Windows CD yet, you'll want to get the fonts first. 4.1. xfstt Unfortunately, XFree86 does not come with built in TrueType support, so you'll have to add it yourself. The easiest way of doing this is with xfstt, a free TrueType font server. 4.1.1. Installation xfstt is very easy to install. First, you'll want to download the tarball from the web. The most current version is at http://metalab.unc.edu/pub/Linux/X11/fonts/Xfstt-0.9.10.tgz Once you have the tarball, untar it. tar -zxvf Xfstt-0.9.10.tgz Then build it and install it. Read the INSTALL file for quick instructions, but it's a no brainer. make; make install is all you have to do. Once that's done, copy the TrueType fonts you've managed to get from various sources to /usr/ttfonts, and you're ready to go. Start xfstt by typing xfstt --sync # updates xfstt's font database xfstt & # runs xfstt in the background. Then type xset +fp unix/:7100 # tells X about xfstt. or add FontPath "unix/:7100" to your XF86Config to tell X about the font service. 4.1.2. Adjusting the default font size If your TrueType fonts appear to be very tiny, the following commands help. Add the -dpi switch to your X server command line (see section 3 to do this.) Use the --res switch to tell xfstt to increase the default resolution. Use the following command line. xfstt --res 120 4.2. xfs xfs is an alternative font server that is now being included with RedHat based distributions. xfs is based on the FreeType Font library and provides similar functionality to xfstt. xfs is able to serve both TrueType and Type 1 fonts, as well as legacy X fonts. 4.2.1. Installation First step is to add TrueType Fonts to your linux filesystem. Su to root, and make a directory to hold the fonts: mkdir /usr/share/fonts/ttfonts Then, add fonts to this directory, either by copying them from your Windows system: cp /mnt/win/path_to_fonts/*ttf /usr/share/fonts/ttfonts/ or by downloading those available directly from Microsoft . These fonts are in self-extracting zip archives. You can still install them though in linux unzip Note that the font file names must be lower case. One quick and easy way to convert them is to copy them to a DOS (FAT16) filesystem and then copy them back. DOS doesn't do upper case. For a more linuxian way, go to the directory containing the fonts and type this: ls *TTF | while read f do [ -f "$f" ] && mv -f "$f" "`echo \"$f\" | tr A-Z a-z`" done You'll get the ">" prompt as you type each line, hit return at the end of each line above. Note the punctuation -- those "backquotes" are important! Once the TrueType fonts are properly installed, as root: ttmkfdir -o fonts.scale mkfontdir Rerun these commands anytime the contents of your font directory changes. Next, edit the xfs font config file, /etc/X11/fs/config, to add your TrueType fonts to the server's font list: catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled, /usr/X11R6/lib/X11/fonts/100dpi:unscaled, /usr/X11R6/lib/X11/fonts/75dpi:unscaled, /usr/X11R6/lib/X11/fonts/misc, /usr/X11R6/lib/X11/fonts/Type1, /usr/X11R6/lib/X11/fonts/Speedo, /usr/share/fonts/default/Type1, /usr/share/fonts/ttfonts, /usr/X11R6/lib/X11/fonts/100dpi, /usr/X11R6/lib/X11/fonts/75dpi Alternately, you can use the 'chkfontpath --add ' command to add fonts. While you're at it, you may want to change the default point size too. default-point-size = 140 This gives me 14 point, instead of the default 12. Some X apps use this, some won't. Next, make sure the FontPath line in /etc/X11/XF86Config is: FontPath "unix/:-1" Note that "unix/:7100" may also do the trick, but did not work with the initial release. Comment out any existing FontPath with '#' since you no longer need it. The xfs package itself should be installed already with the other XFree packages. To make sure it runs as one of the default services either use 'ntsysv' or chkconfig --add xfs Now xfs will start every time you boot. Now restart X to force the new FontPath and start/restart xfs /etc/rc.d/init.d/xfs restart You should now have a functioning font server. You can check which fonts are being served: xlsfonts | less or check them out further with xfontsel, and even better, gfontsel! 5. KDE KDE is one of the best things that have happened to Linux and X in a long time. It provides a consistent user interface that goes a long way towards making Linux accessable to the average non-geek. More information about KDE can be found at http://www.kde.org/ . So why am I singing it's praises here? This is because KDE 1.1 has a new feature that will make the fonts & colors in your programs, including non-KDE applications consistent with KDE's current style. 5.1. Applying KDE fonts & colors to non-KDE apps This is very easy. Simply start up the KDE Control Center, go to Desktop, and go to Style inside Desktop. In there, there will be a toggle switch labled "Apply fonts and colors to non-KDE apps". Turn it on, click OK, and your done! The next time you start up many X applications, they will use the same colors and fonts that your KDE applications do. Some people may like this feature better than others, but if you don't like it you can always turn it off. 6. Adjusting fonts in specific applications 6.1. Netscape Navigator/Communicator Netscape Communicator is particularly susceptible to font problems. If you're using the default FontPath, your fonts will be very tiny and very ugly. The first thing you'll want to do is fix your XF86Config FontPath (see section 2.) Using 100dpi fonts improves readability immensly. You'll also want check your font settings under Edit/Preferences, under Appearance/Fonts. To get rid of bitmap font pixelization, turn off the option "Allow Scaling" on the font selection. If you have xfstt or xfs, Netscape is perfectly capable of using TrueType fonts. However, it doesn't handle xfstt's quirkiness very gracefully. In Edit/Preferences, you can specify TrueType fonts as the variable and fixed width fonts, however Netscape will not remember the size you've picked after you closed it. If you haven't used the -dpi switch when starting the X server or used the --res switch in xfstt, you'll get very tiny fonts. Once I applied these two fixes, TrueType fonts work great. 6.2. WordPerfect Coming soon. 6.3. StarOffice Coming soon. 7. Credits Created by Doug Holland Email: meldroc@frii.com WWW: http://www.frii.com/~meldroc/ Additional contributions by: Hal Burgiss Thanks go to: The folks at comp.os.linux.x who gave me a hand in figuring all of this out in the first place. The Linux community in general who made all of this possible in the first place. Microsoft and Apple: for providing the fonts that adorn my desktop. 8. Legalities Copyright 1999 by Doug Holland. Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions. All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator for more information. In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would very much like to be notified of any plans to redistribute the HOWTOs, this one in particular! Web page authors are free to link to this HOWTO without restriction, though the author would appreciate an email informing him of this, just so he can boost his ego by knowing who else reads and links to this document. Many of the terms mentioned in this document are trade names. Unless otherwise stated, all trademarks are property of their respective owners.