Enabling antialiased fonts in Slackware 9.0

by Brendan James Arnold
A guide to get nice looking fonts in common Slackware applications
home

Introduction

This guide will tell you how to install TrueType fonts (specifically the MS Webfonts,) and how to get them to display in some common applications. This guide has been tested on Slackware versions 9.0 to 12.1.

I would really appreciate feedback. Did this guide help? Was it completely inaccurate? Either way let me know on brendanarnold@gmail.com

Thanks to Paul Magwene for pointing out that there is a preinstalled alternative to ttmkfdir, Stephen Hodgson for reccommending that downloads be directed to mozilla mirrors, Enrico Giorio for pointing out an inconsistency, Pete Smith for pointing out a typo, Shane Kelly for some useful notes regarding Slackware 9.1 and importing fonts from Windows, Ray Bayley for testing the guide on newer versions of Slackware and to Frank Bell for verifying on versions up to 12.1

Installing TrueType fonts

Grab the MS Webfonts from the following address...

You will need the utility, cabextract to extract the fonts from the .exe files. This can be downloaded from the following address...

Compiling cabextract is just a case of the usual...

tar -zxvf cabextract-0.6.tar.gz
cd cabextract-0.6
./configure
make
make install

If you have a Windows partition, you can simply copy the fonts directly across without having to use cabextract etc.

Then, as root, create a directory to place your fonts in. I chose /usr/local/share/fonts/ttfonts/. Copy only the font files (the files that end in .ttf or .TTF) into this directory. If the fonts are to be used by all users, then it may be a good idea to change ownerships to root and ensuring proper file permissions by changing to the font directory and typing...

chown root.root *
chmod 644 *

Apparently Slackware 9.1 onwards comes with a pre-prepared folder for TTF fonts (found at /usr/X11/lib/fonts/TTF).

In addition, all filenames need to be lower case. Use this Perl one-liner to do just that.

find . | perl -ne 'chomp; next unless -e; $new=lc($_); rename $_,$new'

You will then need to generate the fonts.dir and fonts.scale files as well as the encodings using the mkfontscale and mkfontdir utilities which come with XFree86 4.3 (The X-Server in Slackware 9.0). Type the following in the directory in which you have placed your fonts...

/usr/X11R6/bin/mkfontscale /usr/local/share/fonts/ttfonts/
/usr/X11R6/bin/mkfontdir /usr/local/share/fonts/ttfonts/
/usr/X11R6/bin/mkfontdir -e /usr/X11R6/lib/X11/fonts/encodings

The X server supplied with Slackware has a font server capable of displaying TrueType fonts built in, we just need to let it know where the directory containing the fonts is. Open /etc/X11/XF86Config and add FontPath "/usr/local/share/fonts/ttfonts" (or whatever your font path is,) to the top of the list of FontPaths. Whilst you are editing the file, make sure that the line Load "freetype" (In the "Module" section) is uncommented.

You also need to edit the file /etc/fonts/fonts.conf. Add <dir>/usr/local/share/fonts/ttfonts/</dir> (or whatever the path to your font directory is) in amongst the other paths to font directories.

Although editing the file fonts.conf works in Slackware 9.1 it is warned against - instead try editing /etc/fonts/local.conf, this may not be necessary if you use the existing TTF fonts directory metioned above in Slackware 9.1

The TrueType fonts should be available now although they won't be properly hinted (spaced, weighted etc.).

Adding hinting support

The final step is recompiling freetype 2. Due to copyright, hinting of antialiased fonts is turned off by default. Download the source for freetype 2 from the link below,

Untar it as usual, but before compiling, open the file include/freetype/config/ftoption.h in the freetype source folder and look for the line that has TT_CONFIG_OPTION_BYTECODE_INTERPRETER. Once found, make sure it is uncommented and reads,

#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER

Now change back and type the usual...

./configure
make
make install

You should now have an antialiased font server! GTK2+ apps. should have automatic antialiasing and it simply a matter of selected TrueType fonts in KDE Control Center for nice fonts in KDE apps. However things may still look bad in certain other applications...

Antialised fonts in OpenOffice.org

To replace the UI fonts, go to Tools -> Options -> OpenOffice.org -> Font Replacement, check the 'Apply Replacement Table' check box and replace the font Andale Sans UI with a font of your choice.

Antialiased fonts in Mozilla

This should also work for Phoenix, although I have not tried it.

Mozilla has antialiasing capability but it is not compiled in by default. To enable it requires re-compiling Mozilla. To do this, you need the mozilla source. If you have the full Slackware CD set, then you can find it in source/xap/mozilla/mozilla-source-X.X.tar.gz, if not select an appropriate mirror from the address below,

and navigate through releases --> mozilla-X.X --> src. Unless you have special reason, download the .bz2 tarball as it weighs in at about 10MB less than the gzipped version. Even so, be warned that this is a huge download (~30MB!).

After untaring, you need to create a file called .mozconfig and put it into the mozilla directory. Copy the following into the file,

ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --enable-optimize
ac_add_options --without-system-nspr
ac_add_options --without-system-zlib
ac_add_options --without-system-jpeg
ac_add_options --without-system-png
ac_add_options --without-system-mng
ac_add_options --enable-crypto
ac_add_options --enable-strip
ac_add_options --enable-strip-libs
ac_add_options --enable-xft

Now type the following,

MOZILLA_OFFICIAL=1
export MOZILLA_OFFICIAL
BUILD_OFFICIAL=1
export BUILD_OFFICIAL

Now you are ready to start compiling. In the mozilla directory type,

make -f client.mk build

Now go and do something useful for about two hours depending on your processor ;-)

Once this is done, type the following to make a tar-ball of your binaries.

make -C xpinstall/packager

The tar ball will be found in dist directory. Copy this to wherever you want Mozilla installed (/usr/local/share/ is a good idea,) and untar it. Create a softlink to somewhere in your path by typing,

ln -s /usr/local/share/mozilla/mozilla /usr/local/bin

And start her up! Select some new fonts from Edit -> Preferences -> Appearence -> Fonts. They should be nicely antialiased.

Troubleshooting

My fonts look unbalanced
If you are sure that you have followed all the above, check the output of xdpyinfo | grep resolution, if the two numbers are not equal try starting X with the option -- -dpi 75 i.e. startx -- -dpi 75. This sets your dots-per-inch on your screen to a manageable 75×75.

References

What I want you to do the most right now is …

… visit my brother's Etsy shop