问题:使用GD库imagettftext()函数时,报“Warning: imagettftext(): Could not find/open font in ”警告 。
解决方案:找了很久,发现是GD库加载字体文件时,需求提供绝对路径,给font路径用realpath()将相对路径转成绝对路径即可。
imagettftext($im,mt_rand(12,14),mt_rand(-30,30),20*$i+10,18,$fontcolor,realpath($fontface),$codex);
imagettftext() 函数是 PHP 中的一个内置函数,用于使用 TrueType 字体将文本写入图像。
句法:
数组 imagettftext($image,float $size,float $angle,int $x,int $y,int $color,string $fontfile,string $text)
参数:此函数接受上述八个参数,如下所...