本文介绍了如何在SVG 1.1中正确显示多行文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个多行文本块并将其显示在SVG中.我想将线条保持为线条.有适当的方法吗?

I would like to take a multiline block of text and display it in SVG. I would like to keep the lines as lines. Is there a proper way to do this?

我将Inkscape用于基本图形,将蜡染用于渲染.似乎两个人对如何执行此操作未达成共识.

I am using Inkscape for my base drawing and Batik for my rendering. It seems the two do not agree on how to do this.

Inkscape正在创建这样的结构:

Inkscape is creating a structure like this:

<flowRoot
       xml:space="preserve"
       id="flowRoot3089"
       style="font-size:16px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
       transform="translate(19.71875,334.88681)">
   <flowRegion id="flowRegion3091">
        <rect id="rect3093" width="50.78125" height="75" x="34.765625" y="155.89932"/>
   </flowRegion>

    <flowPara id="flowPara3123">Item 1</flowPara>
    <flowPara id="flowPara3137">Item 2</flowPara>
    <flowPara id="flowPara3139">Item 3</flowPara>
</flowRoot>

但是,由于某些原因,蜡染不可接受.

However, this is not acceptable to Batik for some reason.

推荐答案

Inkscape将文档的SVG版本设置为1.1,而不是1.2,但仍使用文字流畅.

Inkscape sets the SVG version of the document to 1.1 instead of 1.2, but still uses flowing text.

最简单的解决方案是编辑svg文档,并将SVG版本属性更改为1.2. Inkscape不会将其更改回1.1,并且可以很好地处理1.2版本说明符.

The simple solution for you is to edit your svg document and change the SVG version attribute to 1.2. Inkscape will not change it back to 1.1 and it handles the 1.2 version specifier fine.

然后,Batik将很乐意提供大多数功能,但是,如果您搞砸了Inkscape在流根中创建的几乎所有文本属性,也会遇到另一个Inkscape错误.它将背景颜色设置为文本的选定前景色,这意味着,如果在Inkscape中将文本颜色设置为红色,则当蜡染渲染它时,您会看到一个红色正方形...文本在那里,但是红色也是如此,所以不是很明显.这是一个Inkscape错误,在flowRegion-> rect元素的代码中清晰可见.

Batik will then be happy to provide most functionality, however you'll also run into another Inkscape bug if you mess with pretty much any of the text attributes within the flow root that Inkscape creates. It sets the background color to the selected foreground color for the text, which means if you set the text color to red in Inkscape, when batik renders it, you'll see a red square ... the text is there, but its red too, so not really visible. This an Inkscape bug and is clearly visible in the code for the flowRegion -> rect element.

解决方案是在使用inkscape调整flowRect属性后手动对其进行编辑.

The solution is to manually edit your flowRect attributes after tweaking them with inkscape.

如果您使用标准svg输出而不是inkscape svg输出,Batik似乎也会做得更好.

Batik also seems to do better if you use the standard svg output rather than inkscape svg output.

这篇关于如何在SVG 1.1中正确显示多行文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 17:24