imagettftext
Write text to the image using TrueType fonts.
imagettftext Function synopsis
imagettftext(
GdImage $image,
float $size,
float $angle,
int $x,
int $y,
int $color,
string $font_filename,
string $text,
array $options = []
): array|false
Parameters
$image
TypeGdImage
$size
Typefloat
The font size in points.
$angle
Typefloat
The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.
$x
Typeint
The coordinates given by $x and
$y will define the basepoint of the first
character (roughly the lower-left corner of the character). This
is different from the imagestring, where
$x and $y define the
upper-left corner of the first character. For example, "top left"
is 0, 0.
$y
Typeint
The y-ordinate. This sets the position of the fonts baseline, not the very bottom of the character.
$color
Typeint
The color index. Using the negative of a color index has the effect of
turning off antialiasing. See imagecolorallocate.
$font_filename
Typestring
$text
Typestring
The text string in UTF-8 encoding.
$options
OptionalTypearrayDefault value[]
An array with linespacing key holding a float value.
Return value
Typearray|false
Returns an array with 8 elements representing four points making the
bounding box of the text. The order of the points is lower left, lower
right, upper right, upper left. The points are relative to the text
regardless of the angle, so "upper left" means in the top left-hand
corner when you see the text horizontally.
Returns false on error.
Changes to the imagettftext Function
PHP 8.0
- Return type added:
array|false - Optional parameter added - #9:
array $options = []
imagettftext(
- $im,
- $size,
- $angle,
- $x,
- $y,
- $col,
- $font_file,
- $text
- )
+ GdImage $image,
+ float $size,
+ float $angle,
+ int $x,
+ int $y,
+ int $color,
+ string $font_filename,
+ string $text,
+ array $options = []
+ ): array|false imagettftext Function Availability
imagettftext Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |