PHP3 Manual
PrevNext

ImageTTFText

ImageTTFText -- write text to the image using a TrueType fonts

Description

int imagettftext(int im, int size, int angle, int x, int y, int col, string fontfile, string text);

ImageTTFText draws the string text in the image identified by im, starting at coordinates x,y (top left is 0,0), at an angle of angle in color col, using the TrueType font file identified by fontfile.

The coordinates given by x,y will define the basepoint of the first character (roughly the bottom-left corner of the character). This is different from the ImageString(), where x,y define the upper-right corner of the first character.

angle is in degrees, with 0 degrees being left-to-right reading text (3 o'clock direction), and higher values representing a counter-clockwise rotation. (i.e., a value of 90 would result in bottom-to-top reading text).

fontfile is the path to the TrueType font you wish to use.

This example script will produce a black GIF 400x30 pixels, with the words "Testing..." in white in the font Arial.

Example 1. ImageTTFText

<?php
Header("Content-type: image/gif");
$im = imagecreate(400,30);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageTTFText($im, 20, 0, 10, 20, $white, "/path/arial.ttf", "Testing...");
ImageGif($im);
ImageDestroy($im);
?>

This function requires both the GD library and the Freetype library.


PrevHomeNext
ImageSYUpImageColorAt