Jump to content

imageloadfont() function to load specific ttf file


seco

Recommended Posts

Hi

i ahave a ttf file and i want to use it in writting a text on the image

and in the php hlp i see the function imageloadfont() and how it used and i write the following

 

<?php
// create a 100*30 image
$im = imagecreate(100, 30);

// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// here i load a font file on the same directory of the script called myfont.ttf
$font = imageloadfont("myfont.ttf");
imagestring($im, $font, 0, 0, "sometext", $textcolor);

// output the image
header("Content-type: image/png");
imagepng($im);
?> 

 

it gives me error message says:- The image “http://localhost/z.php” cannot be displayed, because it contains errors.

 

any idea?

 

thanks in advance.

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.