php imagettftext和阿拉伯语编码

php imagettftext和阿拉伯语编码,php,image,imagettftext,Php,Image,Imagettftext,我用这个代码在图像上写文字,但用阿拉伯语,问题是字母是从左到右写的。我使用这个代码 header('Content-Type: image/png'); $im = imagecreatetruecolor(400, 30); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0,

我用这个代码在图像上写文字,但用阿拉伯语,问题是字母是从左到右写的。我使用这个代码

header('Content-Type: image/png');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$text = 'نص عربي';
$text = mb_convert_encoding($text, 'HTML-ENTITIES',"UTF-8");
$text = html_entity_decode($text,ENT_NOQUOTES, "ISO-8859-1");
$font =  'arial.ttf';
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
结果是这张图片上的字母从左向右书写,无法阅读,因此如何设置正确的编码以在图片上打印阿拉伯文本


我在Github上看到了这个PHP库:

它似乎支持RTL文本,所以您可以尝试一下


我在Github上看到了这个PHP库:

它似乎支持RTL文本,所以您可以尝试一下


gd甚至支持rtl语言吗?您是否需要只写一个单词(或者最多只写一行),如示例图所示?如果是这样,我会说,在将其传递给imagettftext之前,请尝试还原字母的顺序……gd是否支持rtl语言?是否只需要编写一个单词(或最多一行),如示例图像所示?如果是这样,我会说,在将其传递给imagettftext之前,请尝试恢复字母的顺序…