[css-font-load-events] Completed first draft of redesign, feedback requested

Heya everyone!  Since John didn't have the time to work on Font Load
Events and update it to the Tokyo consensus, I took it over at his
request.  I started working on the redesign last Friday, and completed
the first draft of it last night:
<http://dev.w3.org/csswg/css-font-load-events/>

This draft reflects the Tokyo consensus, and goes a bit further in an
attempt to address some of the issues that John left in his draft.
I'll outline the functionality:

1. I've introduced FontFace objects.  @font-face rules generate these
automatically, or they can be constructed manually from a url or an
ArrayBuffer (hi, pdf.js! you're welcome!).  These serve mostly the
same function as a CSSFontFaceRule, except they host some additional
useful functions, and they have no link into the document or the
stylesheet, and thus are safe to expose on Workers.  (I haven't filled
in all the details yet, but they'll be structured-cloneable, so the
document can ship fonts to its workers via postMessage().)

2. FontLoader has been changed into FontFaceSet, approximately in line
with my blog post on the subject: <http://www.xanthir.com/b4PV1>.  The
fonts in the FontFaceSet are the ones that the user agent has access
to. It's prepopulated with all the FontFaces from @font-face, but you
can add your manually-constructed ones too.

3. The events have been reduced.  I've kept "loading" and
"loadingdone", and added "loadingerror".  loadingdone and loadingerror
fire at the same time, and provide an array of the font faces that
have been successfully or unsuccessfully loaded since the last time
the document was stable.

4. The missing per-font events have been translated into a ready()
function on the individual FontFace objects which returns a Promise
representing their load status, and the notifyWhenFontsReady()
function has been replaced with a ready() function on FontFaceSet
which fulfills when there are no fonts loading.

5. In the spirit of "expose the primitives and add sugar, rather than
magic", I've exposed the font matching algorithm directly, as a
function on FontFaceSet and a (not yet filled in) function on
individual FontFaces.  This dramatically simplified the load() and
check() methods, which was nice. ^_^

That's about it, aside from minor tweaks and rewordings of lots of it.

Review?  Chrome is planning to start implementing *soon* (we've been
chomping at the bit for this), so getting your comments in sooner
rather than later makes it a lot more likely they can actually be
addressed.

~TJ

Received on Thursday, 5 September 2013 18:28:24 UTC