Thursday, September 25, 2008
A little more on font linking
I've just been playing with HTML font linking* using the info in the 2002 W3C Web Fonts Working Draft. Works beautifully. You specify the weight, style (regular/italic), and stretch (condensed/normal/expanded) - and off you go! For example:
@font-face {
font-family: "DejaVu Serif";
src: url("http://example.com/free-libre-font-files/dejavu-fonts-ttf-2.26/DejaVuSerif-Italic.ttf") format("TrueType");
font-weight: 400;
font-style: italic;
font-stretch: normal;
}
@font-face {
font-family: "DejaVu Serif";
src: url("http://example.com/free-libre-font-files/dejavu-fonts-ttf-2.26/DejaVuSerif.ttf") format("TrueType");
font-weight: 400;
font-style: normal;
font-stretch: normal;
}
body {
font-family: "DejaVu Serif", serif;
}
And by magic, regular and italic variants will be found and used. Note how the two @font-face at-rules have the same font-family value, thus grouping them as one typeface.
OK, it's a little bit of work, but the indirection gives scope for future flexibility. Just remember kids: always read the licence!
Browsers: Firefox 3.1 (font-linking build) and Safari 3.1 on OS X.
Labels: fonts w3c browsers

Comments (0)
ยป Post a Comment | Back to blog index