W3C home > Mailing lists > Public > www-style@w3.org > May 2012

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

From: John Daggett <jdaggett@mozilla.com>
Date: Thu, 24 May 2012 18:28:39 -0700 (PDT)
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
Message-ID: <1139760932.20584882.1337909319118.JavaMail.root@mozilla.com>

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:

July 2009 thread:

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:
Received on Friday, 25 May 2012 01:29:08 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:15 UTC