Salve.
Sto cercando, senza riuscirci, di utilizzare correttamente la funzione imagettftext.
Vorrei poter passare come stringa di testo una stringa che, ad esempio, contenga anche apostrofi.
Tuttavia, non riesco a fargliela prendere. O la stringa viene troncata, o gli apostrofi vengono sostituiti da \', o ancora da %92...
Come posso fare per fargli prendere normalmente gli apostrofi?
Questo è quello che ho scritto nella pagina da cui viene presa la stringa:
Codice PHP:
$text = "That's it";
$text = str_replace("'","‘",$text);
print "<img src='font.php?text=" . $text . "'";
mentre questa è la pagina che elabora l'immagine:
Codice PHP:
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreate(350, 45);
// Create some colors
$white = imagecolorallocate($im, 244, 247, 232);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
// The text to draw
$text = $_GET['text'];
// Replace path by your own font path
$font = 'accid.ttf';
// Add the text
imagettftext($im, 20, 0, 0, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
Grazie mille in anticipo.