PHP - imagettftext not working and GD installed

…衆ロ難τιáo~ 提交于 2019-12-05 04:50:30

Had the same problem, with FreeType installed, solution was

 $font = "./Arial.ttf"; // <--- put ./ in front of filename

Notice you don't have Free Type installed:

["FreeType Support"]=>
  bool(false)

This function requires both the GD library and the » FreeType library.

You will need to install Free Type library before you can use this function.

try installing these package:s freetype, freetype-devel

If you compiled PHP you can make sure you added enabled freetype during compile time:

--with-freetype-dir=/usr/include/freetype2/ --with-freetype

Or if you using something such as YUM or APT-GET it should be really simple to install those libraries, and a quick search ob google with get you started.

Veshraj Joshi

Well i also got problem around

$font='arial.tff'; 

I think you should provide absolute path to the $font like

$font="c:/windows/fonts/arial.ttf";

i assume you are a windows user. and remove

header('Content-Type:image/png');

to get the real error

I solved this problem with this solution:

$fontfile= __DIR__.'/Fontname.ttf';

Andrew is right, the php manual for imagettftext states FreeType is required to use imagettftext, imagettfbox, and others. Most people the GD devel package will install FreeType automatically:

Fedora/Redhat:

yum install gd gd-devel php-gd

Debian/Ubuntu:

apt-get install php5-gd libgd2-xpm libgd2-xpm-dev

This error was probably in your logs:

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