I am looking to create a new forum signature that pulls quotes from a DB and displays them in a black background PNG image. That part is easy, however some quotes are longer than the image so I need the text to wrap. How do I make the text wrap so it does not go off the image? Do I need to just count characters and once X characters is reached add a <br /> or is there a better way to do this?
Thanks in advance!
Write text to PHP generated PNG
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
It looks like imagefontwidth() will return the information you need...
Although I'm not sure how accurate the result is, if your using a font that is variable width I would guess it returns the pixel width of "W" typically the widest character...
Likewise you could calculate the height of the image using the counter-part...
Although I'm not sure how accurate the result is, if your using a font that is variable width I would guess it returns the pixel width of "W" typically the widest character...
Likewise you could calculate the height of the image using the counter-part...
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
imagettfbbox() will be useful here too.