Re: [css-writing-modes][svg] Embedded SVG and inheritance

>From an SVG author's perspective, a ` svg { all: unset; } ` rule in the
default stylesheet would be very problematic; it would break current
content that uses SVG to style text within HTML (e.g., decorative headings)
with the expectation that the text styles are inherited.  It would also
throw off any sizing of the SVG using font-relative units.

On the specific issue of writing modes and layout, the desired behavior is
*either* to rotate the SVG to match the writing mode, or to inherit the
writing mode, but never both, since this would rotate the SVG text twice.

A case of when you would want to rotate the SVG would be a small inline
icon within latin rotated vertical text.  The same small icon within
upright vertical text would not be rotated.  A larger block SVG, such as a
chart, would also not be rotated.

I would therefore suggest the default should be *not* to rotate the SVG
contents.  However, there should be the *option* of rotating the graphic to
match the text, for both SVG and image inline icons or other small graphics.

I therefore propose there should be a new property that applies to block,
inline-block, and inline replaced content elements, to define how that
element's layout properties should be computed relative to the page layout:
 possible names would be `layout-orientation` or `content-orientation`.

The main options would be the same as `text-orientation`: upright |
sideways-right | sideways-left | sideways .  However, there would be a new
option, `context` or `use-text` or something equivalent, which would say to
use the parent element's writing mode and text orientation to determine how
this element will be laid out.

The current prose statement in CSS Writing Modes about which content should
rotate by default would be redefined in terms of this new property.  So,
`<math>` would have layout-orientation: context in the default stylesheet,
but <img> and <svg> would have layout-orientation: upright.  But the author
could over-ride either as required.

This still leaves the question of what to do with `writing-mode`.  I would
lean towards letting it inherit as normal, and requiring authors to
over-ride as they wish.

Amelia BR

On 7 May 2015 at 13:19, fantasai <> wrote:

> On 05/07/2015 01:14 AM, Jonathan Kew wrote:
>> On 7/5/15 05:22, Koji Ishii wrote:
>>> Not sure where to post cross-WG thing, IIUC cross-posting is not
>>> recommended, so let me start here.
> Cross-posting is totally fine, when it's a legit thing that should
> be discussed in both groups. :)
>  An issue was brought up asking whether SVG viewBox is logical or
>>> physical when containing HTML has writing-mode: vertical-*. I think
>>> this is easy -- physical -- and should be confirmed at www-svg if
>>> needed.
>>> But then checking CSS Writing Modes brought up a couple of CSS questions.
>>> 1. Is SVG "images" or "content involving text"?
>>> CSS Writing Modes defines[1]:
>>> * The content of replaced elements do not rotate due to the writing
>>> mode: images, for example, remain upright.
>>> but then defines:
>>> * However replaced content involving text (such as MathML content or
>>> form elements) should match the replaced element’s writing mode and
>>> line orientation
>>> I suppose SVG belongs to images rather than "involving text" here even
>>> if SVG contains text.
> Yes, I think it should probably be treated as an image. We'll
> want to clarify that in the spec.
>  2. Does writing-mode: vertical-rl in HTML inherits to SVG?
>>> [...]
>> ... I agree it might be better to avoid this, as the svg image as a
>> whole does not rotate. While there may be some cases where an author
>> would want the text within an svg image to respond to the document's
>> writing mode, this seems unlikely to be widely useful.
>> Perhaps we should simply add
>>    svg { writing-mode: initial; }
>> to the UA stylesheet? Then an author who *does* want the outside
>> writing-mode to apply to text within the svg can still use
>> "writing-mode: inherit" to achieve this.
> It seems to me that this is a broader problem than just writing-mode.
> Should 'font-variant: small-caps' inherit into an SVG? What about
> 'text-emphasis'?
> It might just make sense for the UA style sheet to include
>   svg { all: unset; }
> and then make a per-property exception if necessary for some very
> specific reason, e.g.
>   svg { all: unset; color: inherit; }
> if we want 'color' to inherit by default.
> The place to make this change would be
>   * informatively in CSS Cascade Level 3 (as an example appendix)
>   * normatively in the appropriate SVG specs
> ~fantasai

Received on Thursday, 7 May 2015 19:41:13 UTC