[css3-fonts] Re: Adding a font to the current stack (smarter fallbacks)

Matthew Wilcox wrote:

> Can we get a way (or is there already a proposed way) to add a font
> on top of an existing font stack? It is tedious and a maintenance
> issue to have to re-declare entire font stacks throughout a
> stylesheet just because I want to use a different font on one
> particular element of the page.
> 
> e.g.,
> 
> html { font : 125%/1.3 MelbourneRegular, "Helvetica Neue", Helvetica, Arial, sans-serif; }
> 
> then later on I need to change a font for one particular paragraph
> and have to write:
> 
> #special {  font-family : LeagueGothicRegular, MelbourneRegular, "Helvetica Neue", Helvetica, Arial, sans-serif;  }

I think the right way to simplify this is with some form of variable
substitution.

For example:

@font-stack {
  name: FallbackStack;
  font-family: MelbourneRegular, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

#special { font-family: LeagueGothicRegular, FallbackStack; }

The substitution would occur at parse time and would only be expanded
within font or font-family property values (thus avoiding issues like
nested definitions).

I'm dubious of generalized list morphing super-syntax, that seems like
complete overkill in this particular case.

> I'm not sure it even needs a change of syntax or additional trigger.
> It just needs defining as what CSS ought to do when the current font
> stack has been exhausted - fall back to parent elements font stack.
> In other words, the default action could be inherit without breaking
> any existing sites (because the current default is to just flop over
> and use whatever the browser's got set as a default font, I think).

I think "fallback to parent" is not such a great strategy here, you're
in effect creating chained property values (i.e. the value of
font-family for a given element becomes it's value plus its parent,
plus its parent's parent, etc.).

Regards,

John Daggett

Received on Thursday, 12 January 2012 04:15:41 UTC