开发者

SVG Word wrapping function in PHP? [closed]

开发者 https://www.devze.com 2022-12-23 04:29 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

开发者_StackOverflow社区 Improve this question

Before I go ahead and try to code my own, are there any functions / libraries for PHP which will generate SVG images with text wrapped to a bounding box?

I'm looking for a function which will accept a string and a bonding box, along the lines of: wrapText($text,$x,$y,$width)

So if $text were "The Quick Brown Fox Jumped Over The Lazy Dog" and $width were 125, the SVG file might show:

The Quick Brown

Fox Jumped

Over The Lazy

Dog.

This XML.com article looks like what I'd use, but it's ECMAScript built into the SVG. I'm looking for something that generates pure SVG with no scripts (so it could be read by Adobe Illustrator, for example)

Before I re-code their algorithm in PHP, does anything like this already exist?


In the end I did this myself. The final result is proprietary code, so I can't share it here. But basically it involved creating an SVG 1.2 document with the text inside a <flowRect>, and then feeding that SVG through Inkscape to convert the SVG 1.2 <flowRect> to a series of SVG 1.1 <tspan>s

0

精彩评论

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

关注公众号