imagefttext() frustrations

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
wildfish
Forum Newbie
Posts: 4
Joined: Thu Jan 22, 2004 9:23 pm

imagefttext() frustrations

Post by wildfish »

I'd be a happy camper if I could just get these GD text functions to work, but so far they only produce, well, nothing. Here's what I'm working with:

Code: Select all

header("Content-type: image/png");
$im    = imagecreate(200,100);
$background_color = imagecolorallocate ($im, 100, 50, 25);
$white = imagecolorallocate($im, 255, 255, 255);
$fontfile = "arial.ttf";
imagefttext($im, 12, 0, 0, 0, $white, $fontfile,"Test string");
imagepng($im);
imagedestroy($im);
I have tried using the full file path and also omitting the .ttf extension. I have tried imagettftext() as well as imagefttext() and both of them return absolutely nothing, not even an error. I've determined that the functions are returning false but I have no idea why. This is running on an WinNT system, php 4.3.3, GD 2.015.

Any help would be GREATLY appreciated. Thanks.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The last option to imagetftext is not optional, despite what the docs imply ;)
So try :
imagefttext($im, 12, 0, 0, 0, $white, $fontfile,"Test string", array());
wildfish
Forum Newbie
Posts: 4
Joined: Thu Jan 22, 2004 9:23 pm

Post by wildfish »

thanks for your suggestion, but the function is still ineffective. all I know is that it's returning false, but I'm not getting an "unknown function" or "can't find file" error.
wildfish
Forum Newbie
Posts: 4
Joined: Thu Jan 22, 2004 9:23 pm

Post by wildfish »

Okay, I've got it solved, sort of. I specified the font path as my host's WINDOWS/fonts directory instead of my uploaded font, and that worked.
Thanks for the help.
Post Reply