8&&($height_text>$height_image_wo_margins||
$width_text>$width_image_wo_margins)
);
if($height_text>$height_image_wo_margins||
$width_text>$width_image_wo_margins)
{
//no readable font size will fit on button
echo 'text given will not fit on button.
';
}
else
{
//we have found a font size that will fit
//now work out where to put it
$text_x=$width_image/2.0-$width_text/2/0;
$text_y=$height_image/2.0-$height_text/2.0;
if($left_text $text_x+=abs($left_text);
$above_line_text=abs($bbox[7]);
$text_y+=$above_line_text;
$text_y-=2;
$white=imagecolorallocate($im,255,255,255);
imagettftext($im,$font_size,0,$text_x,$text_y,$white,$fontname,
$button_text);
header('content-type:image/png');
imagepng($im);
}
imagedestroy($im);
?>
warning: imagettfbbox() [function.imagettfbbox]: invalid font filename in e:\appserv\www\make_button.php on line 38
回复讨论(解决方案) 没有那个字体 换一个字体或把字体文件拷到相对应的目录
在c盘路径下 有arial字体文件啊。
我把putenv('gdfontfath=c:\windows\fonts');
改成putenv('gdfontfath=c:\windows\fonts');
报错为:warning: imagettfbbox() [function.imagettfbbox]: could not find/open font in e:\appserv\www\make_button.php on line 38
但是在文件夹中的确有arial字体文件
请大侠帮助!~~~
不好意思
报错一直为 warning: imagettfbbox() [function.imagettfbbox]: invalid font filename in e:\appserv\www\make_button.php on line 38
是字体变量的问题。把
putenv('gdfontfath=c:\windows\fonts');
$fontname='arial';
直接改成
$fontname = 'c:/windows/fonts/arial.ttf'就可以了,大小写不敏感。
我也遇到了这种情况,也按照#4楼的做了,还是出现那种情况,找不到文件名
字体路径的反斜杠是怎么写的,是\还是/,我试了好几种,都不行,并且字体在系统中存在
warning: imagettfbbox() [function.imagettfbbox]: invalid font filename in d:\xampp\htdocs\test\class\pimage.class.php on line 211
warning: imagettftext() [function.imagettftext]: invalid font filename in d:\xampp\htdocs\test\class\pdraw.class.php on line 1023
我的问题出现在调用的类里面,,你们怎么看?
4楼的方法解决了,谢谢.
4楼正解,3ku!
4楼方法管用!