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);
?> 

Link to comment
Share on other sites

 

 

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); 
?> 

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.