There was recently a thread on this list discussing the installation
of php 4.1.x with gd-2.0.1 and freetype-2.0.8. The conclusion of
this discussion was that php-4.1.x requires gd-2.0.2 which has not
yet been released.

I have obtained a copy of a patch to gd written by Wez Furlong (who
also maintains PHP's gd interface). With this patch I have successfully
compiled php-4.1.2 with gd-2.0.1-patched and freetype-2.0.8.

In order to perhaps save others the grief I have been through over the
last couple of days, I am making this patch and my config available.

Instructions:

Get freetype 2.0.8 from http://freetype.sourceforge.net/
and install it (or install a package if your system has one).

Get the gd-2.0.1 tarball from http://www.boutell.com/gd/
Get Wez's patch from:
http://mel01.juggernaut.com.au/patches/gd/gd-2.0.1.patch.wez.gz

Make sure you don't have any old gd libraries installed on your
system. If you have gd-1.8.4 installed PHP might not find the new
2.0.1 installation. Track down old libraries with:
find / -name "libgd.*" -print

Build gd with the patch and install it:

gzip -d gd-2.0.1.patch.wez.gz
tar -xzf gd-2.0.1.tar.gz
cd gd-2.0.1
patch -p1 < ../gd-2.0.1.patch.wez
# edit Makefile if desired - by default it installs into /usr/local
make install

Now continue with your PHP build in the normal manner. My relevant
PHP configure options are:

 --with-gd
 --with-jpeg-dir=/usr
 --with-png-dir=/usr
 --with-zlib-dir=/usr
 --with-freetype-dir=/usr
 --enable-gd-native-ttf
 --enable-gd-imgstrttf

If you don't have these libraries all installed under /usr, make
the appropriate changes to these directives.


And a quick test PHP script:

<?php
  Header("Content-type: image/png");
  $im = ImageCreate(400, 100);
  $black = ImageColorAllocate($im, 0, 0, 0);
  $white = ImageColorAllocate($im, 255, 255, 255);
  ImageFtText ($im, 20, 0, 10, 20, $white,
    "/usr/local/lib/ttf/Helve.ttf",
    "This is a test 1234",
    array());
  ImagePng($im);
  ImageDestroy($im);
?>

Note the array() as the last argument to ImageFtText(). It appears that
you can pass a multi-line string to ImageFtText, and the array may
contain an option to control line spacing. e.g.
ImageFtText ($im, 20, 0, 10, 20, $white,
  "/usr/local/lib/ttf/Helve.ttf",
  "This is a test\r\ntest\r\ntest\r\ntest\r\ntest\r\ntest",
  array("linespacing" => 0.5));
generates a block of text with half the normal line spacing.


Thanks to:
Wez Furlong for maintaining PHP's GD interface
Boutell.com for the GD library (even if updates are slow :)
Ernie Dipko for his help resolving this problem.

 ...Richard.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to