开发者

How to make SVG respect a text-width and have it break lines accordingly?

Like in HTML, but I'd prefer to not use foreignObject.

This should be a standard-pr开发者_开发问答oblem so I guess there is a standard-solution, couldn't find one though.

Thanks

Raffael


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/.


I rendered the line breaking aided by the PHP-function imagettfbbox(), to measure the line-length.

Best

Raffael


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


The standard solution is SVG1.2, but it's unimplemented so I guess the foreignObject solution is the best at the moment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜