Page 1 of 1

imagettftext() font bug?

Posted: Fri Oct 22, 2004 9:04 pm
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 :)

Posted: Fri Oct 22, 2004 9:34 pm
by objectifier
Try giving it the full path to the font and see if the error still exists.

Posted: Sat Oct 23, 2004 1:29 am
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. :(

Posted: Sat Oct 23, 2004 12:40 pm
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.

Posted: Sat Oct 23, 2004 7:18 pm
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.

Posted: Sat Oct 23, 2004 7:22 pm
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!