PHP and using fonts with GD

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
Stanger
Forum Newbie
Posts: 2
Joined: Sat Nov 04, 2006 1:15 pm

PHP and using fonts with GD

Post by Stanger »

First time poster here. Hope this makes sense and is able to be answered.

I am coding a script that uses gd to create an image. In a perfect world, the user will be able to enter text, choose a font from a dropdown menu and submit the info to the script that generates their custom image.

Thus, I have a question.

In order for this to work, do the fonts have to be ones installed on the USERS pc?

My reason for asking this is that, so far, my script will not use ANY font that is not installed. I am working in a Windows invironment but have attempted to set the font directory using putenv( 'GDFONTPATH='.realpath('./fonts') );. The fonts inside that directory are not installed on my machine. Maybe I am not doing something right with that piece of code? Is this possible without having the fonts "installed" on the PC running the server?

I have written several scripts using PHP, but never have I used anything with GD or fonts. This area is still very new to me and any help with this is much appreciated.

Stanger
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Moved to GD.

the fonts would have to be installed on the server. I believe GD only works with TTF fonts using the imagettftext() function
Stanger
Forum Newbie
Posts: 2
Joined: Sat Nov 04, 2006 1:15 pm

Post by Stanger »

My appologies for not looking harder at the forum descriptions.

Thanks for the info. That makes a world of difference for this script :)

Very much appreciated!

Stanger
Post Reply