W3C home > Mailing lists > Public > www-style@w3.org > March 2015

[css-font-loading] tracking FontFace objects for loadingdone/loadingerror events

From: Cameron McCormack <cam@mcc.id.au>
Date: Wed, 18 Mar 2015 17:49:42 +1100
To: www-style@w3.org
Message-ID: <20150318064942.GD27130@wok.mcc.id.au>
The spec uses [[LoadingFonts]], [[LoadedFonts]] and [[FailedFonts]]
internal slots to track when loading, loadingdone and loadingerror
events are fired and with what details.


The only time that a “loading” event is fired at a FontFaceSet is when
one of the FontFaces in it has its status change to “loading”.  This
means that an event won’t be fired if a FontFace that is already
“loading” is added to the FontFaceSet.  For example:

  assert(document.fonts.status == "loaded");
  var f = new FontFace("test", "url(very-long-loading-font)");
  setTimeout(function() {
    assert(f.status == "loading");
    assert(document.fonts.status == "loaded");  // ?
  }, 1000);

Is this intended, or should adding the FontFace cause
document.fonts.status to become “loading” and f to be added to


When a FontFace that is in a FontFaceSet has its status updated to
“loaded”, it is added to the [[LoadedFonts]] slot.  Later, the contents
of that [[LoadedFonts]] slot are used as a value on the “loadingdone”
event.  The FontFaces in [[LoadedFonts]] are exposed on the
“loadingdone” event even if they have been subsequently removed from the
FontFaceSet.  For example:

  assert(document.fonts.status == "loaded");
  var f1 = new FontFace("test", "url(takes-5s-to-load)");
  var f2 = new FontFace("test", "url(takes-10s-to-load)");
  f1.loaded.then(function() {
    assert(f1.status == "loaded");
    assert(f2.status == "loading”);
    assert(document.fonts.status == "loading");
    assert(document.fonts.status == "loading");
    document.fonts.onloadingdone = function(e) {
      assert(e.fontfaces[0] == f1);  // ?
    assert(document.fonts.status == "loaded");

Is that intended?  Or should the FontFaces exposed on the event object
only be the ones that were in the FontFaceSet at the time its status
became “loaded”?


What is meant to happen when you add an already-“loaded” FontFace to a
“loaded” FontFaceSet?  My reading of the spec is that no events are
fired.  Is this correct, and intended?

Cameron McCormack ≝ http://mcc.id.au/
Received on Wednesday, 18 March 2015 06:50:09 UTC

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