Jump to content


Photo

Using imagettftext


  • Please log in to reply
1 reply to this topic

#1 jsvoyager

jsvoyager
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 May 2006 - 09:24 PM

I've got a really strange problem here.

I'm using the imagettftext function and I can't get it to seem to work correctly. It is able to process the image, however it dosen't out any text on. This is on my development computer. On the production computer, I put the same script and it works perfectly, putting the text down where it should be in the correct color. The only color of text that I've goten to work on my development computer is black, but it does not display black text but a kind of yellow text. Very odd.

Thanks in advance for any help.

Here's the code (it is making two image buttons, one for normal and one for mouse over, at the same time)
function make_button($title, $id){
    putenv('GDFONTPATH=' . realpath('.'));
    //SOME GLOBALS THAT MIGHT NEED TO BE CHANGED LATER ON DOWN THE ROAD
    error_reporting(E_ALL);
    $norm_path = "../img/buttons/template.png";
    $over_path = "../img/buttons/template_over.png";
    $x = 3;
    $y = 23;
    $font = 'font.ttf';
    
    
    $norm = imagecreatefrompng($norm_path);
    $over = imagecreatefrompng($over_path);
    
    $font_color = imagecolorallocate ($norm, 115, 16, 0);
    $font_over_color = imagecolorallocate ($over, 115, 16, 0);
    
    $data = imagettftext ($norm, 18, 0, $x, $y, $font_color, $font, $title);
    //Make sure the rectange of the font did not excede the length of the image
    if ($data[5] > imagesx($norm)){
        return false;
    }
    $data = imagettftext ($over, 18, 0, $x, $y, $font_over_color, $font, $title);
    
    //Save images as png
    imagepng($norm, "../img/buttons/$id.png");
    imagepng($over, "../img/buttons/{$id}_over.png");
        
    //Destroy images
    imagedestroy($norm);    
    imagedestroy($over);
    return true;
}


#2 jsvoyager

jsvoyager
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 07 May 2006 - 12:57 AM

Found out my issue myself. Old version of FreeType. Recompiled witha --with-freetype and a --without-ttf.

Bug report I found: [a href=\"http://bugs.php.net/bug.php?id=27693\" target=\"_blank\"]http://bugs.php.net/bug.php?id=27693[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users