这是我在更改有效网站的环境时收到的错误消息:
Warning: imagettftext() [function.imagettftext]: Could not find/open font
首先我以为这是由于缺乏文件权限,但事实并非如此,我检查了路径并将所有文件设置在 777 中... 然后我检查GD,看起来它已经安装了:
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.5
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
我正在尝试使用 arial.ttf,所以我猜没有太多异国情调...... 知道从哪里开始看吗?
谢谢
最佳答案
如果您使用的字体与脚本位于同一目录中(开头没有前导 /
),请仅键入 arial
,不带 .ttf
。如果它在另一个目录中,则必须包含 .ttf
。顺便说一句:如果您可以添加您正在使用的代码,那就太好了。
这里是示例代码:
# Correct
$font = 'arial';
# Wrong
$font = 'arial.ttf';
# Correct
$font = '/fonts/arial.ttf';
# Wrong
$font = '/fonts/arial';
PHP.NET说:
Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.
关于php - 使用带有 imagettftext 的字体时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5566236/