Saturday, 22 June 2019

Re: shortcut "font" in CSS

On 22/06/2019 19:09, Jim Nagel wrote:
> Does the shortcut version of the "font" property in CSS work properly in
> Netsurf?

Yes, it does. You can find extensive test data at [1].

> This CSS gives me the display I want:
> font-family: serif;
> font-style: italic;
> font-weight: bold;
> font-size: 24pt;
>
> This single CSS expression is supposed to be equivalent, but Netsurf
> ignores it:
> font: serif italic bold 24pt;
>
> Or am I failing to understand the spec?

I'm afraid so. The spec[2,3] says that (assuming none of the
single-token values are specified -- e.g. caption or inherit):

* font-style, font-variant, font-weight appear first (in any order), if
required
* font-size comes next (and is always required)
* an optional line-height may be specified next
* font-family appears last

So, given the long-hand you have specified above, you want something like:

font: bold italic 24pt serif;


J.

1. https://git.netsurf-browser.org/libcss.git/tree/test/data/parse2/font.dat
2. https://www.w3.org/TR/CSS21/fonts.html#font-shorthand
3. https://www.w3.org/TR/css-fonts-3/#font-prop

No comments:

Post a Comment