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, they got the idea from MacOS which is
where TrueType originated. Windows 9x and nearly every other flavor 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. XFree86 4.x does have built in support
however (see Section 4). This will mean installing a font server
that does support TrueType and, of course, installing the fonts themselves.
You won't find decent TrueType fonts included with any distribution. The
likely reason is that there are not any 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 too. MacOS fonts will not work. There
are also some 'free' TrueType fonts available for download if you have
already nuked that CD (see Links in Section 6.2).
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.
These fonts are in self-extracting zip archives. You will need to get the ones
labeled for use with 'Windows 3.1' if you need to extract them under Linux.
You can indeed unpack these in 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 font archives. (It also looks
like Microsoft no longer has the 16 bit Arial, Courier and Times-Roman on
this site.) Or you can get an RPM of WebFonts that contains some of the MS
TrueTypes here.
This has enough fonts to keep Netscape and other web browsers happy.
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:
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 just solely
for the purpose of having TrueType support.)
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.
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:
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:
FontPath "unix/:-1"
for Redhat 6.x, or for Redhat 7.x:
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:
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. 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. These commands don't seem to 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:
Rerun the first and last of these commands anytime your add or remove fonts.
xset +fp only needs to be run when adding a new font
directory to an existing Fontpath.
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.
You will also need a configuration file. Here is a sample:
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 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:
(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!