-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-fonts] Allow authors to redefine generic font families #10452
Comments
I once proposed to enable authors to redefine color keywords – and was told this was a bad idea. I believe this would be worse because it takes away power from users and hands it to authors. Although most originate in the Unix/Linux/X11 world, the (non-System) color keywords have universal definitions across browsers, both in theory and practice, whereas generic font family keywords, at least in theory, depend on OS and browser settings or defaults – in practice, it’s not always possible for users to choose different typefaces, or they can just do so indirectly via themes. Furthermore, is this proposal only about classic generic font keywords or also about those inside |
It’s not uncommon for proposals to get rejected for years before they get accepted, for a variety of reasons. E.g. inline
Web pages are already able to define their own fonts, and do so to great extent so that ship has sailed (more than two decades ago lol). This is about included UI components being able to read which fonts the page is using.
I think starting from generic font keywords is a good MVP, we can always extend it if the need arises. |
I might have read the proposal too hastily on a tired Sunday morning. |
If this was designed in parallel to custom color schemes in #9660, which would add the ability for author-overridden system color keywords, I guess it should not apply to generic font family keywords used in the |
@Crissov The actual use cases need access to the actual generic font families like But yes, the efforts to redefine existing keywords to express page-specific styles would benefit from more coordination. I was even thinking that keywords like Another thing I realized: if this is done via |
Background
Most websites define their own typography, yet currently UI components have no access to it. In many cases using the inherited font-family is ok, but for others it’s not. Examples:
We recently got access to the OS’s default font families (
ui-*
,system-ui
) which provide far better alternatives than the generic counterparts, and are in very widespread use. However, web pages typically define their own sans, serif, monospace, etc. fonts, and any UI library or component used within the page should have access to these, not just the OS defaults.This is part of a much broader problem around pages exposing their design tokens, but inspired from #9660 I figured maybe instead of trying to define a more general feature, paving the cowpaths and redefining some of the tokens that are already there may be the best course of action. As a bonus, this provides a nice fallback by default: if the page has not overridden these tokens, they simply have their default values.
Syntax
I imagine this would be part of the
@font-face
rule. However, simply allowing generic font families for thefont-family
descriptor is not a good solution. Authors typically want to link to their fonts normally, like:and then assign them to tokens as a separate step. Perhaps something like:
or:
A nice-to-have would be to be able to specify multiple generic font-families, so that e.g. authors can alias
sans-serif
andui-sans-serif
to the same font-family. Perhaps allowing multiple names onfont-family
could address this and remove the need for a separate rule entirely:The text was updated successfully, but these errors were encountered: