【发布时间】:2018-01-27 21:15:28
【问题描述】:
问题
我收到一个运行时错误,上面写着 - 字体文件名无效。我在 Window 8.1 中使用 XAMPP
看来我需要映射 C:\XAMPP 中存在的字体文件夹的任何路径,或者请提出建议。
$jpg_image = imagecreatefromjpeg('sunset.jpg');
$white = imagecolorallocate($jpg_image, 255, 255, 255);
$font_path = 'font.TTF';
$text = "This is a sunset!";
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);
【问题讨论】:
-
该文件是否与该脚本存在于同一文件夹中?如果是,请尝试将其更改为:
$font_path = __DIR__ . '/font.TTF';。如果在同一个文件夹中不存在,则添加绝对路径。 -
还是一样的错误。
标签: php