Re: [css3-fonts][cssom] Load events for webfonts?

Tab Atkins Jr. wrote:

> I couldn't find anything about this from a cursory search of the list.

Er, search with "load event font-face" perhaps?

There have been a few discussions of this in the past but figuring out
the details of the event and what it does is tricky.  I agree
completely that something like this is needed.

The subject often comes up in the context of canvas elements, which
can draw text but have no way of knowing whether a given font was
loaded before the drawing takes place.  This needed in other contexts
also where fonts need to be dynamically loaded (in Gecko, the onload
handler will wait fonts needed for text on the page to finish loading
but Webkit fires the onload handler before loads are complete).

dbaron's comment summarizing the Gecko bug for this:

> It looks to me (though I read it somewhat quickly) like consensus
> there was tending towards:
>  * events when fonts load
>  * an API to ask whether all the fonts for an element/document have
>    been loaded

The tricky part of this is that @font-face fonts load on demand and
which font in a family is loaded is determined by the style matching
rules.  So if the author defines four @font-face rules for regular,
bold, italic and bold italic but only the italic face is needed,
that's the only one that will be loaded (modulo EOT font load behavior
in pre-IE9 versions of IE which is not lazy).

I think the two API's above may be the simplest to implement.  I think
the "all fonts loaded?" API should be associated with the document,
since fonts are attached to the document not to specific elements.

Specific proposals for this would be most welcome.

Sept 2011 thread:
http://lists.w3.org/Archives/Public/www-style/2011Sep/0012.html
http://lists.w3.org/Archives/Public/www-style/2011Sep/0014.html

July 2009 thread:
http://lists.w3.org/Archives/Public/www-style/2009Jul/0066.html
http://lists.w3.org/Archives/Public/www-style/2009Jul/0204.html

Beth Dakin and I also talked about this during TPAC in 2010 but no
proposals came out of that.

We have an open bug on this with lots of discussion:
https://bugzilla.mozilla.org/show_bug.cgi?id=471915

Received on Friday, 25 May 2012 01:29:08 UTC