<?phpAlthough most of our code has stayed the same you will notice we are now using ImageTTFText () instead of ImageString (). This allows us to choose our font, which must be in TTF format.
header ("Content-type: image/png");
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
$txt_color = ImageColorAllocate ($handle, 0, 0, 0);
ImageTTFText ($handle, 20, 15, 30, 40, $txt_color, "/Fonts/Quel.ttf", "Quel");
ImagePng ($handle);
?>
The first parameter is our handle, then font size, rotation, starting X, starting Y, text color, font, and finally our text. For the font parameter, you need to include the path to font file. For our example I have placed the font Quel in a folder called Fonts. As you can see from our example, we have also set the text to print at a 15 degree angle.
If your text isn't showing, you may have the path to your font wrong. Another possibility is that your Rotation, X and Y parameters are placing the text outside of the viewable area.

