1

Am trying to use the gd library with freetype to write some texts on my image for facebook app(find code below) but am having the error: Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/xxx/public_html/yyy/zzz/abc.php on line 49

Specifications: PHP Version 5.3.26 GD Support enabled GD Version bundled (2.1.0 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.11

I found something like '--with-freetype-dir=/usr' too

My code:

$font='arial.ttf';
$text_color = imagecolorat($unprocessedimagejpeg,317,165);
imagettftext($unprocessedimagejpeg, 16,0,0,16,$text_color,$font,'This is the text');
/*I also tried
putenv('GDFONTPATH=' . realpath('.'));
$font = 'arial.tff'; but to no avail
*/

What can be the problem that am getting the error? Should I inlcude the freetype in the php file? (how) Should I be knowing the full path to my font file? How to proceed? Thanks in advance! Also what would be the path to arial.tff ?? or all the fonts available?

user2599068
  • 21
  • 2
  • 6
  • Assuming you're on a unix-like host, what are the file permissions on arial.ttf? Do the permissions allow the user your PHP process/webserver runs as access? Is in the same directory as the script in question? – BenLanc Jul 22 '13 at 10:45
  • @MrJamin Well it's a linux server, and this is the problem that I cannot find the path to arial.tff to know it's permission any idea on how to find the path to the fonts? – user2599068 Jul 22 '13 at 10:48
  • Does the font arial.ttf exist in the directory? There needs to be a file called arial.ttf somewhere :) place it in the same directory as abc.php – Luc Jul 22 '13 at 15:46
  • No it soesn't exist in any directory. My server provider asks me to use it in code straight forward and it should be working! – user2599068 Jul 23 '13 at 03:28

0 Answers0