Jump to content

[SOLVED] Adding a font to my gd code please help cheers.


redarrow

Recommended Posts

hi there i got this gd code from php.net all works grate, But i wanted to add a font so i

downloadded a font and it's called font.ttf now i need to no how to add it to the

below code, each time i try i get a long funny error.

 

The font and picture are in the same folder as this code any advise please cheer.

 

Like i say without the font i can see the picture and the letters on top.

 

why dont this work!

 

<?php
header("Content-type: image/png");
$string="hell i am redarrow";
$im    = imagecreatefrompng("mat_picture.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
//font needs to be added.
//$font = imageloadfont("font.ttf");
// some were on this line the varable font needs adding.
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
?> 

 

 

solved.

 

Done it lol i read the phpfreaks totural grate stuff

 

<?php 
$im    = imagecreatefrompng("mat_picture.png");
$yellow = ImageColorAllocate ($im, 235, 235, 51);
$saying="hi there i am redarrow"; 
ImageTTFText ($im, 15, 1, 25, 70, $yellow, "/WINDOWS/Fonts/IMPACT.ttf", "$saying"); 
ImagePNG($im); 
?> 

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.