Re: [csswg-drafts] [css-values] ch units shouldn’t cause font downloads (#3135)

The CSS Working Group just discussed `ch and font downloads`.

<details><summary>The full IRC log of that discussion</summary>
&lt;emilio> topic: ch and font downloads<br>
&lt;emilio> github: https://github.com/w3c/csswg-drafts/issues/3135<br>
&lt;emilio> florian: we have multiple viewpoints represented, but are they enough?<br>
&lt;emilio> TabAtkins: initial issue is that currently ch uses the advance of the 0 glyph, which means that if your first font doesn't have a 0 glyph you go down the list and trigger a download for the next font on the list<br>
&lt;emilio> ... so I agree that that's unfortunate<br>
&lt;emilio> ... one objection is that if zero is defined _and_ being used, might as well use it<br>
&lt;emilio> ... this brings in potentially stateful behavior. Whether or not the ch uses it depends on whether the dom contains a 0, or a user types it, etc<br>
&lt;emilio> ... so options are: (1) no change, ch triggers downloads<br>
&lt;emilio> ... (2) always rely on first available font<br>
&lt;emilio> ... (3) look at 0 if there, and accept it's a stateful behavior<br>
&lt;emilio> chris: I think there's a (4), which is switch from the 0 glyph for .notdef<br>
&lt;emilio> TabAtkins: does .notdef has a reasonable char?<br>
&lt;emilio> chris: it's the tofu<br>
&lt;emilio> fantasai: we chose 0 because in monospace we want the size of the font, and in a proportional font digits are usually monospace<br>
&lt;dbaron> (or with font-variant-numeric: tabular-nums)<br>
&lt;emilio> ... so it fullfills all our these requirements<br>
&lt;emilio> fantasai: switching to .notdef would be a degradation for most uses of ch<br>
&lt;jfkthame_> fantasai++<br>
&lt;emilio> ... so I think it's a bad idea<br>
&lt;florian> q+<br>
&lt;emilio> ... relying on only first available font is problematic because often there's a stack where you're mixing latin/cjk fonts, so I don't think it's a good idea either<br>
&lt;emilio> ... I have no problem with (3) because I think it's going to be very unusual<br>
&lt;emilio> ... to have a font that doesn't have a 0, and some stack font has a zero and doesn't get loaded until later<br>
&lt;emilio> ... european digits are used in pretty much every writing system<br>
&lt;emilio> ... and chances are the font that has the zero is going to load<br>
&lt;emilio> ... so I think the concerns that jfkthame has about triggering a reflow when someone types will be rare<br>
&lt;astearns> ack fantasai<br>
&lt;astearns> ack florian<br>
&lt;emilio> ... and the other options degrade the ch units<br>
&lt;fantasai> s/rare/very rare/<br>
&lt;emilio> florian: I think where the fonts at the top of the stack doesn't have 0 is reasonably typical<br>
&lt;emilio> ... and you want the font with the actual zero<br>
&lt;emilio> ... stack with latin first, japanese there, without the digits seems really unusual<br>
&lt;emilio> ... one way you could workaround it is using the first avail font is that first avail font is dependent on the space glyph<br>
&lt;emilio> ... so you could remove the space from the first font down the list<br>
&lt;emilio> q+<br>
&lt;astearns> ack dbaron<br>
&lt;emilio> ... I don't think using the first avail font will buy us anything<br>
&lt;emilio> dbaron: I wonder if the argument that (3) is not a big deal is because it happens really rarely doesn't apply to (1)<br>
&lt;emilio> astearns: yeah, the lack of the glyph is really rare, and having a font that hasn't downloaded yet would be even more rare<br>
&lt;emilio> iank_: can you clarify?<br>
&lt;emilio> astearns: the most common case for lacking of 0 glyph is subsetting, and you do that so that you can use that font and the rest of the stack to render content<br>
&lt;emilio> ... so it's common for that font to be used by the content<br>
&lt;emilio> dbaron: other thought is about impl complexity<br>
&lt;emilio> ... and that depends on what the rules for (1) and (3) actually are<br>
&lt;emilio> ... I think (3) requires that if you _do_ download the font you update the ch units<br>
&lt;emilio> ... which also applies to (1) because ch units is what triggered the download<br>
&lt;emilio> ... so I think the only difference in implementation between (1) and (3) is whether the download is actually triggered<br>
&lt;astearns> ack emilio<br>
&lt;emilio> TabAtkins: that's correct<br>
&lt;fantasai> emilio: Even though 3 is very rare, I think I'd rather do 1<br>
&lt;iank_> don't we have the complexity that fonts can be partially downloaded in the future?<br>
&lt;fantasai> emilio: when it happens, it's just terrible, if you have anything sized with ch it shifts when you type a character, that's terrible<br>
&lt;fantasai> emilio: I'd much rather do 1, I think<br>
&lt;fantasai> emilio: 2 I wouldn't be opposed to, but I think fantasai's arguments are compelling<br>
&lt;dbaron> I agree that (1) (current behavior) is the correct thing.<br>
&lt;fantasai> TabAtkins: if we're trying to go for 1, I wouldn't be comfortable resolving without Myles around, since he was opposed<br>
&lt;fantasai> florian: this is not unique to ch, we have same problem with ex units<br>
&lt;emilio> ... if you want ex that depends on x height of the first avail font which is the first one that contains the space<br>
&lt;emilio> ... so if the first one doesn't contain the space you do need to trigger the download<br>
&lt;emilio> ... unless we want to redefine all font units to not depend on fonts...<br>
&lt;emilio> ... I think we can't escape this problem entirely anyways<br>
&lt;emilio> ... and giving up on font units doesn't sound like a good idea<br>
&lt;dbaron> dbaron: not the em unit, but ex, ch, ic, etc.<br>
&lt;emilio> ... so we need one more person to resolve on (1)<br>
&lt;emilio> iank_: isn't there a feature to allow fonts to be partially downloaded?<br>
&lt;astearns> q?<br>
&lt;emilio> astearns: yeah so that would make it more common not to have a 0<br>
&lt;emilio> chris: related, is there anything on CSS that assumes that fonts are completely downloaded?<br>
&lt;emilio> TabAtkins: yeah, css-font-loaded has a boolean loaded<br>
&lt;emilio> chris: yeah, we need to talk about that<br>
&lt;emilio> fantasai: tristate?<br>
&lt;emilio> dbaron: I think I have memories of working with jdagget on the font downloading code when ex units are used<br>
&lt;emilio> astearns: seems on this issue we're at an impasse?<br>
&lt;emilio> florian: it seems like consensus is towards (1)<br>
&lt;emilio> chris: though myles doesn't like it<br>
&lt;emilio> astearns: I think I agree with myles<br>
&lt;TabAtkins> s/font-loaded/font-loading/<br>
&lt;emilio> ... I want to avoid the case where someone has set up their fonts so that multiple downloads are triggered just to find a character where we could return another value<br>
&lt;emilio> ... and update when the download occurs<br>
&lt;emilio> florian: how's different with ex units and space?<br>
&lt;emilio> astearns: agreed that it's not specific to ch but ch is more common and this is more likely to happen<br>
&lt;emilio> jfkthame_: and arguably it can be avoided by changing the font to contain a 0<br>
&lt;emilio> astearns: I think this should be an exceedingly rare case but I think we should avoid the download<br>
&lt;emilio> jfkthame_: because of the rarity I think we should have the correct behavior. Having an emoji font at the beginning of the font list is not that rare but not getting the ch unit right there seems very unfortunate<br>
&lt;florian> q+<br>
&lt;TabAtkins> And thus, that rules out #2<br>
&lt;emilio> dbaron: one counterpoint here is that part of what makes this condition extra rare is the "and the font doesn't get downloaded for anything else". If the ch unit triggers the download, it's likely the first thing to download the font<br>
&lt;emilio> ... and it might be that the benefit that we get from downloading the font earlier is bigger than the issue of triggering an unlikely download<br>
&lt;emilio> astearns: say you have a font stacks that has a "my ampersand font", "my emoji font" (unused), and "my content font"<br>
&lt;emilio> ... and the emoji font does have a 0<br>
&lt;emilio> ... so you download the emoji font _and_ your ch unit doesn't match what your content actually uses<br>
&lt;fantasai> emilio: Point dbaron was making was if we do 3, then emoji gets used, and your ch unit changes<br>
&lt;emilio> dbaron: but if we do (3) then emoji gets used and your ch unit changes<br>
&lt;emilio> astearns: in the scenario of (3) the content font would use the right ch unit (from the content font, when it loads content), but then if you use emoji or a 0 your ch unit changes<br>
&lt;emilio> fantasai: I don't think that's going to be a common case<br>
&lt;emilio> astearns: yeah this are all really uncommon things<br>
&lt;emilio> ... but I agree with myles that prioritizing reducing downloads over layout changes is the right call<br>
&lt;emilio> fantasai: we can also make it up to the UA<br>
&lt;emilio> ... make triggering downloads not required<br>
&lt;fantasai> emilio: but this wouldn't change to half an em<br>
&lt;astearns> q?<br>
&lt;fantasai> emilio: it would switch to a font lower in the stack<br>
&lt;florian> q-<br>
&lt;emilio> florian (before ^): we already have the language "if not practical, use half an em"<br>
&lt;astearns> ack dbaron<br>
&lt;fantasai> emilio: I don't think that the cases that Alan and Myles argued for, I'm with dbaron that actually triggering the download for ch unit is more likely to help performance than cause problems<br>
&lt;fantasai> emilio: because by the time you get to layout the text, the font may already be there<br>
&lt;fantasai> emilio: otherwise you need to do more layout work, takes up all the ch units<br>
&lt;fantasai> emilio: and likely also trigger the download by the time you et to the content of the websiet<br>
&lt;fantasai> emilio: so I think doing 1 is the right thing<br>
&lt;fantasai> emilio: and also the more sensible thing<br>
&lt;emilio> fantasai: so... strawpoll?<br>
&lt;emilio> TabAtkins: pick up in two weeks with myles on the call<br>
&lt;emilio> ... myles was very strongly against (1)<br>
&lt;emilio> ... so don't want to resolve without him<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3135#issuecomment-1204193554 using your GitHub account


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

Received on Wednesday, 3 August 2022 16:27:17 UTC