22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

For example, here the font ’Robson Celtic’ is defined and referenced in a style<br />

sheet contained in an HTML document.<br />

<br />

<br />

<br />

Font test<br />

<br />

@font-face {<br />

font-family: "Robson Celtic";<br />

src: url("http://site/fonts/rob-celt")<br />

}<br />

H1 { font-family: "Robson Celtic", serif }<br />

<br />

<br />

<br />

This heading is displayed using Robson Celtic<br />

<br />

<br />

The style sheet (in the STYLE element) contains a CSS rule that sets all H1<br />

elements to use the ’Robson Celtic’ font family.<br />

A CSS1 implementation will search the client for a font whose family name and<br />

other properties match ’Robson Celtic’ and, if it fails to find it, will use the<br />

UA-specific fallback serif font (which is defined to exist [p. 210] ).<br />

A user agent implementing <strong>CSS2</strong> will first examine @font-face rules in search<br />

of a font description defining ’Robson Celtic’. This example contains a rule that<br />

matches. Although this rule doesn’t contain much font data, it does have a URI<br />

where the font can be retrieved for rendering this document. Downloaded fonts<br />

should not be made available to other applications. If no matching @font-face is<br />

found, the user agent will attempt the same match as a user agent implementing<br />

CSS1.<br />

Note that if the font ’Robson Celtic’ had been installed on the client system,<br />

this would have caused the UA to add an entry in the font database for the<br />

installed copy as described in the section on the font matching algorithm [p. 231]<br />

. The installed copy would have been matched before the downloadable font in<br />

the example above.<br />

CSS1 implementations, which do not understand the @font-face rule, will<br />

encounter the opening curly brackets and will ignore [p. 42] forward until the<br />

matching closing curly brackets. This at-rule conforms with the forward-compatible<br />

parsing [p. 35] requirement of CSS. Parsers may ignore [p. 42] these rules<br />

without error.<br />

Having the font descriptors separate from the font data has a benefit beyond<br />

being able to do font selection and/or substitution. The data protection and replication<br />

restrictions on the font descriptors may be much weaker than on the full<br />

font data. Thus, it may be possible to install the font definition locally, or at least<br />

to have it in a local cache if it occurs in a commonly referenced style sheet; this<br />

would not require accessing the full font definition over the Web more than once<br />

per named font.<br />

If a font descriptor is duplicated, the last occurring descriptor wins and the rest<br />

must be ignored.<br />

Also, any descriptors that are not recognized or useful to the user agent must<br />

be ignored [p. 42] . Future versions of CSS may allow additional descriptors for<br />

the purpose of better font substitution, matching, or synthesis.<br />

214

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!