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] Computed value of font-feature-settings #8296

Open
jfkthame opened this issue Jan 10, 2023 · 3 comments
Open

[css-fonts] Computed value of font-feature-settings #8296

jfkthame opened this issue Jan 10, 2023 · 3 comments
Labels
css-fonts-4 Current Work

Comments

@jfkthame
Copy link
Contributor

The current text of CSS Fonts 4 seems to contradict itself here.

On the one hand, 6.12 says

Computed value: as specified

Suppose the specified value is

font-feature-settings: "abcd", "spqr", "abcd" 2;

Note that the "abcd" feature has been specified twice, first with the implied value of 1, and later with an explicit value of 2.

So what is the computed value of font-feature-settings? If it's "as specified", then it should be exactly this list of three features, including both entries for "abcd".

However, the text goes on to say, a few paragraphs later,

The computed value of font-feature-settings is a map, so any duplicates in the specified value must not be preserved. If the same axis name appears more than once, the value associated with the last appearance supersedes any previous value for that axis.

Currently, of the browsers I've tried, only Safari appears to do this, returning "spqr", "abcd" 2 from getComputedStyle; both Firefox and Chrome return the list "as specified" including the first (superseded) occurrence of "abcd".

We should confirm which behavior is wanted ("as specified" or "with duplicates removed"), and adjust the spec accordingly. (My inclination is to require the duplicate-removal behavior, as implemented in Safari, so that would imply Firefox and Chrome should fix their bugs here.)

(Note that the similarly-structured font-variation-settings property defines its computed value differently:

Computed value: the keyword 'normal' or a list, each item a string paired with a number

It then has similar text confirming that duplicates should be removed:

If the same axis name appears more than once, the value associated with the last appearance supersedes any previous value for that axis. This deduplication is observable by accessing the computed value of this property.

So maybe a similar computed value description should be used for font-feature-settings, instead of "as specified".)

@svgeesus
Copy link
Contributor

I agree that dups should be removed, as the spec says, so the fix here is to change "as specified" to "as specified, with duplicates removed as described below".

Does "a list" imply that the as-specified order is retained?

@jfkthame
Copy link
Contributor Author

Does "a list" imply that the as-specified order is retained?

I don't think it necessarily does (and the order should be unimportant).

In practice, a UA might want to sort the list (e.g. by binary value of tag) as part of its de-duplicating operation. I'm inclined to think it should be allowed (but not required) to do so.

the fix here is to change "as specified" to "as specified, with duplicates removed as described below"

While we're here, is the UA allowed/expected to normalize feature settings such that tags with the value 1 or on are serialized without an explicit value, and off is normalized to 0? That would be consistent with using the shortest form; but it means these aren't quite "as specified" in such cases.

@jfkthame
Copy link
Contributor Author

By the way, when you get to editing this, there's another issue with the existing text where it says:

However, the text goes on to say, a few paragraphs later,

The computed value of font-feature-settings is a map, so any duplicates in the specified value must not be preserved. If the same axis name appears more than once, the value associated with the last appearance supersedes any previous value for that axis.

This looks like it was copy/pasted from the corresponding text about font-variation-settings, but it's not appropriate to refer to "...the same axis name..." and "...value for that axis" here. The term "axis" is specific to variations, not features.

So this should read something like "...the same feature tag..." and "...value for that feature" instead.

@fantasai fantasai added the css-fonts-4 Current Work label Jun 1, 2023
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

3 participants