Jump to content

Recommended Posts

Ok with this simple code:

<?php
     header ("Content-type: image/png");
   
     $im = ImageCreate (300, 40);
     $grey = ImageColorAllocate ($im, 230, 230, 230);
     $black = ImageColorAllocate ($im, 0, 0, 0);
   
     ImageTTFText($im, 20, 0, 10, 25, $black, "arial.ttf", "TrueType Fonts!");
     ImagePng ($im);
     ImageDestroy ($im);
?>

 

It just gives me a non-exsistent image.

 

I am using xampp. Should I load the font first? In which directory?

Try putting the ttf file in the same folder as the script. You may need to use a better reference to the font, like ./arial.ttf

 

 

HTH

Teamatomic

 

Thanks! Exactly what I needed!

 

If the font is not within GD's predefined library path, it will attempt to search for that filename along a library-defined font path.

 

Note the following example:

// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font = 'SomeFont';

 

Otherwise you can do as intended and point the font to the relative path.

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.