这个函数为什么写入汉字就乱码?如何解决?

解决方案 »

  1.   

    看看ImageString的手册就知道了,第二个参数只能用内置或imageloadfont()载入的gdf字体,中文是不支持的
      

  2.   

    要显示中文需要借助字体库,显示一般用GD库的imagettftext函数,实测参考代码:header ("Content-type: image/png");  
    $str="中文字体显示";  
    //$pic=imagecreatefrompng("background.png"); 
    $width=540;
    $height=340;
    $pic = imagecreatetruecolor($width,$height );
    $color=imagecolorallocate($pic,255,0,0);
    $back=imagecolorallocate($pic,0,0,0);
     imagettftext($pic,12, -90, 250, 150,$color,"C:/WINDOWS/Fonts/simhei.ttf",$str);  
     imagepng($pic);  
     imagedestroy($pic);
      

  3.   

    用imagettftext(),具体看手册