Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a2424901/public_html/index.php on line 35

感情迁移 提交于 2019-11-27 15:29:51

From the docs

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.

This seems to imply that the fontfile should be an absolute path, and if it isn't, the function will append another .ttf onto the end of it.

Specify the full path to the font file.

$font = "/home/a2424901/public_html/Arial.ttf";

Or omit the .ttf and use the GDFONTPATH. The documentation recommends the following:

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

putenv('GDFONTPATH=' . realpath('.'));
$font = "Arial";

To add on to user2724960's answer; Changing the FontName to __DIR__ . '/graph/fonts/someFont.ttf' did it for me.

Full line:

$myPicture->setFontProperties(array("FontName"=>__DIR__ .  '/graph/fonts/someFont.ttf',"FontSize"=>14));

Don't forgot to replace "someFont" with the name of your font file (default: "Forgotte")

My solve (works for me):

realpath('here/is/right/path/to/font.ttf');
Mahdian

if you are using pChart use this:

$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));

I had same problem. My font name was

Titr.TTF

and i changed it to

Titr.ttf

and its worked perfectly.

Please check for the font folder under Resources.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!