Definition
Write ttf text to the graph.
Syntax:
Array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text );
Return Value:
Array
Function types:
Graphic Processing
Description of the imagettftext function of PHP:
This function writes ttf (truetype fonts) text to an image. The parameter size is the font size. angle is the angle of the font, which is calculated clockwise. 0 degrees is horizontal, that is, the direction of three o'clock (from left to right ), 90 degrees indicates the bottom-up text. The x and y parameters are the coordinate values of the text (the origin is the upper left corner );
The col parameter indicates the color of the word. fontfile indicates the name of the fontfile, which is also a remote file. text is of course the string content. The return value is an array consisting of eight elements. The first two are the lower-left x and y coordinates, and the third and fourth are the lower-right x and y coordinates, the fifth, sixth, seventh, and eighth groups are the upper right and upper left x and y coordinates respectively. Using this function, the system needs to install the gd and freetype libraries.
Example of using the PHP function imagettftext
In this example, a 400x30 pixel black base map is created and I am number one is written in the arial vector font !! .
- < ?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, "/somewhere/arial.ttf",
"i am number one !!");
- imagegif($im);
- imagedestroy($im);
- ?>