Skip to content

[css-fonts-4] Is the fontFamily attribute parsed as CSS or not? #8154

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

Open
andruud opened this issue Nov 30, 2022 · 3 comments
Open

[css-fonts-4] Is the fontFamily attribute parsed as CSS or not? #8154

andruud opened this issue Nov 30, 2022 · 3 comments
Labels
css-fonts-4 Current Work

Comments

@andruud
Copy link
Member

andruud commented Nov 30, 2022

A few interfaces define a fontFamily attribute:

  1. CSSFontFeatureValuesRule, which defines a read-write attribute and says: "The list of one or more font families for which a given set of feature values is defined."
  2. CSSFontPaletteValuesRule, which defines a readonly attribute (which makes the following text useless, I think): "The fontFamily and basePalette interfaces are parsed according to the appropriate CSS property syntax."

In (1), it is not stated that we're invoking the CSS parser, so it's not clear how to handle "the list".
In (2), it is stated, but then it doesn't actually matter since the attribute is readonly.

In any case, we should probably avoid invoking the CSS parser per the consensus-ish seen in #3776.

If possible, we should just avoid the problem by making fontFamily readonly in all cases.

@drott said to CC the following on this issue: @litherum @jfkthame @svgeesus, but given #3776 maybe @tabatkins and @emilio also care about this.

@andruud andruud added the css-fonts-4 Current Work label Nov 30, 2022
@jfkthame
Copy link
Contributor

These attributes may contain a list of font families, not just a single family name; and therefore we need to know how that list is represented even if we're not having to parse it in a setter. This is different from the case of the FontFace constructor in #3776, as that deals with just a single family name.

So I think the statement that

The fontFamily and basePalette interfaces are parsed according to the appropriate CSS property syntax

serves to tell a reader of the attribute how to interpret the string that it gets, although maybe this could be expressed more clearly.

@svgeesus
Copy link
Contributor

@jfkthame do you have suggested clearer wording for that statement?

@tabatkins
Copy link
Member

Yeah, talking about parsing in that case doesn't make sense. They should be talking about serialization. If you don't want to elaborate too much on the serialization, just literally doing s/parsed/serialized/ will be correct without changing the level of detail.

Making font-family readonly if possible would probably be best, if we don't want to invoke the CSS parser. Otherwise we'll have to, hmm, invoke strictly split a string, then strip whitespace on the parts, before finally interpreting them as font-family names. A lot of trouble for something incredibly low-value to do in the first place!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-fonts-4 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants