1
我尝试在图片添加文字:和imagestring垃圾文本问题
$newImg = imagecreatetruecolor($dst_width, $dst_height);
imagealphablending($newImg, false);
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $dst_width, $dst_height, $width, $height);
imagesavealpha($newImg, true);
if(!empty($name)){
$fontSrc = './fonts/DejaVuSans.ttf';//support utf8 and unicode
$font = imageloadfont($fontSrc);
//Couleur des noms
$bg = imagecolorallocatealpha($newImg, 0, 0, 0, 0);
$textcolor = imagecolorallocatealpha($newImg, 255, 255, 255, 1);
//Deplacer les noms
imagestring($newImg, $font, 0, $dst_height - 17, 'שדגשדג', $textcolor);
}
已经尝试过:
header('Content-Type: text/html; charset=utf-8');
imagestring($newImg, 500, 0, $dst_height - 17, utf8_encode('שדגשדגש'), $textcolor);
的问题是,当我在希伯来文(UTF8)把文本:שדגשד
其显示文本图片上的那样:
正如你可以看到它的类型垃圾文本,修复它的正确方法是什么?
我的第一个猜测是用过的字体不支持unicode。 – Eiko
也试过,我现在编辑。 – Roasls