2

我对“imagettftext”功能有疑问。如果我评论有问题的行(我看到一个黄色矩形),则以下代码有效。

session_start();
$text = $_SESSION['code'];
header("Content-type: image/gif");
$image = imagecreate(150, 15);
$red_bg = 255; $green_bg = 255; $blue_bg = 155;
$bg_col = imagecolorallocate($image, $red_bg, $green_bg, $blue_bg);
$red_txt = 0; $green_txt = 0; $blue_txt = 0;
$text_col = imagecolorallocate($image, $red_txt, $green_txt, $blue_txt);
$font = "LucidaSansRegular.ttf";
$link_col = imagecolorallocate($image, 0, 0, 255);
//imagettftext($image, 10.0, 0.0, 5, 5, $text_col, $font, "aaaaa");
imagegif($image);

但是,如果我取消注释有问题的行(以显示一些文本),我会遇到问题。Mozilla 写信给我“图像无法显示,因为它包含错误”。

可能这与访问我的字体文件(LucidaSansRegular.ttf)有关。我目录中的所有文件都有“-rw-r--r--”(包括喜欢的文件)。

有什么建议么?我需要在另一台服务器上添加该代码有效。

4

1 回答 1

0

/ 表示根目录 ./ 表示当前目录 ../ 表示父目录

希望这能向您解释它为什么起作用;)

于 2010-12-20T22:11:24.530 回答