[css-font-loading] family name parsing note

I think it might be a good idea to add a note about the parsing of font
family names in Section 2.1. The spec currently defines the parsing of
the family argument to the FontFace constructor as:

  Parse the family argument, and the members of the descriptors
  argument, according to the grammars of the corresponding
  descriptors of the CSS @font-face rule.

This is fine I think but the current Chrome implementation treats the
family argument as if it was already quoted, such that the assertion
below will fail:

  var f1 = new FontFace("@blah", "url(x)");
  assert(f1.status == "error"); // @blah is not a valid name unless quoted

Suggested note:

As with font family names within @font-face rules, the family argument
is a single font family name. It can be unquoted or quoted and it cannot
be a generic font family name (e.g. sans-serif).

Test examples:

  var f2 = new FontFace("'simple'", "local(Georgia)");
  assert(f2.status == "unloaded");

  document.fonts.add(f2);
  document.fonts.load("simple");
  assert(f2.status != "unloaded"); // simple == 'simple' so f2 should be
loading

Regards,

John Daggett

Received on Friday, 27 March 2015 02:35:34 UTC