Re: [css-scoping] Scoping @font-face defined in shadow DOM

Ryosuke Niwa wrote:

> We would like to make a declaration of @font-face scoped to the shadow
> DOM in which it is defined and have a higher precedence over
> @font-face defined outside the shadow DOM.
>
> While not ideal, we think it's okay to let @font-face defined outside
> the shadow DOM to bleed into the shadow DOM since that is needed to
> support the common scenario of matching the style outside the shadow
> DOM.  We can solve this problem in the future by providing a mechanism
> to hide @font-face.

I don't know what precisely you're proposing here but @font-face rules
don't have "precedence", they don't override one another.

Example:

  @font-face { font-family: test; src: url(xxx.woff); }
  @font-face { font-family: test; src: url(yyy.woff); }

  <p style="font-family: test">Hello</p>

This produces a font family for which yyy.woff will be loaded first. After
it's loaded, if the font in yyy.woff doesn't cover all glyphs in content,
xxx.woff will then be loaded. The second @font-face rule is added to the
family.

So I think you need to define more precisely what you'd like here. Do you
want @font-face rules defined in the shadow DOM to be scoped to only affect
font usage within the shadow DOM? Define a separate FontFaceSet that
contains the @font-face rules in the DOM along with the ones in the shadow
DOM, with ordering in document definition order. That will have no affect
on @font-face rules in the DOM other than their load state.

> On the other hand, @font-face inside a shadow DOM overriding
> @font-face outside the shadow DOM will break one major feature of
> shadow DOM: style rules in a shadow DOM do not affect nodes outside
> the shadow DOM.  In particular, @font-face defined in one shadow DOM
> should not affect fonts used in another shadow DOM.

Here again, not sure what you mean by "overriding". @font-face rules
accumulate, they don't override. And how is any node affected outside the
shadow DOM's with whatever you're imagining?

​

Received on Tuesday, 10 November 2015 05:44:04 UTC