Page 1 of 1

imagefttext() frustrations

Posted: Thu Jan 22, 2004 9:23 pm
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.

Posted: Thu Jan 22, 2004 9:31 pm
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());

Posted: Thu Jan 22, 2004 11:29 pm
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.

Posted: Thu Jan 22, 2004 11:35 pm
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.