Forum Moderators: coopster

Message Too Old, No Replies

How to use imagettftext

         

Gian04

2:24 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Warning: imagettftext() [function.imagettftext]: Could not find/open font in ... on line 71
PNG  IHDRxD70 IDATx콷n7b⨙1FLxɦ󽓀J}Lw7dhBC (LOng Text of alien characters here)

I always get this error message even though Im sure that i specified the correct path of the font

Heres my code:

$fonttype = "../image/fonts/GOTHICB.TTF";

imagettftext($imagehere, 20, 0, 5, 125, $bluetext, $fonttype, $texthere);

Still an error even if I change the path like this

$fonttype = "http://www.example.com/image/fonts/GOTHICB.TTF";

[edited by: Gian04 at 2:36 pm (utc) on June 22, 2007]

joelgreen

5:09 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



That "strange string" is a PNG file content. It somehow treats png file as path...

Are you sure $fonttype is not set to something strange before it is passed to the imagettftext?

whoisgregg

5:34 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Properly specifying the font path can be pretty tricky. I'd recommend using an absolute path on your server (the relative path "../..." and url "http://..." approaches are both less than ideal).

So, specify the font like:

$fonttype = $_SERVER['DOCUMENT_ROOT']."/image/fonts/GOTHICB.TTF";

Also, take a look at the manual page [php.net] with it's caveats for specifying font path.

maccas

11:58 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Not sure if this would cause that error but was the font uploaded as a binary?