【发布时间】:2014-10-06 23:03:24
【问题描述】:
我正在尝试使用我在网站上上传的字体,但我不断收到此错误:
“
imagettftext(): 找不到/打开字体”。
我已经尝试过使用 putenv 工具,但它仍然无法打开文件。 Bonfire 上是否有一个选项可以限制可以使用的文件类型? 我可以使用 imagestring 函数,但我想要其他字体。
我能够将字体加载到 HTML 文件中,所以看起来 imagettftext() 有问题。
$image = imagecreatefrompng('/home/dev3/public_html/themes/admin/images/countdown.png');
$font = array(
'size'=>40,
'angle'=>0,
'x-offset'=>10,
'y-offset'=>70,
'file'=>'/home/dev3/public_html/fonts/DIGITALDREAM.ttf',
'color'=>imagecolorallocate($image, 255, 255, 255),
);
$image = imagecreatefrompng('/home/dev3/public_html/themes/admin/images/countdown.png');
// Open the first source image and add the text.
$text = $interval->format('%a:%H:%I:%S');
if(preg_match('/^[0-9]\:/', $text)){
$text = '0'.$text;
}
$text,$font['color']);
putenv('GDFONTPATH=' . realpath('.'));
imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'],$font['file'] ,$text);
ob_start();
imagegif($image);
ob_end_clean();
$gif = new AnimatedGif($frames,$delays,$loops);
$gif->display();
【问题讨论】:
-
尝试使用完整路径。或者查看
echo getcwd();的输出。它和你的 .ttf 文件所在的位置一样吗? -
没有 .ttf 文件与我的 php 位于同一目录中。我已将 .ttf 文件的副本放在多个位置,包括具有正确路径的 public_html 文件夹,但它仍然给我带来了问题。我可以打开路径的 url,它会提示我下载文件。我什至尝试在不同的服务器上使用 URL,它运行良好。我认为这个问题与 imagettftext() 有关,因为 imageString 函数工作得很好,我只想使用 .ttf 文件
标签: php imagettftext bonfire