Closed Bug 1547232 Opened 6 years ago Closed 6 years ago

Text in SVG is rendered in wrong size

Categories

(Core :: SVG, defect, P3)

60 Branch
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: marcel.kammer, Unassigned)

Details

Attachments

(1 file)

Attached image pdf_err.svg

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.

Component: Untriaged → SVG
Product: Firefox → Core

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.

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?

Correct, that's not a Firefox bug. The font size is the only thing we'd look into fixing.

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?

Flags: needinfo?(longsonr)

Alternatively we should add a WPT to test that xml:space inherits correctly.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

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.

Flags: needinfo?(longsonr)

The font size issue seems fixed in Firefox 67. Not sure what fixed it or exactly when it got fixed.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME

Interesting. I'll write up a WPT for it then.

Adding the test in bug 1558356.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: