Open Bug 890692 Opened 11 years ago Updated 2 years ago

maybe support textLength="" and lengthAdjust="" on tspan and textPath

Categories

(Core :: SVG, defect)

defect

Tracking

()

Webcompat Priority P3

People

(Reporter: heycam, Unassigned)

References

Details

(Keywords: access)

Attachments

(3 files)

Bug 569722 added support for textLength="" and lengthAdjust="" on <text> but not <tspan> and <textPath>.  We should think about whether it makes sense to support them on these child elements as the spec currently says, and bring it up in the WG if not.

If we do support this, we'll need to change SVGTextPathElement::Get{Enum,Length}Info to also include these attributes, since they currently override the ones on SVGTextContentElement.
Summary: maybe support textLength="" and lengthAdjust="" on tspan and textPath → maybe support textLength="" and lengthAdjust="" on altGlyph, tspan and textPath
Here's a test case showing how textLength on SVG can be used. It's a single <text> element containing a separate <tspan> for each line. These lines wrap around a rectangle, e.g. an image in a newspaper style layout.
FWIW, a fix for this would help me a lot. Right now my workaround is to add a CSS rule for Firefox if sub-pixel rendering is not supported properly: 

text { text-rendering: geometricPrecision; }
Implementing this for <tspan> would work wonders for multiline text. Right now I have to use <text> for everything to get the proper fallback behavior, which has two problems:

* Text selection gets weird (Firefox interprets <tspan> boundaries like inline elements, <text> boundaries like line breaks)
* Assistive technology thinks each <text> should be treated like a paragraph
Yes.  Since it is in the spec it seems good to implement it (this bug seems to have been around a long time).  My webapp looks fine in IE and webkit, but was unreadable in firefox.  My workaround is to not use tspan on firefox but that breaks screen readers for the blind.
<svg width="350" height="200" viewBox="0 0 350 200">
        <text textLength="350">
          <tspan x="1" y="80">I am a single line of text inside an SVG</tspan>
          <tspan x="1" y="100">and this is basically one sentence.</tspan>
        </text>
        <rect x="0" y="0" width="350" height="200" fill="none" stroke="blue" stroke-width="2"></rect>
      </svg>
I would like this to be revisited. <text> cannot be expected to be used for each line as that is not proper markup. 

so far the only proper fix I have found to get <tspan> glyphs to fit the viewbox is to apply dx values to every glyph, starting with 0. however this is far from a good solution, as the spacing isn't consistent across browsers, and it's just plain tedious. all other latest browsers (including IE 11)support textLength on tspan.
<svg width="350" height="200" viewBox="0 0 350 200">
        <text>
          <tspan x="1" y="80" textLength="350">I am a single line of text inside an SVG</tspan>
          <tspan x="1" y="100" textLength="350">and this is basically one sentence.</tspan>
        </text>
        <rect x="0" y="0" width="350" height="200" fill="none" stroke="blue" stroke-width="2"></rect>
</svg>
Summary: maybe support textLength="" and lengthAdjust="" on altGlyph, tspan and textPath → maybe support textLength="" and lengthAdjust="" on tspan and textPath

The SVG 2 CR does mention both attributes as valid for <textPath>, and Chrome supports this as well, even though they do not support textLength on the <text>. Because we have received a webcompat report about this, this may be breaking some things.

Webcompat Priority: --- → ?
Webcompat Priority: ? → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: