TrueType for XFree86 Mini-Howto


Overview

This mini-howto describes the steps I followed to use TrueType fonts in X Windows. If you want to get to the guts of this mini-howto, you skip the background section.

 

Credits

A big thank you goes out to all the people who emailed me with suggestions, comments! This page will slowly incorporate all your recommendations!

 

Disclaimer

I cannot guarantee the accuracy or correctness of the information I present in this howto. What I describe here is basically a log of what I had to do to set up my system. I cannot be held responsible for any damage done to your systems, use this information at your own risk!

That being said though, if you have questions, comments, or suggestions, please send me email at ying @ zippydesign dot com.

 

Background

I have always been unhappy with the quality and limited selection of the fonts in X. They are inferior when compared to what is availalbe in the TrueType font world. The handful of ugly fonts that came with XFree86 were pitiful compared to what I was use in Windows. Fortunately, some kind souls created the FreeType project and XFSFT patches. I won't go into details about what they are, visit their respective homepages if you are interested.

My desktop dualboots Linux and Windows 98, and all my truetype fonts are stored in the Windows 98 partition. What I wanted to do was be able to use those fonts in X. I am running:

  • RedHat Linux 5.2 (with the 2.2.1 kernel)
  • XFree86 3.3.3

If your configuration differs, please make the appropriate changes to my examples.

 

What You Need

First of all let's gather all the necessary components. Since I'm using RedHat, I'll be using the RPM's to install everything. It is assumed that you already have X up and running. The versions of software I list below are the most current (as of this writing), I found them on rpmfind.net.

Special thanks to Jim Wadell and Stephan F. Stevens from the Alaska Linux User Group for providing a convenient place to grab all of the above files. You can download them from ftp.aklug.org/pub/contributions/TrueType.

 

Installing

The nice thing about RPM's is that they are so easy to install. You have to be root to install RPM's, so once you're root and get to the directory where you downloaded these files to:

$ rpm -Uvh freetype-1.2-i386.rpm
$ rpm -Uvh freetype-devel-1.2-i386.rpm
$ rpm -Uvh xfsft-1.0.3-1.i386.rpm

You'll have to build ttmkfdir manually, so:

$ mkdir ttmkfdir
$ cd ttmkfdir
$ tar -zxf ../ttmkfdir
$ make FREETYPE_BASE=/usr

You'll end up with a binary ttmkfdir, copy this to /usr/local/bin or wherever you like. You need it to make fonts.dir and fonts.scale files, more on this later.

 

Creating a Fonts Directory

First we have to make directories for our TrueType fonts (ttf). Here's your first decision, do you want to use fonts from an existing Windows partition or not.

Using Fonts from an Existing Windows Partition

If you have a dualboot system and would like to use the fonts out of your Windows directory, then read on otherwise this part doesn't apply to you. I have my ttf's in my Windows partition, I mount this as /mnt/c, so my fonts are in /mnt/c/windows/fonts. I made a symlink called /usr/share/fonts/truetype that points my real ttf directory.

$ mkdir /usr/share/fonts
$ ln -s /mnt/c/windows/fonts /usr/share/fonts/truetype

Installing New TTF Fonts

If you don't have Windows on any other partition, or would like to keep the fonts separate, then just make this directory and fill it up with your favourite truetype fonts:

$ mkdir /usr/share/fonts
$ mkdir /usr/share/fonts/truetype

 

Setting up the Fonts Directory

After you have your ttf's in the fonts directory, you have to build fonts.dir and fonts.scale files. If you're curious as to what they do, read up the documentation that comes with the xfsft package.

Okay, now go into the ttf font directory and run ttmkfdir (the thing you built a while ago):

$ cd /usr/share/fonts/truetype
$ /usr/local/bin/ttmkfdir > fonts.scale
$ mkfontdir

ttmkfdir might complain about a couple fonts, read the docs to find out why. The mkfontdir program comes with XFree86, so if it's not in your path then you should find out where it is. It is also important to note that everytime you add a font to your system, you must run tmkfdir and mkfontdir again.

 

Configuring XFSFT and XF86Config

W're almost done, there's just two files to edit, /usr/etc/xfsft.conf and /usr/X11/XF86Config.

xfsft.conf

Add the directory /usr/share/fonts/truetype and remove (or comment out) directories that you don't have for the catalogue directive. This is what mine looks like:

clone-self = off
client-limit = 20

catalogue = /usr/X11R6/lib/X11/fonts/Type1,
            /usr/X11R6/lib/X11/fonts/misc,
            /usr/X11R6/lib/X11/fonts/Speedo,
            /usr/X11R6/lib/X11/fonts/75dpi,
            /usr/share/fonts/truetype,
#            /usr/X11R6/lib/X11/fonts/100dpi

use-syslog = off
error-file = /var/log/xfsft-errors.log

default-point-size = 120
default-resolutions = 100,100,75,75

XF86Config

XFSFT is able to render your other fonts as well as TrueType fonts. So if you already have a font path specified in your xfsft.conf, you don't need to specify it in your XF86Config. Just add a line telling X to look at the TrueType font server. Here is the relevent section from my XF86Config, the line in bold is what you have to add, and notice I commented out all my other font paths:

FontPath   "tcp/localhost:7100"
#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"
NOTE:

Looking at the tcp/localhost:7100 path, you can probably guess that this font server doesn't have to run on localhost. In fact, you can setup one font server (let's say on host fonty), and have all your other X servers point to tcp/fonty:7100 for fonts. These X servers don't have to be running XFree86, this will work on any X server (eg. NCD X Terminals, etc.).

This also means that you should have adequate protection if you don't want other people accessing your font server -- think about rejecting incoming tcp packets on port 7100 (or whatever port yours runs on).

That wraps up the configuration, let's start it up!

 

Starting the TrueType Font Server

If you installed the RPM, just run:

$ /etc/rc.d/init.d/xfsft start

All this does is call /usr/X11R6/bin/xfsft -port 7100 -config /usr/etc/xfsft.conf so if you didn't install the RPM, put this in your rc.local or whatever. No error messages? Good, let's do the final step -- (re)starting X.

 

Starting X

You know how to start X, run startx. If you didn't see any error messages then voila, you've got your fonts! Go wild, load up Netscape and change the fonts to Times New Roman or Arial. Use Courier New instead of that gross thing you've been looking at for so long. Load up GIMP and play with all your new fonts!!

If you don't want to restart X, just run:

$ xset +fp tcp/localhost:7100

If you do this, be sure to restart the applications (like Netscape) to make the rebuild the font list. Enjoy!

 

Get More Fonts

Incase you don't already own a gazillion fonts, here are some places for you to pick up some freebies:

 

Known Issues

The only problems I've run into so far are:

  • I can't get StarWriter 5.0 (the word processor component of Star Office) to use TrueType fonts. Every other component of StarOffice works happily with the fonts but not StarWriter.

  • In Netscape, be sure to click Allow Scaling if you pick a TrueType font as the default fixed or variable fonts. Also note, Netscape only lists two sizes (0 and 12.0) when you choose a truetype font.

  • Alas, you cannot print these fonts, they will print as Times no matter what font is displayed on-screen. I've tried both in Netscape and StarOffice (with the components that can display True Type fonts on-screen).

 


Link Exchange Fast Counter
Web Database Mini-Howto by Ying Zhang (ying @ zippydesign dot com)