New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 793965 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: 2017-12-26
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

getComputedTextLength() + textLength oddities

Reported by philipp....@gmail.com, Dec 11 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36

Steps to reproduce the problem:
1. Go to https://bl.ocks.org/Herst/raw/a304caf946e59a7e34c24bd828fa0b3a/?textLength=100 or alternatively open the attached test case and set the textLength to 100 (and press the enter key or trigger the "change" event somehow else).

2. Observe the displayed getComputedTextLength() return values displayed below each SVG.

What is the expected behavior?
The getComputedTextLength() return value would be expected to be around what the value set by the textLength attribute.

What went wrong?
The getComputedTextLength() return values differs quite a bit from textLength attribute value. In some cases it seems entirely unaffected by it (set the "textLength" textbox to empty to see how it is without textLength).

Did this work before? N/A 

Does this work in other browsers? No
 Apparently Apple Safari 9.1 (according to browserstack.com) is similar to Chrome on this. Mozilla Firefox and Microsoft Edge are not (at least if spacingAndGlyphs is used in the case of Firefox).

Chrome version: 63.0.3239.84  Channel: stable
OS Version: 10.0
Flash Version:
 
waterfall_computed_text.html
8.2 KB View Download
Unable to reproduce the issue on reported chrome version 63.0.3239.84 using Windows 10 with the steps mentioned below:

Steps followed to reproduce the issue:
1) Launched chrome
2) Navigated to URL: https://bl.ocks.org/Herst/raw/a304caf946e59a7e34c24bd828fa0b3a/?textLength=100
3) Provided the TestLength value
4) getComputedTextLength() value changed as per TestLength value

@Reporter:
Please find the attached screencast for your reference and let us know if we are missing anything in reproducing it, can you please try to test this issue by creating a new profile with no extensions and apps in it and let us know if the issue still persists.

Thanks!
793965.mp4
1.5 MB View Download
Cc: viswatej...@techmahindra.com sc00335...@techmahindra.com
Labels: Needs-Triage-M63 Triaged-ET Needs-Feedback
@#1 Below the SVG it says "computedLen:", after this is the value returned by getComputedTextLength(). This return value is very different from "100" or any "textLength" value you enter, unlike in other browsers. This is what this issue is about.
Components: Blink>SVG

Comment 5 by f...@opera.com, Dec 12 2017

getComputedTextLength() never was particularly well-specified. The SVG 1.1 definition [1] basically say "The total sum of all of the advance values...".
The SVG2 draft defines it in terms of the getSubStringLength() method, but in practice I think it only differs from SVG 1.1 by not including contributions from 'dx' and 'dy'. SVG2 has a note which seems to indicate that the "user agent's calculation for ‘textLength’" is what's supposed to be returned - which I interpret as not including adjustments due to textLength.

In Blink the behavior is fairly close to what SVG2 says, although I suspect that *-spacing may not be included.

You can raise an issue on the spec (https://github.com/w3c/svgwg/issues) for clarification.

[1] https://www.w3.org/TR/SVG11/text.html#__svg__SVGTextContentElement__getComputedTextLength
[2] https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getComputedTextLength
NextAction: 2017-12-26
Status: Available (was: Unconfirmed)
Thank you, since this is a standards issue then and not a bug per-se it can be closed from my side (I shouldn't be one making that decision though).

BTW, I came across this because I wanted to achieve that having text which just possibly shrinks to fit into text into a box but without expanding if the text width is smaller. If something existed where I could just make a text element behave this way then getComputedTextLength() wouldn't be needed (in this case), see also https://github.com/w3c/svgwg/issues/341

Comment 8 by f...@opera.com, Dec 13 2017

Status: WontFix (was: Available)
FWIW, we're happy to change the behavior here if there's consensus around what the behavior should be (and it is clarified et.c.) I think we can close this until then though.
The NextAction date has arrived: 2017-12-26

Sign in to add a comment