php – 如何在图像中写入阿拉伯语或波斯语等非英语字符?

如何使用PHP GD库将阿拉伯语或波斯语字符写入图像?

即“احسان”

解决方法:

使用此函数将文本传递给imagettftext

<?php
function revUni($text) {

    $wordsArray = explode(" ", $text);

    $rtlCompleteText='';
    for ($i = sizeOf($wordsArray); $i > -1; $i = $i-1) {

        //$lettersArray = explode("|", str_replace(";|", ";", $wordsArray[$i]));
        $lettersArray = explode(";", $wordsArray[$i]);

        $rtlWord='';
        for ($k = sizeOf($lettersArray); $k > -1; $k = $k-1) {
            if (strlen($lettersArray[$k]) > 1) { // make sure its full unicode letter
                $rtlWord = $rtlWord."".$lettersArray[$k].";";
            }
        }

        $rtlCompleteText = $rtlCompleteText." ".$rtlWord;

    }

    return $rtlCompleteText;
}
?>
上一篇:jpg文件上的php gd image png watermark会产生奇怪的结果


下一篇:php – 用于缩略图创建的函数imagecopyresampled()或imagecopyresized()?