w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.47k stars 659 forks source link

[css-fonts-5] Consider 'extends' descriptor to reduce duplicate declarations #6104

Open fantasai opened 3 years ago

fantasai commented 3 years ago

CSS Counter Styles has an extends descriptor that basically copies all the descriptors of a different @counter-style rule and lets this @counter-style rule override specific ones rather than repeating them all. See https://www.w3.org/TR/css-counter-styles-3/#extends-system

It might make sense to copy that system over to @font-face, to make it easy to tweak the definitions of a common font face into multiple variants?

svgeesus commented 3 years ago

Avoiding the maintenance headache of almost-the-same descriptor blocks sounds good in principle.

Should that be added as a general feature of @-rules or is it okay to just define it in @counter-style and @font-face (and potentially @ont-feature-values and @font-palette-values )?

svgeesus commented 3 years ago

As a very weak counter-argument, SVG at one time had a feature in gradients to make them extend other gradients; which could lead to lengthy chains of gradients extending other gradients extending other gradients, and was not liked by implementers especially when animated.

(Of course, descriptors can't be animated)

tabatkins commented 3 years ago

I don't think this should be a general feature; it's additional impl complexity that isn't particularly needed for most rules. But font-faces do the "multiple at-rules that are nearly identical" thing a lot more than counter-styles do, especially as we add more of these controlling descriptors.

astearns commented 3 years ago

Is there any evidence that authors have found descriptor duplication in font-face rules annoying enough to have created tooling for this case?

faceless2 commented 3 years ago

There was none found for https://github.com/w3c/csswg-drafts/issues/3691, which was something I floated a while back that had a similar goal.

css-meeting-bot commented 3 years ago

The CSS Working Group just discussed [css-fonts-5] Consider 'extends' descriptor to reduce duplicate declarations.

The full IRC log of that discussion <dael> Topic: [css-fonts-5] Consider 'extends' descriptor to reduce duplicate declarations
<dael> github: https://github.com/w3c/csswg-drafts/issues/6104
<dael> fantasai: The @counter-style rules can get complicated. @extend lets you go off previous definition. As @font-face gets more complicated might be might to have same mech so a font-face rule can extend another one and add some descriptors
<dael> myles: I think I agree with astearns comment where we should wait for things like Sass to come up with it. A bit early to add b/c don't know we need it
<dael> astearns: And a lot of things we're adding to complicate rule are for specific fonts and not really shared. Don't want to get to state where someone uses a value they tested on one font on a lot where they don't know correct
<dael> fantasai: Yeah. When have variable font youll have a bunch of common stuff to core. might want to set some things to set named variants
<dael> astearns: Agree probably useful for variation fonts, but should wait until we know it'll be used
<dael> leaverou_: May not have seen sign complaints b/c authors copy/paste generated @font-face rules. Duplication is there
<fantasai> +1
<dael> myles: I understand we're discussing this bc adding rules. If we give them time to start using new things we'll hear noise about needing this. If not nec we won't
<dael> Rossen_: Hearing folks leaning toward waiting to see how and when it's needed
<dael> Rossen_: We'll put this on pause until have stronger signals