在imagettftext中使用字体时出现问题 [英] Problem using font with imagettftext
问题描述
这是我更改有效网站的环境时收到的错误消息:
this is the error message i get when I change the environment of an effective website:
Warning: imagettftext() [function.imagettftext]: Could not find/open font
首先,我想这是由于文件权限不足引起的,但事实并非如此,我检查了路径并在777中设置了所有文件... 然后我检查GD,看起来好像已经安装了:
First I was thinking it cames from a lack of rights on the files, but it doesn't, I check the path and set all the files in 777... Then I check GD, and it looks like it is installed :
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,所以我想没有太多异国情调... 知道从哪里开始看吗?
I'm trying to use an arial.ttf, so not much exotic I guess... Any idea where to start looking at ?
Thx
推荐答案
如果使用的字体与脚本位于同一目录中(开始时不能以/
开头),则仅键入arial
而不使用.ttf
.如果它在另一个目录中,则必须包含.ttf
.顺便说一句:如果您可以添加正在使用的代码,那就太好了.
If you are using font which is in the same directory with script (no leading /
at beggining) , type just arial
without .ttf
. If it is in another directory you must include .ttf
. BTW: It would be nice if you could add code that you are using.
这是示例代码:
# Correct
$font = 'arial';
# Wrong
$font = 'arial.ttf';
# Correct
$font = '/fonts/arial.ttf';
# Wrong
$font = '/fonts/arial';
PHP.NET 说:
取决于GD的版本 字体文件时,PHP正在使用库 不以前导/开头 .ttf将附加到文件名 图书馆将尝试搜索 对于该文件名以及 库定义的字体路径.
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.
这篇关于在imagettftext中使用字体时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!