Array imagettftext (resource image, int size, int angle, int x, int y, int color, string fontfile, string text)
Imagettftext () draws the string text to the image, starting from the coordinates x, y (0, 0 in the upper left corner), angle, color, use the truetype font file specified by fontfile. Depending on the gd library used in the php Tutorial, if fontfile does not start with '/', '. Ttf' will be added to the file name and the library will be searched to define the font path.
*/
// Send the header file
Header ("content-type: image/png ");
// Create an image
$ Im = imagecreatetruecolor (400, 30 );
// Define the color
$ White = imagecolorallocate ($ im, 255,255,255 );
$ Gray = imagecolorallocate ($ im, 128,128,128 );
$ Black = imagecolorallocate ($ im, 0, 0 );
Imagefilledrectangle ($ im, 0, 0,399, 29, $ white );
// Define text
$ Text = 'Hello world! ';
// The path of the font file
$ Font = 'Arial. Ttf ';
// Add a shadow to the text to draw the text in gray.
Imagettftext ($ im, 20, 0, 13, 23, $ gray, $ font, $ text );
// Add text to draw the text in black
Imagettftext ($ im, 20, 0, 10, 20, $ black, $ font, $ text );
// Output png image
Imagepng ($ im );
Imagedestroy ($ im );
/*
This function requires both the gd Library and the freetype library.
*/