Ich möchte ein Bild mit etwas Text darauf generieren, scheint die LTR-Sprachen gut zu funktionieren, aber wenn es auf Arabisch versucht, es einfach nicht funktioniert siehe den Screenshot unten, wo ich zeichne 3 Text-Strings mit dem vorgestellten TextcodeSchreibe RTL (arabisch) Text zu Bild mit PHP
Hier ist mein Test-Code (mit Kommentaren):
// Create a 300*300 image
$im = imagecreate(300, 300);
// Yellow transparent background and blue text
$bg = imagecolorallocatealpha($im, 255, 255, 0, 45);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// Write an LTR string
imagestring($im, 5, 250, 100, 'test', $textcolor);
$font = 'DroidKufi-Regular.ttf'; // specify the fonts file
$text = "تجربة";
// Add the text
imagettftext($im, 10, 0, 10, 20, $textcolor, $font, $text);
// set a red text color
$textcolor = imagecolorallocate($im, 255, 0, 0);
// strrev doesn't seem to solve the problem
$text = strrev($text);
// add the text
imagettftext($im, 10, 0, 30, 250, $textcolor, $font, $text);
imagefilledrectangle ($im, 0, 0, 1, 1, $bg);
// Output the image
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
Sie haben die [Lösung hier] versucht, verwenden (http://www.php.net //manual/en/function.imagetttext.php#91028) nehme ich an? Oder [vielleicht dieser?] (Http://stackoverflow.com/questions/2444015/right-align-text-in-a-image-with-imagetttext-php) .. vielleicht hast du es nicht, vielleicht hast du es nur versucht [dieser?] (http://forums.phpfreaks.com/topic/44370-solved-make-text-string-read-from-right-to-left-in-imagettftext-function/) – Ohgodwhy
Ja, Sie haben Recht , aber ich denke nicht, dass dieser http://stackoverflow.com/questions/2444015/right-align-text-in-an-image-with-imagetttext-php mir helfen wird, aber ich werde es versuchen Danke für die schnelle Antwort :) –
Eigentlich zeigt diese Lösung nicht in der Nähe meines Problems –