Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not find/open font" when using PHP gd

Tags:

php

fonts

gd

I am getting this error Could not find/open font When trying imagettftext() in PHP.

The font file is there. What is the problem?

like image 401
Drew LeSueur Avatar asked Sep 28 '10 05:09

Drew LeSueur


1 Answers

I found the answer on bytes http://bytes.com/topic/php/answers/4833-gd-could-not-find-open-font-font-problem

Setting the gdfontpath may help

$fontpath = realpath('.'); //replace . with a different directory if needed
putenv('GDFONTPATH='.$fontpath);
$font = 't.otf';
...
$box = imagettfbbox($size, 0, $font, $text);
like image 139
Drew LeSueur Avatar answered Sep 17 '22 22:09

Drew LeSueur