views:

54

answers:

0

I have problems with the "imagettftext" function. The following code works if I comment the problematic line (I see a yellow rectangle).

session_start();
$text = $_SESSION['code'];
header("Content-type: image/gif");
$image = imagecreate(150, 15);
$red_bg = 255; $green_bg = 255; $blue_bg = 155;
$bg_col = imagecolorallocate($image, $red_bg, $green_bg, $blue_bg);
$red_txt = 0; $green_txt = 0; $blue_txt = 0;
$text_col = imagecolorallocate($image, $red_txt, $green_txt, $blue_txt);
$font = "LucidaSansRegular.ttf";
$link_col = imagecolorallocate($image, 0, 0, 255);
//imagettftext($image, 10.0, 0.0, 5, 5, $text_col, $font, "aaaaa");
imagegif($image);

But if I uncomment the problematic line (to show some text) I get a problem. Mozilla writes me "The image cannot be displayed, because it contains errors".

May be this is related with the access to my font file (LucidaSansRegular.ttf). All files in my directory have "-rw-r--r--" (including the fond file).

Any suggestions? I need to add that on another server this code worked.