| Question : | I am trying to install GD + Truetype with PHP4, but all I get is libgd was not built with TrueType font support | |
| | Answer : | *Note*
This answer may or may not help you. This is the way we got it to work, maybe it will help you. If it does please contact altphp@php4hosting.com so we know and can help others.
--
GD 1.x
-------
We had this trouble when trying to install the following combination.
PHP-4.2.3,gd-1.8.4 + freetype-2.1.3
Firstly freetype-2.1.3
wget http://telia.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.3.tar.gz
tar -pxzf freetype-2.1.3.tar.gz
cd freetype-2.1.3
make setup
make
make install
cd ..
Then GD
wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
tar -pxzf gd-1.8.4.tar.gz
cd gd-1.8.4
Then edited Makefile
Found the line that had the following
CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG
And replaced with
CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG -DHAVE_LIBFREETYPE
Then found the line
LIBS=-lgd -lpng -lz -lm
and replaced with
LIBS=-lgd -lpng -lz -ljpeg -lfreetype -lm
Then found the line
INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include
and replaced with
INCLUDEDIRS=-I. -I/usr/local/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include
This last line needed edited as freetype-config showed the include libraries were not in /usr/include/freetype2 but in /usr/local/include/freetype2 Yours may vary
To find our your freetype library include paths use the following :-
freetype-config --cflags
Ours gave :-
-I/usr/local/include/freetype2
Then run
make
make install
Now time to install PHP, we used the following configure options :-
./configure --prefix=/usr/local/apache/php --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --enable-track-vars --enable-bcmath --enable-ftp --with-gd --enable-gd-native-tt --with-freetype-dir --with-imap --with-png-dir --with-jpeg-dir --with-dom=/usr/local --with-zlib-dir --enable-trans-sid --with-mcrypt=/usr/local --with-mhash=/usr/ --with-curl --with-openssl=/usr/local/ssl --with-apxs=/usr/local/apache/bin/apxs
make
make install
Restart apache and try the following test script
The initial install seemed to go well and the PHPInfo paged showed :-
FreeType Support enabled
FreeType Linkage with freetype
But when trying to use the following code :-
<?php
//Header ("Content-type: image/jpeg");
$im = imagecreate (400, 30);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, 20, 0, 10, 20, $white, "/home/user/web/arial.ttf",
"Testing... Omega: Ù");
ImageJpeg ($im);
ImageDestroy ($im);
?>
It gave the error :-
Warning: libgd was not built with TrueType font support in /home/admin/web/font.php on line 7
The arial.ttf font was taken from a windows install and uploaded as binary. We had edited the GD Makefile for jpeg and Truetype support and PHP had said it was available in the initial configure and the phpinfo page.
After some reading of many sites it was found that GD-1.8.x does not support TrueType version 2.
So we tried again using GD-2.0.1, the same error!
Finally we did a fresh install of GD-1.8.4 to see what files were created (They are listed after a make install)
So we removed them using the following :-
rm /usr/local/lib/libgd.a
rm /usr/local/bin/pngtogd
rm /usr/local/bin/pngtogd2
rm /usr/local/bin/gdtopng
rm /usr/local/bin/gd2topng
rm /usr/local/bin/gd2copypal
rm /usr/local/bin/gdparttopng
rm /usr/local/bin/webpng
rm /usr/local/bin/bdftogd
rm /usr/local/include/gd.h
rm /usr/local/include/gdcache.h
rm /usr/local/include/gd_io.h
rm /usr/local/include/gdfontg.h
rm /usr/local/include/gdfontl.h
rm /usr/local/include/gdfontmb.h
rm /usr/local/include/gdfonts.h
rm /usr/local/include/gdfontt.h
Then went back to try an install of GD-2.0.8.
wget http://www.boutell.com/gd/http/gd-2.0.8.tar.gz
tar -pxzf gd-2.0.28.tar.gz
cd gd-2.0.28
./configure
make
make install
cd ..
ldconfig
Now time to install PHP.
* NOTE *
Then we used the following configure options :-
wget http://www.php.net/distributions/php-4.2.3.tar.gz
tar -pxzf php-4.2.3.tar.gz
cd php-4.2.3
./configure --prefix=/usr/local/apache/php --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --enable-track-vars --enable-bcmath --enable-ftp --with-gd --enable-gd-native-tt --with-freetype-dir --with-imap --with-png-dir --with-jpeg-dir --with-dom=/usr/local --with-zlib-dir --enable-trans-sid --with-mcrypt=/usr/local --with-mhash=/usr/ --with-curl --with-openssl=/usr/local/ssl --with-apxs=/usr/local/apache/bin/apxs
The important ones being :-
--with-gd --enable-gd-native-tt --with-freetype-dir
Then
make
make install
Restart apache and our test php script worked!
If you have build problems with php or apache you might try and do a make clean on both directories to get it to compile properly.
Hope that helps someone.
This has helped many people that we know of plus has been installed on our servers and works without fail!
Good luck!
| | |