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. And of course no big surprise, but they got the idea from Apple. In fact, TrueType is a registered trademark of Apple Computer, Inc. Windows 9x and nearly every other incarnation of Windows comes with Arial, Times New Roman, and Courier New, which are roughly equivalent 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 more TrueType fonts. Don't microwave your Windows CD yet, you'll want to get those fonts first!
Unfortunately, XFree86 3.x does not come with built in TrueType support, so you'll have to add it yourself (see below). This will mean installing a font server that does support TrueType and, of course, installing the fonts themselves. XFree86 4.x does have built in support however (see Section 4). You won't find many decent TrueType fonts included with any distribution. The likely reason is that there are not many quality TrueType fonts available under a suitable license at this time.
Let's start with the fonts first. Any TrueType font included with the various MS Windows incarnations should work. Don't forget word processors and other apps that may include their own fonts. MacOS fonts will only work if converted to a usable format. (See the links section for converter packages.) There are also some 'free' TrueType fonts available for download if you have already nuked that CD (see links section).
In order to use TrueType, the fonts will have to be always accessible to the font server. This means they will have to be on a filesystem that is always mounted. This can conceivably be a Windows partition on a dual boot system. Alternately, the fonts can be copied to Linux. First su to root:
# su -
# mkdir -p /usr/local/share/fonts/ttfonts
Now, change to the new font directory:
# cd /usr/local/share/fonts/ttfonts
Then, add the fonts to this directory, either by copying them from your Windows system:
# cp /mnt/<path_to_fonts>/*ttf .
or by downloading those available directly from Microsoft: http://www.microsoft.com/typography/fontpack/default.htm. These fonts are in self-extracting zip archives. The ones labeled for use with Windows 3.1 can indeed be unpacked under Linux with the Linux zip utility:
# ls *exe | xargs -n 1 unzip -L
The '-L' option will convert to lower case font names (this may be necessary for some versions of xfsft and Redhat's xfs). Note that the current Linux zip utility does not work with the 32 bit Win9x cab font archives. (It also looks like Microsoft no longer has the 16 bit Arial, Courier and Times-Roman on this site.) But these can be unarchived under Linux with cabextract, which can be found http://www.kyz.uklinux.net/cabextract.php3. This would now seem to be the best way to go since there is a better selection of fonts.
A slick solution to this from Sebastiano Vigna is his http://freshmeat.net/webFonts4Linux, which automates the downloading, extracting and installation of the Microsoft fonts all in one neat package.
Or you can get an RPM of WebFonts that contains some of the MS 'Web' TrueTypes from ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm. This has enough basic fonts to keep Netscape and other web browsers happy. Something similar for Debian is http://packages.debian.org/unstable/graphics/msttcorefonts.html. This does not include the actual fonts, but facilitates the installation.
You will also have to include the new TrueType directory(s) in the X server's fontpath. So with your text editor of choice add the line(s) as appropriate:
FontPath "/usr/local/share/fonts/ttfonts"
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"
There are several font servers available that will do the job: xfstt, xfsft, and Redhat's patched version of xfs based on xfsft. While these names are all too similar, these are different packages. One, or more, of these should be included with any recent Linux distribution, and you may have one installed already.
Historically, font servers were used to serve fonts over a network. Font resources could then reside on one host, and clients could access them as needed. But, the developers have enhanced these to include features such as the ability to render TrueType fonts. (XFree86 4.x has this ability included already, and thus an additional font server is not really needed solely for the purpose of having TrueType support.)
One such font server is xfstt. xfstt was designed specifically with TrueType fonts in mind.
xfstt is very easy to install and configure. If it isn't already installed, you'll want to download the tarball, or check your CD. The most current version can be found at http://metalab.unc.edu/pub/Linux/X11/fonts/
Once you have the tarball, unpack it:
$ tar -zxvf xfstt-*tgz
Then build and install it. Read the INSTALL file for quick instructions, but it's a no brainer.
From the xfstt directory is all you have to do.
# make
# make install
Then start xfstt with:
# xfstt --sync # updates xfstt's font database
# xfstt & # runs xfstt in the background.
xfstt should be started before the X server starts. Once you have this working correctly, you can add the above lines to /etc/rc.d/rc.local, or other suitable start up file. Then type:
$ xset +fp unix/:7101 # tells X about xfstt, and where to look for fonts.
or add:
FontPath "unix/:7101"
to your XF86Config to tell X about the font server. Rerun xfstt --sync any time the FontPath, or contents, change.
If your TrueType fonts appear to be very tiny, the following commands may help.
Add the -dpi switch to your X server command line (see section 3 above to do this.)
Use the --res switch to tell xfstt to increase the default resolution. Use the following command line.
# xfstt --res 120
As of Redhat Linux 6.0, Redhat based distributions (Mandrake, etc) have included a specially patched version of xfs, the XFree86 Font Server, and patched X servers as well. Redhat's xfs includes the xfsft patch set which in turn is built upon the FreeType Font library. Redhat's xfs provides similar functionality to xfstt. xfs is able to serve both TrueType and Type 1 fonts, as well as legacy X fonts.
If you are using a Redhat based distro, you should have xfs installed already. If not, it is in the XFree86-xfs*rpm. 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.
The default Redhat installation of xfs serves fonts via a Unix Domain Socket. We'll need to tell the X server where to look for xfs, and thus fonts. The FontPath in /etc/X11/XF86Config must include for Redhat 6.x:
FontPath "unix/:-1"
This is changed for Redhat 7.x to:
FontPath "unix/:7100"
At least for a default configurations. This is a reference to the socket where xfs is listening. You may include additional FontPaths, but these will be handled by the X server, and not xfs. A clean install of Redhat 6/7 should have this already set up, but if you are upgrading from an older version, you may have to change this yourself!
xfs then has its own, separate FontPath stored in /etc/X11/fs/config. This is where it will look to find fonts. This is over and above the X server's FontPath in XF86Config. You can either add the new path(s) with a text editor, or use the chkfontpath command:
# chkfontpath --add /new/font/path
The FontPath must exist before running chkfontpath. The relevant section of /etc/X11/fs/config should now look something like this:
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/Type1,
/usr/X11R6/lib/X11/fonts/Speedo,
/usr/X11R6/lib/X11/fonts/misc,
/usr/X11R6/lib/X11/fonts/100dpi,
/usr/X11R6/lib/X11/fonts/75dpi,
/new/font/path
When adding a new FontPath for TrueType fonts, you will want to do this step after installing and preparing the fonts. See the next section.
We still have a bit of work to do before we can actually use any TrueType fonts. xfs requires a few things to be in order. First, all font files must have lower case names for xfs. Secondly, they shouldn't have embedded spaces. And then, we will need to create a couple of files to make things go.
Su to root, and change to the directory where the TrueType fonts are.
# su -
# cd /usr/local/share/fonts/ttfonts
If there are any upper case font names, you can use the following script to convert all names to lower case:
#!/bin/sh
#
## -------- convert upper to lower case ---------
ls * | while read f
do
if [ -f $f ]; then
if [ "$f" != "`echo \"$f\" | tr A-Z a-z`" ]; then
#Note that 'This' will overwrite 'this'!
mv -iv "$f" "`echo \"$f\" | tr A-Z a-z`"
fi
fi
done
## eof
Note the punctuation -- the backquotes are important! Remove any spaces from font names too. Once the TrueType fonts are properly installed, you must create both fonts.dir and fonts.scale files. The following commands do this:
# ttmkfdir -o fonts.scale
# mkfontdir
You should now have fonts.dir and fonts.scale files in your TrueType font directory. ttmkfdir is in the Freetype RPM, and must be run before mkfontdir. With Debian based distros, there is a similar utility called mkttfdir, and is in the fttools Deb package. Though this apparently does not generate as many encodings as ttmkfdir. These commands may not always report errors, so verify that they were created and are not empty files:
$ ls -l fonts.*
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.dir
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.scale
If you encounter any problems, try ttmkfdir with the - m switch. This will discard bad characters from the font file. Specify a number such as 50 or l00 (ttmkfdir -m 50). The files themselves are text files. Have a look:
$ less fonts.dir
114
webdings.ttf -microsoft-Webdings-medium-r-normal--0-0-0-0-p-0-microsoft-symbol
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-ascii-0
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-fcd8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-9
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-1
[...]
Next, update the FontPath and xfs:
# chkfontpath --add /usr/local/share/fonts/ttfonts
# /etc/rc.d/init.d/xfs restart
You should now be in business. You can check which fonts are available to X:
$ xlsfonts | less
or check them out further with xfontsel, or gfontsel. If they are visible to xlsfonts, then they are available to X and vice versa. If they are not there, try restarting X with Ctrl-Alt-BS.
xfsft is a TrueType solution from Juliusz Chroboczek. xfsft is based on the FreeType font library as developed by Mark Leisher and others. It is essentially is a patch for XFree86's xfs and related libraries -- xfs + ft. Redhat's xfs is essentially xfsft with a few minor modifications. Also, XFree86 4.x includes the freetype font module which is also the result of Juliusz's work, and is one of the TrueType solutions available for XFree86 4.x.
Building xfsft requires having at least some of the XFree86 source available, in addition to xfsft itself, so this is not for the faint of heart. Instructions for building and configuring xfsft are in the tarball, so I won't go into details here. They are pretty straight forward. There are links to binaries available at the xfsft home page (see above).
Note that you must also create fonts.scale and fonts.dir files for xfsft. fonts.scale can be created manually (ugh!), or with the ttmkfdir utility. This is not included with xfsft but you can get it here: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz, or probably on many Linux archives sites too. Redhat has this as part of the Freetype RPM. And for Debian it is called mkttfdir and is in the fttools package.
You will also need a configuration file. Here is a sample:
-----------------------------------------------------
clone-self = off
use-syslog = off
client-limit = 20
catalogue = /usr/local/share/font/ttfonts
error-file = /home/jec/fonts/xfs.errors
# in decipoints
default-point-size = 120
# x,y
default-resolutions = 100,100,75,75
-----------------------------------------------------
You can then run start xfsft:
# xfs -port 7100 -config /path/to/your/config/file &
You can then add xfsft to the X server's FontPath:
$ xset +fp tcp/localhost:7100
If all goes well, you could then add this FontPath to XF86Config.
fonts.alias is yet another font configuration file that can be used to tweak how fonts are handled. Like fonts.scale and fonts.dir, fonts.alias must be in the same directory as the fonts you are aliasing. It is not mandatory however, but does solve certain potential problems.Here is an example from the first line of/usr/X11R6/lib/X11/fonts/misc/fonts.alias on a Redhat system:
fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
fixed is the 'alias' here. Any time this is requested, we actually get the font definition from the second column. Font too small? Just change the definition. (Warning: this is a critical file, at least on Redhat.) The same principle applies to all fonts, including TrueType. In fact, if you don't have TrueType, you could conceivably use this trick to have a comparable Type 1, or other, font aliased as a TrueType.
fonts.alias is important for some applications that don't handle the data provided by fonts.scale well. Most notably here is Netscape. Without a fonts.alias you will find that Netscape will only show point sizes of 0 and 12 available. fonts.alias fixes this. You might also find that if you a specify another size with the scalable font option under Preferences, Netscape will not remember this setting. Annoying! This is also fixed. So we really need this file. Sample excerpt from a fonts.scale:
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-ascii-0
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-fcd8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-1
These are scalable so we don't get any predefined point sizes. We will need to create our fonts.alias something like this excerpt for Arial:
-monotype-Arial-medium-r-normal--6-60-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--7-70-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--8-80-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--10-100-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--9-90-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--11-110-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--10-100-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--11-110-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--12-120-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--13-130-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--13-130-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--14-140-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--14-140-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--15-150-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--15-150-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--18-180-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--18-180-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--24-240-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--24-240-75-75-p-0-iso8859-1
(Please note that I have split each line for readability. There should be two columns all on one line, without the "\", and separated by at least one space.) This will keep Netscape happy. Also, if font names should have embedded spaces, then you should enclose the filename in quotes. You might also note the pointsize discrepancy between the first and second columns of the first few rows. The first column of the first entry has a '6', whereas this is aliased to a '9' in the second column, and thus '9' point. This is by design and is an excellent way to overcome the Netscape 'damn tiny fonts' syndrome. Adjust to suit your tastes, resolution, and eyesight.
This file can be created manually with a text editor, or conceivably with some fancy sed or awk scripting. There is an excellent discussion of this file, and other font related topics at Kristin Aanestad's site at http://home.c2i.net/dark/linux.html. There is also a link to a python script which can reportedly automatically generate a fonts.alias file at this same site. Thanks to Kristin whose work and insight was the inspiration for this section!
Note that with XFree86 4.0.2 and greater, there are new font handling mechanisms available via the Xft extensions. Font aliasing is done in Xft's own configuration file: XftConfig. This is the preferred method where anti-aliasing, and the other new rendering features are desired. See the Anti-aliasing Section for more on this. This is only true where the application itself supports the new extensions! At this time, not many do yet.