Re: [csswg-drafts] [css-fonts-4] font-display says it's valid in @font-feature-values but it isn't an at-rule (#2973)

...oooh, that's a good idea. Hm.

How about this?

```
@partial font-face {
 ...
}
```

The `@partial` rule looks identical to a normal at-rule, just with the normal at-rule's name pushed forward as a plain ident and `@partial` being the name instead. It otherwise has the same syntax as the extended at-rule; additional prelude comes after the ident, etc. (So, for example, counter styles would be extended with `@partial counter-style foo {...}`.)

At-rules have to define that they're extensible; it's expected that every "closed" at-rule will be. They must define precisely how to match themselves against the "main" at-rule: for example, `@partial counter-style` is matched according to the counter style name; `@partial font-face` is matched according to the `font-family` descriptor and the various styling descriptors that are relevant for matching, so it extends all compatible `@font-face` rules.

All the `@partial` rules are collected and merged in order of appearance, as usual. They extend whichever version of the "main" rule that won the cascade (for all existing ones, this is just the last one). Relative ordering of @partial vs "main" rules is unimportant; the winning partial declarations are all ordered after the "main" declarations.

Worked out example:

```css
@partial counter-style foo {
  prefix: "pre";
  suffix: "post";
}

@counter-style foo {
  system: cyclic;
  symbols: A B C;
}

@partial counter-style foo {
  suffix: "after";
  negative: "neg";
}

@counter-style foo {
  system: alphabetic;
  symbols: A B C;
  prefix: "before";
}
```

This is equivalent to:

```css
@counter-style foo {
  system: alphabetic;
  symbols: A B C;
  prefix: "pre";
  suffix: "after";
  negative: "neg";
}
```

-----

For font-face, the following would extend all faces of the "foo" family with a  font-display value:

```css
@partial font-face {
  font-family: "foo";
  font-display: optional;
}
```

If you wanted to only extend the bold faces, you could do:

```css
@partial font-face {
  font-family: "foo";
  font-weight: bold;
  font-display: optional;
}
```

--------

Thoughts?

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2973#issuecomment-442167124 using your GitHub account

Received on Tuesday, 27 November 2018 18:32:11 UTC