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.

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.