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

Re: [css2.1] [css3-fonts] <family-name> ambiguous - partially quoted names allowed?

From: fantasai <fantasai.lists@inkedblade.net>
Date: Wed, 24 Mar 2010 01:12:14 -0700
Message-ID: <4BA9C95E.1030106@inkedblade.net>
To: Bert Bos <bert@w3.org>
CC: W3C Emailing list for WWW Style <www-style@w3.org>
On 04/22/2009 06:43 AM, Bert Bos wrote:
> On Tuesday 21 April 2009, Zack Weinberg wrote:
>> Mozilla has a bug report[1] requesting that this:
>>
>>    font-family: "lucida" grande;
>>
>> be treated as equivalent to this:
>>
>>    font-family: lucida grande;
>>
>> There is no formal grammar for<family-name>  and the prose does not
>> say whether some-but-not-all tokens of a family-name can be quoted.
>> Matter of fact, it doesn't really explain what the grammar is at all
>> - it just says that certain punctuation characters must be \-escaped
>> if they appear unquoted in a family-name.
>>
>> My preferred reading of the spec would disallow partial quotation,
>> but what I really care about as an implementor is that there be an
>> unambiguous, ideally formal, grammar for every nonterminal.
>
> Partially quoted names were not among the original use cases. Maybe it's
> possible to read the spec as syntactically allowing them, but it
> certainly doesn't define what they mean.
>
> The intent can, I think, be captured by this annotated grammar:
>
>    Value: [ [<family-name>  |<generic-family>  ] [ ,<family-name>  |
>      <generic-family>  ]* ] | inherit;
>    <generic-family>: serif | sans-serif | cursive | fantasy | monospace;
>    <family-name>: STRING | IDENT+;  /* see restriction below */
>
> where the restriction is that<family-name>  cannot be one of the single
> IDENTs serif, sans-serif, cursive, fantasy, monospace, inherit, default
> or initial.

Proposed changes:

Replace the paragraphs
   # If an unquoted font family name ... converted to a single space.
with the following text:

   | Font family names must either given quoted as strings_, or unquoted as
   | a sequence of one or more identifiers_. This means most punctuation
   | characters and digits at the start of each token must be escaped in
   | unquoted font family names.
   |
   | For example, the following declarations are invalid:
   |
   |   font-family: Red/Black, sans-serif;
   |   font-family: "Lucida" Grande, sans-serif;
   |   font-family: Ahem!, sans-serif;
   |   font-family: test@foo, sans-serif;
   |   font-family: #POUND, sans-serif;
   |   font-fmaily: Hawaii 5-0, sans-serif;
   |
   | If a sequence of identifiers is given as a font family name, the
   | computed value is the name converted to a string by joining all the
   | identifiers in the sequence by single spaces.
   |
   | To avoid mistakes in escaping, is recommended to quote font family
   | names that contain white space, digits, or punctuation characters
   | other than hyphens:
   |
   | body { font-family: "New Century Schoolbook", serif }
   | <BODY STYLE="font-family: '21st Century', fantasy">
   |
   | .. `strings`: http://www.w3.org/TR/CSS21/syndata.html#strings
   | .. `identifier characters`: http://www.w3.org/TR/CSS21/syndata.html#characters

(I would also suggest tucking the whole thing under the <family-name>
type definition.)

Note that this changes the prose to be more in line with the Appendix G
grammar, and thus introduces additional constraints that were not in the
prose before. Most of them are already honored by a majority of the UAs,
though. (Arron and I checked.)

> (The spec is not worded very well with respect to 'default'
> and 'initial', implying that it is somehow obvious that they are
> reserved, although it is only obvious if you've read CSS3 Values And
> Units...)

(This should have been addressed in the last publication.)

~fantasai
Received on Wednesday, 24 March 2010 08:12:49 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:25 GMT