IE9 officially supports the new WOFF format for embedding webfonts. And there was much rejoicing. But, the question that’s been nagging away at me has been: how do we as web developers account for IE’s legacy EOT format while giving preferential treatment to the emerging WOFF standard?
The short answer is: keep using Paul Irish’s bulletproof smiley syntax. WOFF will be loaded by browsers that understand it, and legacy IE versions (8 and under) will load EOT.
The long answer: every src declaration within the @font-face block effectively resets the CSS parser’s attempt to find the appropriate font file. The rendering engine will use the first viable font source in the last src declaration inside each @font-face block. Paul Irish’s smiley syntax works perfectly here, since the first src declaration is only understood by IE < 9 (due to the EOT format), while the second src declaration is understood by >= IE9 and all other good browsers.
This produces a win-win situation. Good browsers that aren’t IE ignore the first src declaration because EOT is not viable to them. IE9 prefers the second src declaration because it understands EOT.
I have a few test cases to view. They’re also available on Github.
4 Comments
Thanks for the font insights Matt! I’ve been playing around with the font-face kits at http://fontsquirrel.com which appear to implement the methodology you are describing. They’ve been pretty solid.
Thanks Matt for digging into this. IE is finally maturing I guess.
Woot!
I will concede there is one flaw in the bulletproof syntax.
Android totally effs up and can’t handle the local() so it drops the whole declaration. As a result no fonts are downloaded and even tho the browser does indeed support webfonts, it doesn’t support the bulletproof syntax.
Personally, I think serving webfonts to mobile devices is a mistake, especially until the FOUT/invisible text situation is solved. The files are too damn large and prevent you from reading the body text for a long time.
So I’m perfectly fine with the Android bug. 🙂
@Ethan & @Peter You’re welcome!
@Paul Ah, didn’t know that about Android, good to know. I agree that in most cases mobile devices shouldn’t get webfonts, except maybe by using the WebFont Loader to emulate Firefox behaviour, and only with WOFF/TTF, not SVG due to lower sizes.