I’ve noticed significant variations in font rendering when using the GD/FreeType graphics libraries, depending on the platform and font technology used. Here’s a visual reference of my observations.
The following tables show buttons created with a PHP script using 2 type sizes. Both TrueType and Postscript (using T1Lib) are provided.
Font Rendering Comparison
Font used: Arial 9pt TrueType, Arial 11pt PostScript with 16-step anti-aliasing, 0 space, 0 tightness.
We see dramatic differences in TrueType rendering on different platforms. TTF letter spacing is bad on all but FreeBSD, e.g. the “Bu” of “Button.” TTF on Win32 is especially bad. PostScript looks the same on MacOS X and FreeBSD, and is clearly better than any of the TrueType buttons, assuming you want anti-aliasing.
The other important difference between TrueType and PostScript (T1Lib) are the APIs provided, at least through PHP. The ImagePSText function has two controls for spacing and another for anti-aliasing. ImageTTFText provides no such controls.
Font Rendering Comparison 2
Font used: Arial 8pt TrueType, Arial 10pt PostScript
MacOS X: binary provided by entropy.ch (GD 2.0.28, FreeType 2.1.9)
Win32: binary provided by PHP.net (GD 2.0.28, FreeType 2.1.9, no T1Lib)
Win32/Cygwin: compiled from source (GD 2.0.33-1, FreeType 2.1.9-1, T1Lib 5.1.0-1)
FreeBSD: as installed on textdrive.com (GD 2.0.28, FreeType 2.1.10)
Building PHP With T1Lib on Windows
The Win32 binary available from PHP.net does not include T1Lib, and as you can see here, TrueType font rendering on Windows leaves something to be desired. If you want to use the PostScript T1Lib, you’ll need to grab source and build your own. I used Cygwin for the build because you can get all the necessary libraries pre-built, thus saving a huge amount of hassle. Here’s the PHP configure line I used:
./configure --with-iconv --with-gd --with-t1lib=/cygdrive/c/cygwin/lib --with-png-dir=/cygdrive/c/cygwin/lib --with-freetype-dir=/cygdrive/c/cygwin/lib --with-libxml-dir=/cygdrive/c/cygwin/lib --with-zlib-dir=/cygdrive/c/cygwin/lib
Note that this does not create a web-safe version of PHP (according to the configure script). For my use generating buttons, I’m doing it locally from the command line so that’s okay. Your needs may vary, and you’ll probably need more configure options than I used here.