GD with FreeType 2.x

1) Permissions are 777
2) Yes, the fonts are in place
3) Yes, as you can see in the php_info link.

I've been searching for 2 days now, but I can't find the solution to this problem.

Maybe you coudl try building it again..
Code:
cd /usr/local/directadmin/customapache
./build clean
./build php n

Once built: service httpd restart
 
Maybe you coudl try building it again..
Code:
cd /usr/local/directadmin/customapache
./build clean
./build php n

Once built: service httpd restart

I rebuilded gd and php for over 10 times, also with different configure options. But everytime the same, it wont display TTF fonts. Its really very strange.
 
1) Permissions are 777
2) Yes, the fonts are in place
3) Yes, as you can see in the php_info link.

I've been searching for 2 days now, but I can't find the solution to this problem.

One more.. ;)

Check again and make sure the following is in your php config file.. : /usr/local/directadmin/customapache/configure.php

Code:
      --with-gd \
        --with-gd-dir=/usr/local \
 [b][color=red]     --with-freetype \
        --with-freetype-dir=/usr/lib \[/color][/b]
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        ..
        ..
[b][color=red]       --enable-gd-native-ttf[/color][/b]
That's about all my level of intelligence can help you with.. Sorry.. :confused:
 
Hi,

If possible post the code for the part of the script that is responsible for writing the string into the image. Look for the imagettftext function.

All I can think of is a if you say gd and freetype are all setup correct:

a) You have a @ before the function thereby hiding the error message from being output if any

b) the text colour is the same as the background.
 
Thanks for the suggenstions!

Tried recompiling one more time, but with the exact same result.

Check this is clearly not a color problem.

Only thing I can think of is that the path to the freetype libs in the configure script is incorrect. What file(s) should I look for?

./configure \
--with-apxs \
--with-curl \
--with-snmp=shared,/usr/include/net-snmp \
--with-curl-dir=/usr/local/lib \
--with-gd \
--with-gd-dir=/usr/local \
--with-freetype \
--with-freetype-dir=/usr/include \
--enable-gd-native-ttf \


ls /usr/include/freetype*

/usr/include/freetype:
freetype.h ftnameid.h ftxerr18.h ftxgdef.h ftxgsub.h ftxopen.h ftxsbit.h
fterrid.h ftxcmap.h ftxgasp.h ftxgpos.h ftxkern.h ftxpost.h ftxwidth.h

/usr/include/freetype2:
freetype
 
But that doesn't explain why PHP isn't outputting any error message like it should do if there was a problem with the freetype library or not finding the font.

To test if it's your php script search google for a premade image verification script and test that out.

If that works then you know it's your PHP coding at fault.

Grant
 
http://bnext.nl/test.php

Code:
<?php

function test ($string, $test)
{
    echo $string . '... ';

    if ($test)
        echo "success.\n";
    else
        echo "fail.\n";
}

$token = "Testing GD!";

// Create image

$pic = ImageCreate (300, 300); 

test ('Creating image', $pic);

$col2 = ImageColorAllocate ($pic, 0, 0, 100); 
$col1 = ImageColorAllocate ($pic, 200, 200, 200); 

// Test PNG/JPG functionality

ob_start();
$res1 = @ImagePNG ($pic);
$res2 = @ImageJPEG ($pic);
ob_clean();

test ('Testing PNG output', $res1);
test ('Testing JPEG output', $res2);

// Test TrueType functionality

$ttfont = trim (`locate -n 1 .ttf`);

test ('Testing FreeType', @ImageTTFText 
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token));
test ('Testing FreeType2', @ImageFTText 
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token, array()));

// Test Type1 functionality

$font = @ImagePsLoadFont (trim (`locate -n 1 .pfb`));

if ($font)
    $res = @ImagePsText ($pic, $token, $font, 10, $col1, $col2, 0, 0);

test ('Testing the Type1 library', ($font && $res));

test ('Destroying image', ImageDestroy($pic)); 

?>
 
http://bnext.nl/test2.php (image = displayed, but no fonts).

Code:
<?php 
// het random nr. aanmaken en gecodeerd opslaan in php sessie 

session_start();
$randomnr = rand(1000, 9999); 
$_SESSION['randomnr2'] = md5($randomnr);
// captcha plaatje met nummer maken - afmetingen kun je aanpassen gebruikte font
$im = imagecreatetruecolor(100, 38);
// Kleurenbepaling
$white = imagecolorallocate($im, 255, 255, 255); 
$grey = imagecolorallocate($im, 128, 128, 128); 
$black = imagecolorallocate($im, 0, 0, 0);
// zwarte rechthoek tekenen - afmetingen kun je aanpassen aan verschillende fonts
imagefilledrectangle($im, 0, 0, 200, 35, $black);
// hier - font.ttf' vervangen met de locatie van je eigen font bestand
$font = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
// schaduw toevoegen
imagettftext($im, 35, 0, 22, 24, $grey, $font, $randomnr);
// randomnr. toevoegen
imagettftext($im, 35, 0, 15, 26, $white, $font, $randomnr);
// voorkomen dat afbeelding ge-cached wordt
header("Expires: Wed, 1 Jan 1997 00:00:00 GMT"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache");
// plaatje verzenden naar browser
header ("Content-type: image/gif"); 
imagegif($im); 
imagedestroy($im); 
?>
 
Ok well your code works fine.

If you are running a redhat based OS then what is the output of

Code:
rpm -qa | grep freetype

Grant
 
Im using Ubuntu 6.06 LTS and have installed the needed freetype packages.

But I just noticed that the needed freetype libs are in /usr/local/lib, so recompiling one more time! :)
 
Ok, this is really weird.

On SMF the fonts are now showing, but the test script gives me:

Fatal error: Call to undefined function: imagettftext()

while the php_info (http://bnext.nl/info.php) shows that ttf support is enabled?
 
Use

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

and remove

Code:
--with-freetype \
--enable-gd-native-ttf \

and recompile.

My complete configure.php is

Code:
#!/bin/sh
./configure \
        --with-apxs2 \
        --with-curl \
        --with-curl-dir=/usr/local/lib \
        --with-gd \
        --with-gd-dir=/usr/local/lib \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mcrypt \
        --with-mhash \
        --with-mysql=/usr \
        --with-mysqli=/usr/bin/mysql_config \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-xml \
        --with-zlib \
        --with-zlib-dir=/usr/local/lib \
        --with-zip \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-magic-quotes \
        --enable-sockets \
        --enable-track-vars \
        --enable-mbstring \
        --enable-memory-limit \
        --with-freetype-dir=/usr/local

and that's for php5 and apache2 taken from the new custombuild.

Grant
 
OMG!

I just realize that I need to modify the configure.php_ap2 and not configure.php!!

I feel so stupid, but thanks for all help!!!

Edit: Everything works perfect now, can't believe i've modifing the wrong configure file for 2 days :o
 
Last edited:
Here's my complete config:
Code:
./configure \
        --with-apxs \
        --with-curl \
        --with-curl-dir=/usr/local/lib \
        --with-gd \
        --with-gd-dir=/usr/local \
        --with-freetype \
        --with-freetype-dir=/usr/lib \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-kerberos \
        --with-mcrypt \
        --with-mhash \
        --with-mysql=/usr \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-xml \
        --with-zlib \
        --with-zlib-dir=/usr/local/lib \
        --with-zip \
        --with-openssl \
        --with-imap=/usr/local/imap-2004c1 \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-magic-quotes \
        --enable-sockets \
        --enable-track-vars \
        --enable-mbstring \
        --enable-memory-limit \
        --enable-gd-native-ttf
 
I've had, like most of you, some trouble with enabling freetype in gd.
But finally after some time found the solution.

first install freetype2.**

Code:
cd /usr/local/directadmin/customapache/
wget [url]http://ovh.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.9.tar.gz[/url]
tar zxf freetype-2.1.9.tar.gz
cd freetype-2.1.9
./configure
make
make install

next part (2)
open /usr/local/directadmin/customapache/configure.php
and make sure the following lines are in there, if not add them.

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

next part (3)

in the /usr/local/directadmin/customapache/ directory
type in:

Code:
./build clean
./build gd
./build php

with these line you recompile gd & php ( with the ./build php, be sure to type Y when prompted for installing GD )

finally restart apache with.
Code:
service httpd restart


After this freetype worked finally worked for me.



You are the best my friend..I give you big hug..Thanks a lot...

regards...


Ugur Onur
 
my server is broke thanks to this
Kanary, if you'd like help you'll have to be a bit more specific.

Please tell us your server OS/distribution and version, and also your DirectAdmin version number.

Thanks.

Jeff
 
CentOS 4.4 and DA 1.29.7
Although I have tried it with many versions of DA, all to no avail.
----

Every day I find more and more software that REQUIRES GD with Freetype support - software that can not be run on my DirectAdmin server. I have lost customers due to this problem.

I have tried just about every suggestion here in the forums with recompiling this and that with no joy.

When can we expect a solution to this problem from the support folks?

This is well past being a joke.
 
Last edited:
tar zxf freetype-2.1.9.tar.gz

I get errors when trying to un tar this download. I have downloaded it 6 times already. the error is always the same (yes, I did delete the old file between downloads).

The error is always the same:

Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: Error exit delayed from previous errors

Any other suggestions?

This machine is a fairly recent clean CentOS 4.4 install with only DA installed, no custom mods.
 
try this link

Code:
wget http://dfn.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.9.tar.gz
 
Back
Top