[css3-fonts] font descriptor default values

>> This seems simple, but to really make this work you're going to need
>> four rules to cover each of the four common style variations -
>> normal, bold, italic and bold italic, since a single @font-face rule
>> only defines a single *face* within a family.
>
> The default value for font-weight and font-style is "all", or at least
> it was, has this been changed?

Yes, the latest editor's draft eliminates the use of 'all'.  The default
is instead 'normal'.

The way 'all' was defined in the CSS2 font spec has a number of
problems:

(1) It's *very* un-CSS like, the order of @font-face rules with
    different style settings can override previously defined faces in
    non-intuitive ways.  Consider a simple example:

@font-face { 
  font-family: MyFont; 
  src: url(A); 
  font-weight: bold; 
}

@font-face { 
  font-family: MyFont; 
  src: url(B); 
}

If the font-weight rule defaults to 'all', equivalent to defining
separate rules for all values of the descriptor, then you end up with
the second face completely overriding the first face.

(2) It breaks normal CSS style matching.  Consider another simple
    example, this time with the order specified so that the bold face is
    defined *after* the normal face:

@font-face { 
  font-family: MyFont; 
  src: url(B); 
}

@font-face { 
  font-family: MyFont; 
  src: url(A); 
  font-weight: bold; 
}

body { font-family: MyFont; font-weight: 900; }

One would expect the body text to be bold in this case, since MyFont has
a bold face. But it won't, because the first rule effectively generated
the rule below, meaning the body text will not use the bold face:

@font-face { 
  font-family: MyFont; 
  src: url(B); 
  font-weight: 900;
}

(3) It breaks how bolder and lighter work.  Using the font definitions
    in (2) above, consider this example:

body { font-family: MyFont; }
strong { font-weight: bolder; }
 .
 .
<p>This should be <strong>bold</strong></p>

One would expect the bold in the markup above to use the bold face but
it won't.  The first font defintion in (2) "filled" in the weight slots
for 500 and 600, so the contents of the strong tag will use a weight of
500 which maps to the normal face.  One wouldn't see bold until you have
several nestings of tags with bolder as their font-weight setting (i.e.
400 ==> 500 (normal) ==> 600 (normal) ==> 700 (bold)).

The 'all' default value just seems to make simple things *very*
complicated and forces users to always specify normal default values
(e.g. font-weight: normal) explicitly.  Given that most authors are
accustomed to using font properties only when setting "non-normal"
values, I think it's a whole lot simpler to simply have font descriptor
values default to normal.

WebKit implements @font-face using the 'all' value for font descriptors,
so I've written a testpage that illustrates the problems with this:

  http://people.mozilla.org/~jdaggett/font-face/fontfacewithall.html

Here's the output in PDF form, using WebKit latest:

  http://people.mozilla.org/~jdaggett/font-face/fontfacewithall.pdf

Cheers,

John Daggett
Mozilla Japan

Received on Thursday, 22 January 2009 04:46:09 UTC