[csswg-drafts] unicode-range and falling off the end of the font-family list (#7449)

litherum has just created a new issue for https://github.com/w3c/csswg-drafts:

== unicode-range and falling off the end of the font-family list ==
Consider content like this:

```
@font-face {
    font-family: MyCoolWebFont;
    src: url("someFontThatActuallySupportsTheLetterE.ttf");
    unicode-range: something that doesn't contain the letter e;
}
...
<div style="font-family: 'MyCoolWebFont';">e</div>
```

The relevant section of the spec is this: https://drafts.csswg.org/css-fonts-4/#cluster-matching

> 1. For each family in the font list, a face is chosen using the style selection rules defined in the previous section.
>        ....
> 2. If no font was found in the font list in step 1:
>        1. If c1 is a variation selector, ...
>        2. Otherwise, the user agent may optionally use system font fallback ...
> 3. If no font is found in step 2, use the matching sequence from step 1 to determine the longest sequence that is completely supported by a font ...

Step 1 clearly shouldn't select any fonts. The only one listed in the `font-family` list has a `unicode-range` that doesn't include the character being rendered. Okay.

Step 2.1 is clearly irrelevant.

Step 2.2 uses the term "system font" which is clearly wrong. "System font" is defined in [section 10.4](https://drafts.csswg.org/css-fonts-4/#system-font) as "the font which is used by the system-ui generic font family name."

Is step 2.2 allowed to use `someFontThatActuallySupportsTheLetterE.ttf`? It supports the letter e, and we fell off the end of the fallback list, where we're ostensibly allowed to use any font at this point.

When browsers have fallen off the end of the fallback list and they're trying to find some font to use, it's fairly common practice for browsers to use the first font in the fallback list as a hint, to try to find a used font that's as "close" to the hint font as possible. If the hint font itself supports the target character, then it seems not totally unreasonable to just use the hint font itself to render the character.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7449 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 2 July 2022 00:46:30 UTC