Jump to content

[SOLVED] Help loading font and wrinting on image GD


elpaisa

Recommended Posts

Hi!

 

I'm creating a function that takes values from database and puts these on an image and saves it as a new one, for now as i don't have much experience in GD i am writing it as simple as possible, everithing works fine without loading a font but i need to use arial black to write on the image.

 

Here is the code: that works without loading the font:

 

 

function createimage()
{

Header("Content-Type: image/gif");


$font = 'ariblk.ttf';
$font_size = 2;
$string = 'ADDERALL';
$id = ImageCreateFromGif("images/pot.gif");
$black = ImageColorAllocate($id, 0, 0, 0);

//imagettftext($id, $font_size,  35, 76, $font, $string, $black);

ImageString($id, $font_size,  35, 76, $string, $black);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

 

And here is the one i am trying with, for using the font:

 

 

function createimage()
{

Header("Content-Type: image/gif");


$font = 'ariblk.ttf';
$font_size = 2;
$string = 'ADDERALL';
$id = ImageCreateFromGif("images/pot.gif");
$black = ImageColorAllocate($id, 0, 0, 0);

imagettftext($id, $font_size,  35, 76, $font, $string, $black);

//ImageString($id, $font_size,  35, 76, $string, $black);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

 

 

When do you actually load up the font.

 

gd supports two type of font files

GD fonts (use imageloadfont)

and PostScript Type 1 (use imagepsloadfont)

 

not shure about True Type fonts, but found this Difference between TTF and PSF

 

Well good luck :)

 

 

Well, afther no response for a long time i tried all the possible coding and i've solved it

Thanks!!

 

function createimage()
{

Header("Content-Type: image/gif");

$id = ImageCreateFromGif("images/pot.gif");
$string = 'ADDERALL';
$black = ImageColorAllocate($id, "#000000");

ImageTTFText($id, 7, 0, 30, 88, $black, "AEASWFTE.TTF", $string);
ImageTTFText($id, 7, 0, 31, 88, $black, "AEASWFTE.TTF", $string);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

Archived

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

×
×
  • 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.