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: Fri, 25 May 2012 00:27:47 -0700 (PDT)
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style@w3.org, Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Message-ID: <492844022.20675423.1337930867827.JavaMail.root@mozilla.com>
Tab Atkins Jr. wrote:

> > What about the event target? How will you add the event listener?
> > Doing it on the document is simple. On a font at-rule, that's
> > considerably harder for web authors because of CSSOM complexity...
> 
> Boris provided a good reason why firing it at the @font-face rule is
> unusable in common situations - you won't be able to attach a
> listener to cross-domain resources.
> 
> I suppose that means that firing it at the document is necessary,
> but the difficult then is figuring out which @font-face it was for. 
> I guess the event object would just have to have a property that's a
> dict of all the descriptors on the rule.

I think there are two separate but related features here.  One is a
way to explicitly start the load of a given font, either directly or
indirectly.  The other is a way to figure out when the font(s) have
finished loading.

Explicitly loading a font is hard because fonts are loaded based on
the contents of some element that uses a given font family.  The style
matching algorithm determines the specific face to be loaded.  And
after the font loads *another* font might be needed if a given
character isn't supported by a character within the text run using
that font. You could define manual loading of individual @font-face
rules but it would still be tricky in some cases to know which ones
are needed, especially if descriptors like unicode-range are used.

Figuring out when loading is complete is I think a more important need
at this point. One possibility is a load transition event with an API
to determine if other fonts are still being loaded, so that you'd have
an easy way to determine the "done loading all fonts" case, which covers
several of the use cases noted (but not all).

Cheers,

John Daggett
Received on Friday, 25 May 2012 07:28:20 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT