trouble with loading ttf to be used in GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gugubanana
Forum Newbie
Posts: 5
Joined: Sun Aug 24, 2008 10:41 am

trouble with loading ttf to be used in GD

Post by gugubanana »

elloo,

i'm using php4.3.10 and freebsd4.8-stable however i have troubles with loading ttf fonts in the right color. the php coding works fine with other OS such as "Debian linux", "mac OS" and dare i say "Windows." basically php coding generates an text image using GD and here is the code.

Code: Select all

 
<?php
// Set the content-type
header('Content-type: image/png');
 
// Create the image
$im = imagecreatetruecolor(400, 30);
 
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
 
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'fonts/arialblack.ttf';
 
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
 
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
 
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
 
any how the trouble is, it loads the font however it appears yellow?! i have tried to blame it on my coding however after trying the same coding under different OS, it make me wonder if it is an issue with freebsd4.8. any ideas are highly welcomed.

many thanks.
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: trouble with loading ttf to be used in GD

Post by pcoder »

May be it is because of the version of the GD library used.
I don't know have you gone through the manual or not.
Definitely it will solve your problem, if not then inform here.
http://www.php.net/manual/en/function.imagettftext.php
gugubanana
Forum Newbie
Posts: 5
Joined: Sun Aug 24, 2008 10:41 am

Re: trouble with loading ttf to be used in GD

Post by gugubanana »

yup!

i have tried looking at the manual, actually the sample code i've given here is from the imagettftext documentation. i'm using same GD (2.0.28) version on different operating system and it works fine however on freebsd4.8 text appears yellow.

i'm not an expert on unix however i know that in some unix have special command line to create font folders. i just wonder if freebsd has such commands?

thanks once more.
Post Reply