Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

imagettftext Multiple Lines Fixed image width

Stumbling with imagettftext

4:43 pm on Aug 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 2, 2004
votes: 0

Trying to use imagettftext to draw text on an image. The width and height is fixed. I'm having trouble calculating the basepoint of the first character (x and y). The text is supplied by the user so sometimes I can do one line and sometimes as many as three lines. Someone must have done this before and have a good algorithm. Or is this the wrong function to use?
12:28 am on Aug 23, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
votes: 0

Have you had any luck with this problem? If you know the width in pixels of the image that you are using, you should be able to figure out how many characters can fit across the image using something like imagefontwidth [us2.php.net](). Read the user-contributed notes to get some ideas, as well.

good luck