2

I'm trying to wrap text automatically since I won't know what the text is ahead of time.

I tried using the accepted answer in this question, but nothing shows up. Here is my sample code so far:

  <svg id="viz" style="margin:auto; position:fixed; height:100%; width:100%;" xmlns="http://www.w3.org/2000/svg">
      <switch>
          <g requiredFeatures="http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow">
              <textArea width="200" height="300">whatever</textArea>
          </g>
          <foreignObject width="200" height="300">
              <textArea xmlns="http://www.w3.org/1999/xhtml" style="width: 200px;height: 300px">otherwise</textArea>
          </foreignObject>
      </switch>
  </svg>

I am rendering this SVG in FireFox (since its part of a web page).

wheeler
  • 2,823
  • 3
  • 27
  • 43

1 Answers1

3

Firefox implements some parts of SVG 2 and dropping support for requiredFeatures is one part of SVG 2 that it has implemented.

Previous versions of SVG included a third conditional processing attribute, requiredFeatures. This was intended to allow authors to provide fallback behavior for user agents that only implemented parts of the SVG specification. Unfortunately, poor specification and implementation of this attribute made it unreliable as a test of feature support.

That means that the first part of the switch now applies when at the time I wrote the answer to the other question, it didn't. The answer is to remove the switch and the first element as nobody implements SVG 1.2 textArea any more.

<svg id="viz" style="margin:auto; position:fixed; height:100%; width:100%;" xmlns="http://www.w3.org/2000/svg">
          <foreignObject width="200" height="300">
              <textArea xmlns="http://www.w3.org/1999/xhtml" style="width: 200px;height: 300px">otherwise</textArea>
          </foreignObject>
  </svg>
Robert Longson
  • 118,664
  • 26
  • 252
  • 242