Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-inline] CSS properties appply to SVG elements #3411

Closed
dirkschulze opened this issue Dec 8, 2018 · 6 comments · Fixed by #5149
Closed

[css-inline] CSS properties appply to SVG elements #3411

dirkschulze opened this issue Dec 8, 2018 · 6 comments · Fixed by #5149
Assignees

Comments

@dirkschulze
Copy link
Contributor

Some of the properties in CSS inline apply to certain SVG elements as well. According to SVG2:

  • alignment-baseline to tspan and textPath elements
  • baseline-shift to tspan and textPath elements
  • dominent-baseline to text content elements
  • inline-sizing to text elements (at-risk for SVG 2)
  • line-height to text content elements (SVG2 actually misses to specify it) CC @AmeliaBR

Those are the properties currently covered by SVG's text algorithms. Some of the other properties in CSS inline layout should apply to certain SVG elements as well in the future.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jun 2, 2020

I'm working on these edits, per @fantasai's request (trying to clean up issues on CSS Inline for publication).

I'm trying to use the categories currently defined in SVG 2: text content elements (for any of text, tspan, and textPath), text content block element (text), and text content child element (tspan and textPath). I'm using the SVG 1.1 spec as reference for how properties were originally spec'd to apply to the SVG elements.

But, it seems we have some inconsistencies between what the spec said and what browsers did. Also, dominant-baseline and alignment-baseline have been changed so much compared to the SVG 1 spec already that it isn't entirely relevant.

  • baseline-shift: SVG 1 says child elements only, but Chromium (and probably WebKit???) supports it on text and Firefox doesn't support at all.

  • alignment-baseline is defined to align the current element relative to it's parent so it should logically only apply to child elements, and that's how it was defined in SVG 1. But again, Chromium supports it on text to change the alignment relative to the SVG text anchor point, and Firefox doesn't support it at all.

  • dominant-baseline everyone (SVG 1, Chromium, Firefox) agrees applies to all text content elements.

CodePen tests

So, I'm spec'ing all three to apply to all text content elements unless there is a strong objection and/or my guess is wrong about WebKit and Chromium matching here. There's no reason not to let baseline-shift and alignment-baseline apply to SVG <text> since there is still a clear reference point to measure alignment against.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jun 2, 2020

inline-sizing to text elements (at-risk for SVG 2)

The inline-sizing property in CSS inline is different from the inline-size property in SVG 2, which was defined as an extension of the inline-size property in CSS Logical Sizing.

Now that CSS Logical Sizing is stable, should probably edit the SVG spec to reference it, but as for CSS Inline and the inline-sizing property, that's just an unfortunate name (any chance to still change it?)

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jun 2, 2020

line-height to text content elements (SVG2 actually misses to specify it)

The SVG 2 prose is:

SVG uses the line-height property to determine the amount of leading space which is added between lines in multi-line text (both for horizontal and vertical text). It is not applicable to text on a path.

Firefox is the only browser that has implemented line-height in SVG text content (for pre-formatted line breaks), and they support it on <textPath>, which seems logical enough for me. Probably should be an issue on the SVG spec.

AmeliaBR added a commit to AmeliaBR/csswg-drafts that referenced this issue Jun 2, 2020
Closes w3c#3411
See issue for discussion/reasoning & differences from SVG 1.

Bikeshed error that needs fixing:
the “current text position” definition from SVG text
is not being exported in a way that Bikeshed is picking up,
even with hints about which spec to look for it in.

Changes should be copied over to css-inline-4
after review.
@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jun 2, 2020

See #5149 for edits

AmeliaBR added a commit to AmeliaBR/csswg-drafts that referenced this issue Jun 10, 2020
Closes w3c#3411
See issue for discussion/reasoning & differences from SVG 1.

Changes should be copied over to css-inline-4
after review.
fantasai pushed a commit that referenced this issue Jun 10, 2020
Closes #3411
See issue for discussion/reasoning & differences from SVG 1.

Changes should be copied over to css-inline-4
after review.
@fantasai
Copy link
Collaborator

fantasai commented Jun 10, 2020

@AmeliaBR Yeah, file an issue on the naming if you have a better alternative. :) I don't like it much either. As long as the TTML folks don't have an objection, we can rename.

Wrt applying baseline-shift and alignment-baseline to text elements, sounds good to me. Merged your changes.

@AmeliaBR
Copy link
Contributor

as for CSS Inline and the inline-sizing property, that's just an unfortunate name (any chance to still change it?)

file an issue on the naming if you have a better alternative

Done in #5189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants