Imagettftext
(PHP3, PHP4)
Imagettftext---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Write text to graphics using TrueType fonts
Syntax: array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)
Description:
Imagettftext () uses the TrueType font file Fontfile, in the graphics IM, in the coordinates x,y position, the angle is angle, draws the color col the string text.
The coordinate x,y will be defined as the datum point of the first character, unlike imagestring (), imagestring () is the upper-right corner defined as the first character.
Angle units are degrees, 0 degrees will read text from left to right (3 o'clock), while higher values indicate reverse clock rotation (for example: 90 degrees will result in text being read from bottom to top).
Fontfile is the path you want to use the TrueType font.
Text is a literal string that can contain UTF-8 contiguous characters (& #123的形式) to access characters other than the first 255 characters in the font.
Col is a color index, and using a negative color index closes antialiasing.
Imagettftext () returns an array of 8 elements, representing the four vertices of the text block, the order of the vertices is upper left, right, bottom right, bottom left, and vertices are relative to the text, so regardless of the angle. "Upper left" means that when you look at the upper-left corner of the text in a horizontal direction.
This example will produce a black gif 400x30 pixel graphic, and the white word "testing ..." font Arial.
Example:
<?php
Header ("Content-type:image/gif");
$im = Imagecreate (400, 30);
$black = imagecolorallocate ($im, 0, 0, 0);
$white = Imagecolorallocate ($im, 255, 255, 255);
Imagettftext ($im, 0, $white, "/path/arial.ttf", "Testing ... Omega: & #937; ");
Imagegif ($im); Imagedestroy ($im);
?>
This function requires the GD library and the FreeType library.
Reference: Imagettfbbox ()