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

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 22 Aug 2012 00:07:00 -0700
Message-ID: <CAAWBYDBuhU2V7mJYexvcr5OjU1ME7D4wAsWZL9UibRJXjXNbUg@mail.gmail.com>
To: John Daggett <jdaggett@mozilla.com>
Cc: www-style list <www-style@w3.org>
On Tue, Aug 21, 2012 at 9:43 PM, John Daggett <jdaggett@mozilla.com> wrote:
> Tab Atkins wrote:
>> Modified proposal based on advice on how to spec events properly:
>> [Constructor(DOMString type, optional FontFaceEventInit eventInitDict)]
>> interface FontFaceEvent : Event {
>>   readonly attribute DOMString? family;
>>   readonly attribute DOMString? src;
>>   readonly attribute DOMString? style;
>>   readonly attribute DOMString? weight;
>>   readonly attribute DOMString? stretch;
>>   readonly attribute DOMString? unicodeRange;
>>   readonly attribute DOMString? variant;
>>   readonly attribute DOMString? featureSettings;
>> };
> Just to be clear, the mechanics of this are that for every font loaded
> an event would fire containing the descriptor set for the @font-face
> rule that loaded?  Does it fire for both the src url() case and the
> src local() case?

Yes.  I think the wiki page makes this a little bit clearer - whenever
a source is chosen (or none of the sources prove adequate), the event
is fired.

> I think you need to define some way to determine whether other font
> loads are still pending, since a given page may require multiple fonts
> due either to style selection or character handling.  Given the lazy
> loading nature of downloadable fonts, just defining a simple load event
> is insufficient.
> With a "loads pending" attribute somewhere, the typical font handling
> logic would be:
> 1. Make changes that might cause a font load
> 2. Check to see whether font loads are pending
> 3. If necessary, wait for font loads to complete
> 4. Do stuff that requires the fonts to be loaded

I'm not handling this quite yet - for now, people can track whether
the fonts they care about have loaded or not by themselves.

> What's the error handling model here?  I think you need to define more
> details about what happens when a font load fails.

That's defined in the wiki page version - if the load fails (all
sources return something that's not a font), it still fires the event,
but the usedSrc attribute is null.

> Neither one of these sound like great ideas to me, it pushes all the
> style selection logic into script.  Better to have a method that loads
> the font for a given family/weight/style/stretch combination. Possible
> variations would be to also pass in the text in use and a separate
> version version that loads all fonts for a *family*.

Yeah, these sound pretty decent.

Received on Wednesday, 22 August 2012 07:07:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:20 UTC