Question

I have a script that uses imagettftext to place text onto an image I am creating.

$font_loc="C:\wamp\www\image-test\FreeSansBold.ttf";
imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2,
        $fontheight, $col_text, $font_loc, $inf[2]);

It works fine if I use the code above. However if I change the font location ($font_loc) to be in a sub directory it doesn't work

$font_loc="C:\wamp\www\image-test\font\FreeSansBold.ttf";

I've check the permissions of that file and it seems to be the same as every other file. Also I've never had a problem with not being able to access a file on WAMP before. I don't get any error messages either, the text just doesn't appear.

If anyone else has had a similar problem and has solved it, any help would be great

No correct solution

OTHER TIPS

From PHP documentation:

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

Try adding this before your code:

putenv('GDFONTPATH=' . realpath('./YOUR_SUB_DIRECTORY'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top