SVG Inkscape生成的文件不会在浏览器上显示flowRoot对象

时间:2013-10-15 21:13:33

标签: javascript html html5 svg internet-explorer-9

我正在处理SVG文件,以便使用AJAX在浏览器上制作一些实时动画。

除了让浏览器(Chrome或IE9)显示SVG图像外,一切都很好。以下HTML文件未显示flowRoot文本:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="744.09448"
   height="600"
   id="svg2"
   version="1.1"
   inkscape:version="0.48.4 r9939"
   sodipodi:docname="lcl22.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.7"
     inkscape:cx="175.99454"
     inkscape:cy="282.7269"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="1366"
     inkscape:window-height="706"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-452.36215)">
    <path
       sodipodi:type="arc"
       style="fill:#008000;fill-opacity:1;stroke:#495677;stroke-width:23.16900063;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="circle1"
       sodipodi:cx="227.14285"
       sodipodi:cy="156.6479"
       sodipodi:rx="47.142857"
       sodipodi:ry="44.285713"
       d="m 274.28571,156.6479 c 0,24.45833 -21.10658,44.28572 -47.14286,44.28572 C 201.10657,200.93362 180,181.10623 180,156.6479 c 0,-24.45832 21.10657,-44.28571 47.14285,-44.28571 26.03628,0 47.14286,19.82739 47.14286,44.28571 z"
       inkscape:label="#path2985"
       transform="translate(12.857143,635.71428)" />
    <rect
       style="fill:#00ff00;fill-opacity:1;stroke:#495677;stroke-width:4.86899996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="box1"
       width="284.28571"
       height="110"
       x="312.85715"
       y="738.07648"
       inkscape:label="#box1" />
    <flowRoot
       xml:space="preserve"
       id="flowRoot3058"
       style="font-size:40px;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;text-anchor:middle;text-align:center"
       transform="translate(0,452.36215)"><flowRegion
         id="flowRegion3060"><rect
           id="rect3062"
           width="365.71429"
           height="100"
           x="221.42857"
           y="145.71428"
           style="text-anchor:middle;text-align:center" /></flowRegion><flowPara
         id="flowPara3064"
         style="font-weight:bold;-inkscape-font-specification:Sans Bold">LCL22 TEST</flowPara></flowRoot>  </g>
</svg>

我曾尝试通过更改以下行将代码更改为1.2版,但未解决问题...

   version="1.2"

我需要一种简单的方法来编辑自定义矢量图形并将其引入浏览器。我认为SVG将是一块蛋糕,但我遇到了这样的问题......

任何帮助表示感谢。

的Rds

2 个答案:

答案 0 :(得分:25)

The SVG 1.2 Full specification was never completed(你可以从链接中看到它仍然在2005年的草稿中),而且我认为只有Inkscape支持flowRoot。我认为flowRoot不会成为SVG 2的一部分,因为它可能会使用不同的CSS兼容机制来实现流动文本,因此最好避免使用flowRoot。

使用“文本”菜单中的“转换为文本”命令将其转换为符合SVG 1.1的文本。

答案 1 :(得分:4)

正如其他人所说,您可以使用转换为文字取消来删除flowRoot。

请注意,文本将不再保留在您指定的边界内。

要避免flowRoot向前发展,只需单击文本工具并开始键入,而不是先拖动以设置绑定。

要创建适合边界框的文本,我不确定最佳方法是什么。