W3C home > Mailing lists > Public > www-style@w3.org > January 2012

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

From: John Daggett <jdaggett@mozilla.com>
Date: Wed, 11 Jan 2012 20:12:38 -0800 (PST)
To: Matthew Wilcox <elvendil@gmail.com>
Cc: www-style@w3.org, ACJ <ego@acjs.net>
Message-ID: <48de03c4-beb9-4b80-a506-99ef74f849f1@zimbra1.shared.sjc1.mozilla.com>
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

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.).


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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:09 UTC