Text in SVG is rendered in wrong size
Categories
(Core :: SVG, defect, P3)
Tracking
()
People
(Reporter: marcel.kammer, Unassigned)
Details
Attachments
(1 file)
6.58 KB,
image/svg+xml
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Steps to reproduce:
Open a SVG file in 60.6.1 ESR in Win10. The SVG contains <text>-tags with line breaks between start and end tag (see attached file). It also contains whitespaces between <tspan>-"subtags".
Actual results:
The text is displayed with the wrong font size or displayed with whitespaces that are not part of the text itself (but between XML tags).
Expected results:
In Edge the SVG is rendered as expected. The text should appear with the correct font size. Whitespaces between tags should not appear in the rendered SVG-image. This is the case when removing line breaks or whitespaces between the tags.
Updated•6 years ago
|
Comment 1•6 years ago
|
||
As far as I know Edge does not support xml:space but Firefox does. Looks like Chrome has dropped support for xml:space too as far as I can tell.
That just leaves the font issue. It seems we want the font-size on the text element which shouldn't be necessary so that is a bug.
Reporter | ||
Comment 2•6 years ago
|
||
When using "xml:space=preserve" and using line breaks/spaces for "XML prettyfing" at the same time, these chars will also be rendered when they are somewhere inside of the <text>-tag. So this would be a bug of the app that created the SVG. Is this correct?
Comment 3•6 years ago
|
||
Correct, that's not a Firefox bug. The font size is the only thing we'd look into fixing.
Comment 4•6 years ago
|
||
Regarding xml:space
, it looks like Chrome still honors it but only if it is set on a text content element. It doesn't "inherit" the value from an ancestor <g>
or <svg>
. In https://svgwg.org/svg2-draft/styling.html#UAStyleSheet the user agent style sheet has this rule:
*[xml|space="preserve"] {
text-space-collapse: preserve-spaces;
}
and this is how we implement xml:space
.
It may be more Web compatible to change this UA style sheet rule to:
text[xml|space="preserve"], tspan[xml|space="preserve"], textPath[xml|space="preserve"] {
text-space-collapse: preserve-spaces;
}
WDYT, Robert?
For the font-size part of this bug, is that just another example of problems with using app units and the scaling we do internally?
Comment 5•6 years ago
|
||
Alternatively we should add a WPT to test that xml:space
inherits correctly.
Updated•6 years ago
|
Comment 6•6 years ago
|
||
I'm surprised Chrome's behaviour is web compatible. Most of the SVG editors I've seen only set xml:space on the root <svg> element.
Comment 7•6 years ago
|
||
The font size issue seems fixed in Firefox 67. Not sure what fixed it or exactly when it got fixed.
Comment 8•6 years ago
|
||
Interesting. I'll write up a WPT for it then.
Comment 9•6 years ago
|
||
Adding the test in bug 1558356.
Description
•