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

NEW
Unassigned

Status

()

5 years ago
7 months ago

People

(Reporter: heycam, Unassigned)

Tracking

({access})

Trunk
access
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

5 years ago
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.
(Reporter)

Updated

5 years ago
Summary: maybe support textLength="" and lengthAdjust="" on tspan and textPath → maybe support textLength="" and lengthAdjust="" on altGlyph, tspan and textPath

Comment 1

5 years ago
Created attachment 8347828 [details]
tspan-textLength.svg (testcase)

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.

Comment 2

5 years ago
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; }
Duplicate of this bug: 1012781

Comment 4

3 years ago
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

Comment 5

3 years ago
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.
Keywords: access

Comment 6

a year ago
Created attachment 8914972 [details]
textLength applied to <text> element with <tspan> children

<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>

Comment 7

a year ago
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.

Comment 8

a year ago
Created attachment 8914978 [details]
textLength applied to tspan children

<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
You need to log in before you can comment on or make changes to this bug.