GD Warning: imagettfbbox(): Could not find/open font
2013-09-23 02:20
288 查看
在运行pChart的example的时候出现了这个问题,字体路径是没问题的,代码应该也无问题。网上找了一下,发现官网有相应的提示:http://php.net/manual/en/function.imagettftext.php。
The path to the TrueType font you wish to use.
Depending on which version of the GD library PHP is using, when
not begin with a leading / then .ttf will be appendedto the filename and the library will attempt
to search for that filename along a library-defined font path.
When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional
use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain
spaces.
In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.
遇到这个问题可能的原因是字体路径中出现了“.”,不巧的是,我的脚本就出现了。
这个问题的解决方案有两个:
第一种:就是按官网所说的,在使用imagettfbbox()函数前设置GDFONTPATH环境变量;
第二种:我发现使用字体的绝对路径,也是能够加载的。
网上有说法是linux不能用相对路径,这是错误的,算是GD2.0.18以下版本的小缺陷吧。
fontfile
The path to the TrueType font you wish to use.
Depending on which version of the GD library PHP is using, when
fontfiledoes
not begin with a leading / then .ttf will be appendedto the filename and the library will attempt
to search for that filename along a library-defined font path.
When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional
use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain
spaces.
In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.
<?php // Set the enviroment variable for GD putenv('GDFONTPATH=' . realpath('.')); // Name the font to be used (note the lack of the .ttf extension) $font = 'SomeFont'; ?>
遇到这个问题可能的原因是字体路径中出现了“.”,不巧的是,我的脚本就出现了。
这个问题的解决方案有两个:
第一种:就是按官网所说的,在使用imagettfbbox()函数前设置GDFONTPATH环境变量;
第二种:我发现使用字体的绝对路径,也是能够加载的。
网上有说法是linux不能用相对路径,这是错误的,算是GD2.0.18以下版本的小缺陷吧。
相关文章推荐
- imagettftext Warning: Could not find/open font
- gnuplot Could not find/open font when opening font "arial", using internal non-scalable font
- php【Warning: imageftbbox(): Could not find/open font in……】的问题
- 解决LINUX vncserver 启动 could not open default font 'fixed'错.
- 虚拟机virtualbox:Could not find an open hard disk with UUID(解决方案)
- CDbConnection failed to open the DB connection: could not find driver错误的处理
- 解决LINUX vncserver 启动 could not open default font 'fixed'错误.
- could not open default font 'fixed' ...
- VMware虚拟机启动无法进入系统 linux 无法进入图形界面 error: could not open default font 'fixed'
- Linux "could not open default font 'fixed'."错误解决 .
- SSD(Single Shot MultiBox Detector):create_list.sh io.cpp:187 Could not open or find file
- Could not find any matches for com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+ as no version
- Could not find any matches for com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+ as no versions处理
- yii框架:CDbConnection failed to open the DB connection: could not find driver的解决办法
- Could not find an open hard disk with UUID {57bbe8fe-8b4f-4a0d-aef4-1291b23d2bef}. 返回 代码: VBOX_E_OBJ
- Linux启动时出错:Linux "could not open default font 'fixed'."错误解决
- Could not find/open
- 虚拟机virtualbox:Could not find an open hard disk with UUID {36844126-9e88-4686-9858-2d1a0568f53c}.
- Yii “CDbConnection failed to open the DB connection: could not find driver"解决办法
- VMware虚拟机启动无法进入系统 linux 无法进入图形界面 error: could not open default font 'fixed'