[Webkit-unassigned] [Bug 225790] document.fonts.ready is sometimes still resolved too quickly

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu May 13 17:28:31 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=225790

--- Comment #7 from Ryosuke Niwa <rniwa at webkit.org> ---
(In reply to Cameron McCormack (:heycam) from comment #6)
> Still, flushing here doesn't 100% solve the problem, since script could in
> theory do something like:
> 
> let fonts = document.fonts;
> document.write("<p>some content that would trigger a font load</p>");
> onload = function() {
>   fonts.ready.then(...)
> };

Right. It looks like the current spec seems to suggest that any @font-face rule which appears in a CSS will automatically adds a new entry to FontFaceSet of the document:
https://drafts.csswg.org/css-font-loading/#font-face-css-connection

This might be problematic given that this will end up loading all fonts regardless of whether they're used or not.

It still makes it ambiguous as to when @font-face rule will be added to FontFaceSet and what "status" should say in the intervening period. Namely, if all @font-face rules are defined in an external CSS resource, then there is no CSS-connected FontFace object at the time of accessing document.fonts above, which means that document.fonts.status will say loaded. Only when the stylesheet gets loaded, then do we find @font-face rules and therefore adds more entries to the font source.

Given that a new stylesheet content might be loaded at any moment while the document in question is loading, I don't think there is any reason to believe document.fonts.status will return a reliable information until load event is fired on the global object.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210514/e4b767c0/attachment.htm>


More information about the webkit-unassigned mailing list