Skip to content
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-4] Which type of font family names are system font names? #9292

Closed
cdoublev opened this issue Sep 1, 2023 · 7 comments
Closed
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-fonts-4 Current Work

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Sep 1, 2023

Are they generic family names?

There are two types of font family names:

  • <family-name> [...]
  • <generic-family> [...]

https://drafts.csswg.org/css-fonts-4/#font-family-prop

Or a separate type? About <family-name># in the prelude of @font-feature-values:

[...] rules that include generic or system fonts in the list of font families are syntax errors

https://drafts.csswg.org/css-fonts-4/#font-feature-values-syntax

FF currently accepts @font-feature-values caption {} whereas caption is a system font, probably because it wants a <family-name> that does not match <generic-family>, which does not explicitly include system font names.


aside

font-family: caption is valid, but it has no effect, therefore it maybe a bit misleading to say this:

That is why this property is "almost" a shorthand property: system fonts can only be specified with this property, not with font-family itself

https://drafts.csswg.org/css-fonts-4/#font-prop

@cdoublev cdoublev added the css-fonts-4 Current Work label Sep 1, 2023
@cdoublev
Copy link
Collaborator Author

cdoublev commented Sep 4, 2023

Would it be acceptable to define <system-font> as a third type. <system-font> would be linking to its definition below the font-family propdef table.

- The following values refer to system fonts: [...]
+ The following values refer to <system-font>` names: [...]

<system-font> could then be used as a ref for its name values and in the value definition of font-family.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Sep 5, 2023

About <family-name># in the prelude of @font-feature-values:

[...] rules that include generic or system fonts in the list of font families are syntax errors

I suspect system fonts should have been replaced by installed fonts in e208889, and it should even be entirely removed like in 3d1ac3c.

But then I wonder if a system font name should be parsed as a valid <family-name> in:

  • font-family for @font-face: there is currently no restriction
  • font-family for @font-palette-values: generic fonts are currently syntax errors
  • the prelude of @font-feature-values: generic fonts (at least) are currently syntax errors

I think <family-name> generally excludes generic font names and system font names, but only in font-family for a style rule:

Any identifier which could be misinterpreted as a pre-defined keyword in the font-family value definition, or the CSS-wide keywords, is not allowed.

https://drafts.csswg.org/css-fonts-4/#family-name-syntax

I suspect it should exclude all pre-defined keywords, regardless of the context in which it appears.

@svgeesus
Copy link
Contributor

This means that only named font families are allowed; rules that include generic or system fonts in the list of font families are syntax errors.

That clearly means that we need this third type, so it can be explicitly excluded.

@svgeesus
Copy link
Contributor

svgeesus commented Oct 4, 2023

@cdoublev please have a look at

2.1. Font family: the font-family property
and
2.1.3 Syntax of <system-family-name>

to let me know if this is headed in the right direction? I think it is clearer now, defining the three types of font family in one place rather than burying one under the font shorthand. I'm not done, but would value a sanity check.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 5, 2023

Looks good, thanks. These clarifications are very helpful.


<<'system-family-name'>> should be <<system-family-name>> in font value definition.

I think this is new:

<system-family-name>: [...] it may not be used with the font-family property [...].

But it seems to be matching browser expectations, so I think this is intentional.

edit: I mean, el.style.fontFamily = 'caption' is currently valid in Chrome/FF (without this change), but the font is not used.

@svgeesus
Copy link
Contributor

svgeesus commented Oct 5, 2023

It is new, because the font-family property defines three tokens and allows two of them; it seemed necessary to say why the third one was there.

The older text from which one might infer this is still there:

System fonts can only be set as a whole; that is, the font family, size, weight, style, etc. are all set at the same time. These values can then be altered individually if desired. If no font with the indicated characteristics exists on a given platform, the user agent should either intelligently substitute (e.g., a smaller version of the caption font might be used for the small-caption font), or substitute a user agent default font. As for regular fonts, if, for a system font, any of the individual properties are not part of the operating system’s available user preferences, those properties should be set to their initial values.

That is why this property is "almost" a shorthand property: system fonts can only be specified with this property, not with font-family itself, so font allows authors to do more than the sum of its subproperties. However, the individual properties such as font-weight are still given values taken from the system font, which can be independently varied.

Note that the keywords used for the system fonts listed above are only treated as keywords when they occur in the initial position, in other positions the same string is treated as part of the font family name:

Although the grammar of the font shorthand now uses the <system-family-name> token rather than inlining a list of names.

@svgeesus svgeesus added Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. Closed Accepted by Editor Discretion labels Oct 6, 2023
@svgeesus svgeesus closed this as completed Oct 6, 2023
@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 6, 2023

<<'system-family-name'>> should be <<system-family-name>> in font value definition.

Can you please fix this? <<'system-family-name'>> is referencing an unknown system-family-name property.

LINK ERROR: No 'property' refs found for 'system-family-name'.

(Bikeshed error report)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-fonts-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants