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).
Many distributions are now bundling tools for automating the process of including quality TrueType fonts. SuSE, Debian, and Mandrake do (Red Hat 7.x does not at this time). See what packages you might have for this as this will be the most painless way to go. Essentially, these tools help migrate fonts from a Windows installation, or download those available from Microsoft [note 08/15/02 MS has recently removed these fonts!] , and then handle the installation and configuration all in one neat utility. If you do have such a utility, the below information may not be necessary!
In order to use TrueType, the fonts will have to be always accessible to X. 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. Note 08/17/02: Microsoft has recently discontinued this page. At this time, the following pages (may!) still have these fonts available (or google search for them):
http://nuoriso.hel.fi/__files/ms_truetype_core_fonts_for_the_web/Win95-98-NT/index.html |
http://web.archive.org/web/20000420210719/http://www.microsoft.com/opentype/fontpack/default.htm |
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 at this time.
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. A utility designed primarily for Red Hat can be found: http://sourceforge.net/projects/font-tool/, which includes all the core MS web fonts, plus relevant system configuration. There is a tarball, as well as RPMs (both require cabextract).
You can also get an RPM of WebFonts that contains some of the MS Web fonts from ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm. This has enough basic fonts to keep Mozilla 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.
If doing it yourself, 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"
This configuration is for "core X font" support. For additional configuration relating to the new Xft rendering engine, see the sections below on XFT and anti-aliasing.
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
And very simply, make this small change:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
%define without_bytecode_interpreter 1 |
%define without_bytecode_interpreter 0 |
Other vendors may have a similar, easy-to-use mechanism.
Note that "hinting", "anti-aliasing", and "sub-pixel rendering" are separate concepts (see the section on Xft below for more). Again, this is not a cure-all for "ugly" fonts, but one more piece in the puzzle of font "beautification".
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
If you don't have ttmkfdir installed, check your distribution's repository, or it can be downloaded from: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz. This is necessary!
As of Red Hat 7.1, the above commands are run from the xfs init script. So restarting xfs (/etc/rc.d/init.d/xfs restart) will accomplish the same thing for Red Hat users. Other distros may have similar shortcuts.
You should now have fonts.dir and fonts.scale files in your TrueType font directory. ttmkfdir is in the Freetype RPM for Red Hat users, 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
[...]
If ttmkfdir is persistently giving problems by not generating a proper output file, there may be one or more "bad" fonts (ie fonts it can't handle). In that case, just start with a few common ones, like Arial and Verdana. If this works, then add a few at a time.
Now be sure the new fonts are included in the FontPath. And either restart X (Ctrl-Alt-BS), or the font server (if using one). You could also try refreshing the FontPath:
# xset fp rehash
Red Hat 6.x/7.x users can 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.
This gets you as far as X knows about your new fonts. Individual applications will need to be configured to use them. GNOME and KDE will require additional steps as well (see the respective docs). You will also want to configure Xft (see below), if using XFree86 v4.x or later.
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 does have built in support for TrueType (see Section 4), making a font server not a necessity, though some distros default to using a font server for other reasons now.
XFree86 3.x does not come with built in TrueType support, so you'll have to add it yourself if you are using a 3.x version. This will mean installing a supplemental font server that does support TrueType. And, of course, installing the fonts themselves (see above). See the Appendix for font server installation, and related tips.
Any recent distro will have one or more font servers included, and the important configuration should be done by the installation program.
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 Red Hat.) 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. A perl version of this script is re-printed in the Appendix. Thanks to Kristin whose work and insight was the inspiration for this section!
Another potential use of fonts.alias would be to map one font to something quite different. Say you don't have TrueType fonts, and didn't want to install Microsoft's. You could alias nice, scalable Type 1 fonts to a TrueType. That way when the system (or some web page) wants a TrueType, you'd get something of comparable quality instead of bitmap that doesn't scale well.
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 and de-mystification. This is only true where the application (i.e. the toolkit, e.g QT) itself supports the new extensions! At this time, not all do (yet).