PHP imagettftext()

webquarry

Verified User
Joined
Mar 19, 2004
Messages
182
Just an FYI:

If you have any users complaining about not being able to use the imagettftext() function in PHP, as indicated by the following error message:

Fatal error: Call to undefined function imagettftext()

The solution (for me anyways) was to make sure that freetype-devel was installed and then to add:

--enable-gd-native-ttf
--with-ttf
--with-freetype-dir=/usr

to the configure.php file and then do a

./build php
service httpd restart

I burned a few hours trying to fix that today. Just thought I'd someone else the trouble. ;)
 
Last edited:
Well that is a step-by-step for building php. The key is to make sure that you have the development libraries for freetype installed before you config and build php.

If you are using a redhat distro (RHEL, FCx, etc) they have freetype and freetype-devel rpms. Just install them and any needed deps and you should be fine.

If you are building freetype by hand (make; make install) make sure that the install step in the Makefile also installs the libs. Some programs are set up so that a make install only installs the binaries and not the stuff that you need if you are going to be linking other programs (like php) to it. In that case they have another make command that you use to install the libs. Read the freetype documentation to find out what it is. Sorry but I use redhat so I didn't have to mess around with it at the make level...
 
Thanks. I do have freetype-devel installed (running fedora core 2) I've also installed freetype-2.1.10, but I'm getting the following when compiling (getting really frustrating) LOL

/usr/local/directadmin/customapache/configure.php: line 27: --enable-gd-native-ttf: command not found
/usr/local/directadmin/customapache/configure.php: line 28: --with-ttf: command not found
/usr/local/directadmin/customapache/configure.php: line 29: --with-freetype-dir=/usr: No such file or directory
 
Did you forget the back-slashes in configure.php? (\)

Look at the lines above it. All but he very last line should have a \ at the end.
 
webquarry said:
Just an FYI:

If you have any users complaining about not being able to use the imagettftext() function in PHP, as indicated by the following error message:

Fatal error: Call to undefined function imagettftext()

The solution (for me anyways) was to make sure that freetype-devel was installed and then to add:

--enable-gd-native-ttf
--with-ttf
--with-freetype-dir=/usr

to the configure.php file and then do a

./build php
service httpd restart

I burned a few hours trying to fix that today. Just thought I'd someone else the trouble. ;)

I upgrade apache, upgrade many things but this is the only thing I needed :(

On the side note, the above didnt work, so i did it with absolute paths:

--enable-gd-native-ttf
--with-ttf= /usr/include/freetype1
--with-freetype-dir=/usr/include/freetype2

Which you dont have to do both, onlt ttf or freetype, I did both since I have free typ 1 & 2 installed.

But I still get the error :(:

Fatal error: Call to undefined function: imagettftext()

I also tried restarting the server!

Peace,
 
GXX said:
Here you go, this should get everything set up for you.

Tested on FC1 and CentOS3, should work for most of RH flavors.

Compile Freetype2 from source.

Code:
cd /usr/local/directadmin/customapache/
wget [url]http://savannah.nongnu.org/download/freetype/freetype-2.1.10.tar.gz[/url]
tar zxf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure
make
make install

My Freetype libs are located in /usr/local/lib, check your system and see where it is (ex: /usr/lib).

Open the 'build' file in the DA scripts directory and search for doGD

In the configure line, change --without-freetype to:

Code:
--with-freetype=/usr/local/lib

Open up 'configure.php' in the DA scripts directory and add:

Code:
	--with-freetype \
	--with-freetype-dir=/usr/local/lib \

Make sure to include the trailing \. Note my directory where my Freetype libs are, change yours accordingly if needed.

then do:

Code:
./build clean
./build php

Answer 'y' when asked if you want to compile GD again.

Then restart HTTPD. Open up a phpinfo file and you'll see Freetype support listed now.

worked..... great!!:D :D :D :D :D :D :D

Thanks a bunch,

Peace,
 
./build won't start

Thanks a lot but when i want to do
./build clean
I ve got an error
./build: bad interpreter: No such file or directory
But the file is in the directory
 
Back
Top