in reply to Newline in GD?

If you read "perldoc GD::Text", there is a way to get the current width of the string in pixels:
$gd_text->width(string) return the length of a string in pixels, without changing the current value of the text. Returns the width of string rendered in the cur rent font and size. On failure, returns undef.
So.... you could write a simple loop, to make your string fit the width of the graphic, and when it approaches the limit, shift your next string down by 1.5 times the height of your font, which you can obtain from $gd_text->get('height').

You should be able to print nicely wrapped text, breaking on whole words, with a clever loop to construct and test current string width in pixels.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum