问题
I'm using the GD Library to create images from data I'm pulling from an API.
The strings that are returned can sometimes be kind of lengthy, and I'm hoping to find a way to automatically create a new line for text if the string goes too far.
Is there something like this built into the GD library, or will I have to write some code to count the characters and move everything to a new line if it goes too long?
回答1:
GD is strictly for drawing. You'll need a text layout engine such as Pango.
回答2:
I am not familier with a built-in function that automatically creates new lines, so I guess you need to write a php function that sorts the string to "sub-strings" according to your width length and then use them in your image.
Consider looking at this post: http://www.php.net/manual/en/function.imagestring.php#90481
来源:https://stackoverflow.com/questions/9639693/auto-new-line-in-gd-library