Jump to content

Archived

This topic is now archived and is closed to further replies.

jsvoyager

Using imagettftext

Recommended Posts

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)
[code]
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;
}
[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.