W3C home > Mailing lists > Public > www-style@w3.org > November 2015

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

From: John Daggett <jdaggett@mozilla.com>
Date: Tue, 10 Nov 2015 14:43:34 +0900
Message-ID: <CALYZoVPt_SrFhNfd=6GpuiOJNnprf+G8Zdqp1k-LfdS6-bQ3EQ@mail.gmail.com>
To: Ryosuke Niwa <rniwa@apple.com>
Cc: www-style list <www-style@w3.org>
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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:58 UTC