Auto New Line In GD Library

不羁的心 提交于 2019-12-24 08:35:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!