Come da manuale:
text
The text string.
May include decimal numeric character references (of the form: €) to access characters in a font beyond position 127. The hexadecimal format (like ©
is supported as of PHP 5.2.0. Strings in UTF-8 encoding can be passed directly.
Codice PHP:
<?php
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreatetruecolor(600, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 799, 29, $white);
// The text to draw
$text = 'Sostanzialmente l’arciere mira a se stesso (Lo zen e l’arte del tiro con l’arco)';
$text = str_replace('’', '`', $text);
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 12, 0, 11, 21, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>