imagettftext() font bug?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
biglaz
Forum Newbie
Posts: 5
Joined: Fri Oct 22, 2004 8:53 pm

imagettftext() font bug?

Post by biglaz »

PHP 5.02
GD: bundled (2.0.28 compatible)
FreeType: 2.1.9

I'm having a problem getting imagettftext() to load fonts correctly. I always get the error:
Warning: imagettftext() [function.imagettftext]: Could not find/open font in /var/www/verify.php on line 50

I've tried both of these varieties, to no avail.

Code: Select all

$imgFontFile = "./comic.ttf";
imagettftext($img, 16, -10, $strX, $strY, $imgFontColor, $imgfontFile, $code);

Code: Select all

$imgFontFile = "./comic.ttf";
$imgFontFile = realpath($imgFontFile);
imagettftext($img, 16, -10, $strX, $strY, $imgFontColor, $imgfontFile, $code);

Is this some kind of bug? I know the ttf file is in the right location and is readable.

Thanks :)
objectifier
Forum Newbie
Posts: 3
Joined: Wed Oct 20, 2004 1:24 pm

Post by objectifier »

Try giving it the full path to the font and see if the error still exists.
biglaz
Forum Newbie
Posts: 5
Joined: Fri Oct 22, 2004 8:53 pm

Post by biglaz »

objectifier wrote:Try giving it the full path to the font and see if the error still exists.
I've tried that too. Still an error. :(
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

try

echo getcwd();

right above the imagegettftext()

then you can make sure your using the right path

its prob a simple spelling mistake, or maybe the wrong path.
biglaz
Forum Newbie
Posts: 5
Joined: Fri Oct 22, 2004 8:53 pm

Post by biglaz »

rehfeld wrote:try
echo getcwd();
right above the imagegettftext()
It prints /var/www. I don't see how that helps though. I've tried absolute paths too, to no avail.
biglaz
Forum Newbie
Posts: 5
Joined: Fri Oct 22, 2004 8:53 pm

Post by biglaz »

Oh, now I figured it out! It was a typo alright. Not sure how I didn't catch it. Notice the two different variables "$imgFontFile" & "$imgfontFile". Silly mistake...

Thanks for the help!
Post Reply