Re: [css-font-loading] family name parsing note

On Thu, Mar 26, 2015 at 7:35 PM, John Daggett <jdaggett@mozilla.com> wrote:
> 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

Alternately, we could just define that the family argument is taken
literally (matching Chrome behavior).  I don't think there's really
any need to invoke the weird parsing rules we have for family names.

~TJ

Received on Thursday, 9 April 2015 00:55:49 UTC