- From: Dave Crossland <dave@lab6.com>
- Date: Wed, 7 Jan 2009 12:55:43 +0000
- To: "www-style@w3.org" <www-style@w3.org>
- Cc: "Ed Trager" <ed.trager@gmail.com>
Hi, This thoughtful email came up on the OpenFontLibrary.org mailing list, and I thought I would forward it here :-) 2009/1/7 Ed Trager <ed.trager@gmail.com>: > Hi, everyone, > > It would be nice if there were a way to query the browser (using > Javascript) about whether web fonts are supported or not. If that > were possible, then a web site like the new OFLB site could > dynamically show the web font preview when supported, and hide it from > view when not supported. > > The Javascript would be trivial to write but my investigation so far > has not revealed any way of detecting web font support. > > It is a common "best practice" principle when coding in Javascript > nowadays to check for the existence of certain properties. If the > property exists, then we can exploit the functionality whose presence > is implied by the presence of that property. If not, we can code > around it. > > So perhaps we need to encourage the browser developers to expose a > public property, or document such if it already exists: > > if( thisBrowser.supportsWebFonts ){ > myWebFontDiv.style.display="block"; > }else{ > myWebFontDiv.style.display="none"; > } > > While I agree that the new OFLB site needs to rally toward the future, > unfortunately it looks clunky to say "The text to the right should be > rendered in Font_xxxx thanks to web font linking with @font-face. If > you see a monospace font, your web browser probably does not yet > support this new web technology." > > On my laptop, I see DejaVu Mono Sans used in FF 3.0.5 for the > unsupported @font-face preview. The problem is, unless I look very > closely, I might actually think that I *have* got a preview of > "Font_xxx" --especially if "Font_xxx" is some kind of sans serif font > (like Puritan, for example)! > > If someone on this list has any ideas on how to check for @font-face > support using Javascript, please let all of us know about it. > > - Ed Trager
Received on Wednesday, 7 January 2009 12:56:23 UTC