Jump to content

Using imagettftext


jsvoyager

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.