Home > Backend Development > PHP Tutorial > PHP绘制文字程序出错,求解,该怎么处理

PHP绘制文字程序出错,求解,该怎么处理

WBOY
Release: 2016-06-13 13:28:06
Original
942 people have browsed it

PHP绘制文字程序出错,求解
程序代码如下:
  $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=iconv("GB2312","UTF-8","PHP绘制文字程序"); //如果有中文输出,需要将其转码,转换为UTF-8的字符串才可以直接传递
$font='simsun.ttc';
imagettftext($im,20,0,12,21,$grey,$font,$text); //输出一个灰色的字符串作为阴影
imagettftext($im,20,0,10,20,$black,$font,$text); //在阴影之上输出一个黑色的字符串
header('Content-type:image/png');
imagepng($im);
imagedestroy($im);
?>
浏览器显示如下:

请教各位,这是哪里出了问题?

------解决方案--------------------
他不是明确的告诉你字体文件找不到吗?

$font='simsun.ttc';//这样写就得把 simsun.ttc 拷贝到当前目录下
测试时写作
$font = 'c:/windws/fonts/simsun.ttc';
就可以了
------解决方案--------------------
fonts 文件夹与其他文件夹不同,你看到的都是字体的名字和不是文件名,要查看属性才能看到
simsun.ttc 是 宋体&新宋体

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template