使用 GD 库在字符串中换行
是否可以? \n 不起作用,html 不起作用,似乎什么都不起作用。我知道我可以制作一个新字符串,但这比这个简单任务所需的工作量要多。
我该怎么做?
Is it possible? \n doesnt work, html doesnt work, nothing seems to work. I know I could just make a new string instead, but that is more effort than should be needed for this simple task.
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你不能,
你必须输出一个比以前低一些像素的新字符串。
\n 不会为你做换行...
i think you can't
you have to output a new string some pixels lower than the previous.
\n won't do a linebreak for you...
您不能插入换行符,您可以使用 imagettfbbox 获取任何 truetype 字体的边界框功能。
您可能想查看该页面上的评论以及 上的评论imagettftext 功能页面,他们可能有您正在寻找的答案。
You can't insert line breaks, you can get the bounding box of any truetype font by using the imagettfbbox function.
You might want to take a look at the comments on that page and the comments on the imagettftext function page, they might have the answer you are looking for.
此时此刻你不能。
然而,如果你有很多行,使用这样的东西会更方便:
你可以轻松地创建一个函数来用它编写多行。
At this moment you can't.
However use something like this can be more convenient if you get a lot of lines:
You can easily make a function to write multiple lines with this.