I was struggling with sIFR yet again this morning, an odd WSOD in IE7 and other problems. John Haas showed me Cufón as a replacement, and I was quickly impressed with its potential. The project promises cross-browser compatibility with no plug-ins (bye, bye, Flash!), as well as being fast and easy.
Image Replacement with Cufon!
So I gave it a whirl. At first, I opened a feature request at the Dynamic Rendering module to add support, at the same time digging into the module to see what I would need to add for this new plugin.
However, in the end, I decided the approach was too heavy handed. All I needed to do was add a couple of (very small) scripts to the theme.
First, you need to download the cufon-yui.js script. Then you'll take your TTF or OTF font and run it through the provided generator, resulting in a small (<26kb) script that embeds your font (such as A_Charming_Font_400.font.js in this example).
I just dropped the required javascripts into the theme folder, and modified the theme's info file:
scripts[] = cufon-yui.js scripts[] = A_Charming_Font_400.font.js scripts[] = mytheme.cufon.js
And finally drop something like the following in the new mytheme.cufon.js script referenced above. (Just use jQuery selectors for this part.) You can look in the generated javascript if you're not sure what fontFamily to replace.
if (Drupal.jsEnabled) {
$(document).ready(function() {
Cufon.replace('h2.title', { fontFamily: 'A Charming Font' });
Cufon.replace('#big-title', { fontFamily: 'A Charming Font' });
// Note you can add other generated fonts as well, such as below...
Cufon.replace('#fancy-title', { fontFamily: 'Some Other Font' });
});
}
That's it! No flash required, no "flash of screen" associated with sIFR. It just works. (And did I mention fast?)
very nice
We're considering using drupal for a new electrical business that we are starting here in New Zealand. This has helped cement my ideas about it. Thanks!
I'm having theming problems, could you explain how you themed yours? Mine is here - http://iommo.com/feature and it's really bare bones. Thanks for a great demonstration!
@Danny Concannon, you've never sat beside someone who knew nothing about the things you do, and watched them try to post something/anything on Drupal, have you?
I wish this was available for D6.
thank you so much for posting about this. Amazing mess of modules to do this but awesome recipe! Soooo glad that someone's taking advantage of the new file api in 7 and even in quickly playing with it this is going to make upgrading to D7 a must for us. Sooo much better media integration and sets up for better resource management similar to Apture's simple way of getting web 2.0 content sources into 1 area. Love the way your doing this, keep up the great work.
I may have to look into writing a plugin to suck data in from other sources like Vimeo, Picasa, Scribd.