简体   繁体   English

Apache Batik文字包装的SVG

[英]Apache Batik Text Wrapped SVG

Is there a Batik-compatible way to do automatic text wrapping with SVG? 是否有与蜡染兼容的方法来使用SVG自动换行?

I've looked all over the internet and can't find anything definitively. 我已经遍及整个互联网,无法确定地找到任何东西。 foreignObject with HTML doesn't work. 带有HTML的foreignObject不起作用。 I saw that flowRoot and friends should work, but I can't seem to get one to work properly. 我看到flowRoot和朋友应该工作,但是我似乎无法正常工作。 I can't find a conclusively working example either. 我也找不到最终可行的示例。

An SVG sample that works would be much appreciated. 一个有效的SVG示例将不胜感激。

<flowRoot> was a proposed element in the SVG 1.2 specification. <flowRoot>是SVG 1.2规范中建议的元素。 That specification was never ratified, and those text flow elements weren't implemented by any browsers or renderers other than the Inkscape vector editor. 该规范从未得到批准,并且这些文本流元素没有由Inkscape矢量编辑器以外的任何浏览器或渲染器实现。

If you know you are going to only be in a browser environment, you can use <foreignObject> element. 如果知道只在浏览器环境中,则可以使用<foreignObject>元素。 But if the SVG needs to work outside of a browser, you can't use ithat. 但是,如果SVG需要在浏览器之外运行,则不能使用它。

The upcoming SVG2 spec includes features for wrapping text and placing it inside shapes. 即将发布的SVG2规范包含用于包装文本并将其放置在形状中的功能。 For example there is the inline-size property. 例如,有inline-size属性。 However nothing supports that yet. 但是,尚无任何支持。

The only renderer-agnostic option right now is to layout the text rows yourself using separate <text> or <tspan> elements. 现在唯一与渲染器无关的选项是使用单独的<text><tspan>元素<tspan>布局文本行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM