如何使 SVG 尊重文本宽度并相应地换行?
就像在 HTML 中一样,但我不想使用foreignObject。
这应该是一个标准问题,所以我想有一个标准解决方案,但找不到。
谢谢
拉斐尔
Like in HTML, but I'd prefer to not use foreignObject.
This should be a standard-problem so I guess there is a standard-solution, couldn't find one though.
Thanks
Raffael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SVG 1.2T
The SVG 1.2T
<textArea>
element is the standard way. It's possible to implement similar functionality using javascript too, which can be good as a fallback. See e.g http://www.carto.net/papers/svg/textFlow/.我在 PHP 函数 imagettfbbox() 的帮助下渲染了换行,以测量行长度。
最佳
拉斐尔
I rendered the line breaking aided by the PHP-function imagettfbbox(), to measure the line-length.
Best
Raffael
好吧......它的标签是“自动换行”,看起来这仅在 SVG 1.2 中实现。虽然 FireFox 不支持 W3C 上的示例 (http://www.w3.org/TR/SVGTiny12/text.html#TextInAnArea)...哦天哪
Okay ... the label for that is "word wrap" and it seems like this is only implemented in SVG 1.2. Though the example on W3C (http://www.w3.org/TR/SVGTiny12/text.html#TextInAnArea) is not supported by FireFox ... oh my
标准解决方案是SVG1.2,但它尚未实现,所以我猜foreignObject解决方案是目前最好的。
The standard solution is SVG1.2, but it's unimplemented so I guess the foreignObject solution is the best at the moment.