Rashkae rashkae@tigershaunt.com
Tue, 2 Dec 2003
editted by A. Howlett andrew@howlett.net
Fri, 12 Dec 2003
editted by Dan Eriksen
(rewrote 1.2 as per tip by Avi Alkalay)
Wed, 28 July 2004
In our last meeting, I said I would send a tutorial to improving the font rendering of your distro... So here we go.
I've broken this process to 4 steps:
Compile and install Freetype library
Install additional TTF fonts.
Compile / Install Mozilla
Install OpenOffice.org 1.1
The instruction I provide will be at a fairly low level. Some distros may (and probably do) have tools to make some of these steps easier. (Such as font installation) Since I have little experience with modern Desktop Linux distributions, I will not be able to comment. Hecklers are welcome to promote their distro of choice by pointing out how much easier some of these steps are on their preferred system.
This step involves overwriting a system library, (because we want any application that might be linked to the old library to use the new one). This may cause problems with dependency tracking systems (such as RPM or Deb.) and or the library right get overwritten again when you run an update of your Linux system.
This section describes two methods of installing freetype: from the source tarball, and from the source rpm. Choose one method or the other, but do not do both.
For those whom might not know, True Type fonts in Linux can be rendered in one of two ways. The first and best way is to use Font Bytecode Hints that are part of the font itself. This hinting system is what makes fonts on Windows and Macs look so damned good at any size. It is also, unfortunately, patent encumbered, and therefore turned off by default on many commercial distributions. The second method of rendering TTF font's is with Freetype's very own auto hinting system (patent pending, :D ). This is now the default configuration of Freetype, and also that of many Linux distros. Unfortunately, the method of font hinting cannot be configured at run time, but must be compiled into the freetype binary.
Download the latest version of freetype from http://freetype.sourceforge.net/index2.html
Unpack the tarball.
Optionally, read the file docs/TRUETYPE. Note that as of this writing, the instructions in this file are wrong.
Open the file include/freetype/config/ftoption.h in your text editor of choice.
Find the line that reads:
/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
and remove thecomment marks. (The /* and */ ). This line should now read:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
Save and close the file.
From this point, follow the instructions in docs/UPGRADE.UNX
There is an easier way to do it using rpms. First, download a freetype source rpm, such as freetype-2.1.4-4.0.src.rpm (find a good download site using http://rpmfind.net).
We just need to rebuild the rpm:
bash# rpmbuild --define "without_bytecode_interpreter 0" --rebuild freetype-*.src.rpm bash# rpm -Uvh freetype-*.rpm
At this point, I'm assuming your running at least Xfree86 v. 4.2. If not, you might consider upgrading.
Please refer to: www.xfree86.org/4.3.0/fonts2.html#4
In particular, I found useful sections 2.2.2. Installing scalable fonts and 2.1.2. Fine-tuning Xft (personally, I find anti-aliased fonts to be headache inducing and turn them off where possible. I seem to be in the minority in this case, however. Gnome, KDE and OpenOffice.org also have independent controls to configure anti-aliasing in those respective environments.) You will notice from the first section of that document that installing fonts for XFT enabled applications is simplicity itself. Remember, however, that not all application are XFT enabled. If you want your True Type fonts to be accessed by other applications, the steps in 2.2.2 should be followed. Two of the fonts I find most vital are Microsoft Arial and Microsoft Times New Roman (I don't know if these typefaces actually belong to MS, but you can find them in any Windows installation.)
Also note, if you want to use True Type fonts in applications that are not XFT enabled, you might want to edit /etc/X11/XF86Config and uncomment the Load "freetype" in Section "Module". I found mine was commended out by default with my installation of Xfree.
This section will describe two ways to install Mozilla: from source and by installing the precompiled Firebird binary. You can do one or the other or both. Note that firebird does not include the mail client, so if you want the mail client you should follow the first method.
If you install the default Mozilla binaries, XFT is not enabled. You will find at http://www.mozilla.org/releases/index.html that there is a contrib build of Mozilla with XFT enabled. However, it is linked to gtk toolkit (instead of gtk2). gtk does not work so great with XFT, and the UI fonts end up small and hard to read.
Therefore, I suggest downloading the source tarball. A special warning; this is a large code base that will take several hours to compile on a high performance PC. There should at least be 1GB of free disk space as well. If someone wants a pre-compiled binary, e-mail me and I should be able to create one for your system.
Unpack the tarball and run ./configure --help | less for a list of configuration option. The trick there that you won't find documented anywhere is to link the application to the gtk2 toolkit. Your configure should look something like this.
./configure --enable-default-toolkit=gtk2 --enable-xft \ --enable-crypto --disable-debug --enable-optimize="-O3" --enable-strip
On my system, I also add -march=athlon-xp to the –enable-optimize option. You can modify this to suite your system if you know what compiler flags work best for your architecture and version of gcc. They don't mention this in the help, but enable crypto is required for https support (Secure web pages.)
After configure is done, run make.
When make is finished, if it doesn't die or crash, you can test your new build by cd'ing to dist/bin directory and run ./mozilla
When your satisfied that all is working, cd to xpinstall/packager and run make. This will create a tarball in the dist/bin directory. Move the tarball (tar.gz) file to somewhere useful (like /usr/local) and unpack it. This will leave a binary installation of your freshly compiled mozilla.
Note: You cannot run mozilla from a Symlink without various environment variables being configured. If you want mozilla to run from your system standard path, create an executable bash script that simply runs /usr/local/mozilla/mozilla. Make certain you remove any old binary or symlink from previous mozilla installations. I suggest uninstalling the Mozilla package from your package manager of choice before installing this one.
Optionally, from your compiled Mozilla source tree, you can also build an automatic mozilla installer. See instructions at: http://www.mozilla.org/build/distribution.html and skip to step 5.
Firebird is the Mozilla project web browser without the add-ons - composer, email, and newsgroup reader have been removed. Firebird is just the browser. There is a gtk2-xft binary of firebird in the contrib directory. Download the binary package. It is a tar.gz compressed archive, so untar it and extract it. You will now have a directory named MozillaFirebird. Change to this directory and launch firebird. Here are the instructions:
bash$ tar -xzvf MozillaFirebird-0.7-i686-linux-gtk2+xft.tar.gz bash$ cd MozillaFirebird bash$ ./MozillaFirebird
For those masochists who are actually still reading:
I've never successfully built Open Office from source. The OpenOffice binary installer comes with its own pre-compiled freetype library (without hinting). I've noticed, however, that as of the 1.1 series, the installer will link the application to your system freetype library if available. You can verify this by executing the command
bash$ ldd soffice.bin| grep freetype
(my soffice.bin is located in /opt/OpenOffice.org1.1.0/program). The result should be something like
libfreetype.so.6 => /usr/lib/libfreetype.so.6
indicating that my soffice is linked to the freetype I installed earlier. If this is not the case on your system, you might have to re-install OpenOffice and or symlink the file freetype is linked to in the OpenOffice directory to the correct library file. I'm not sure off hand how to do this.
To install your TTF fonts in OpenOffice, run the spadmin program (as root). spadmin is in the same directory as soffice.bin. Click on fonts button, then click on Add button. Click the ... button and find the directory where you copied your TTF fonts from step 2. (In my case, /usr/X11R6/lib/fonts/TTF. At your option, you can check to create soft links only (which will prevent copying all the files to the Office directory.) Click on Select All button and click on OK. Note: make sure all users have read and execute permission to the /opt/OpenOffice.org1.1.0/share/fonts/truetype direcotory. I found this was bugged in one of the release candidates (probably fixed by now.)
After completing step 3 I logged out of X and logged back in. KDE and OpenOffice seem to have picked up the new freetype library without any configuration required. I enabled aliasing but I might go back and try it without aliasing. Using the shortcut methods in sections 2.2 and 3.2 cut my installation time down to about 15 minutes. Your mileage may vary.