Agaric Design Collective

Taking it to that level with cufon

Average: 5 (1 vote)
By Dan Hakimzadeh
on 30 Mar
2 comments

Key words and phrases

cufon, kick ass fonts, theming themeing ninja skillz, replace, sifr

Tags

Description

So you've got yourself a solid drupal theme, and now you're sitting back looking at your work and thinking that it's good, but it could still be taken to that level.

Well, replacing some titles, basically some h1s and h2s with custom rendered fonts is one way to get it there, and using cufon is the answer. Sure, you could use the Dynamic Rendering module and sifr and do pretty much the same thing, but c'mon, cufon just sounds cooler than sifr... and it'll only take you about ten minutes to do this

and we all know quick and easy is the answer...

step one
find a font file you want to use. http://dafont.com has a bunch of truetype fonts that are free

step two
you need to download the cufon-yui.js script (attached to this node, but it has a .txt extension you have to remove... also you can download the js from here -> http://cufon.shoqolate.com/js/cufon-yui.js)

step three
take your TTF or OTF font and run it through this generator (http://cufon.shoqolate.com/generate/), which will result in a small script that embeds your font (such as MYFONT_400.font.js ) (400 is the font weight FYI..)

step four
create a file called MYTHEME.cufon.js which has the following code in it

  if (Drupal.jsEnabled) {
    $(document).ready(function() {
      Cufon.replace('h1.title', { fontFamily: 'Gotham-Book' });
      Cufon.replace('h2.title', { fontFamily: 'Gotham-Book' });
      // Note you can add other generated fonts as well, to really take it to that level
      // Cufon.replace('#fancy-title', { fontFamily: 'Some Other Font' });
    });
  }

step five
now you should have three js files so add them to your theme folder, and modify your theme's info file and add:

  scripts[] = cufon-yui.js
  scripts[] = MYFONT_400.font.js
  scripts[] = MYTHEME.cufon.js

step six
crack open a frosty beverage (I have been enjoying Stone Brewery's IPA lately...), clear your cache, or just goto the Theme Selection page and resave it so that your new .info file gets used, and behold, your site just got taken to that level the agaric way

can't forget the source...
http://aaronwinborn.com/blogs/aaron/cuf%C3%B3n-alternative-sifr-image-re...

 

I prefer signwriter...

Depending on the site, Signwriter is often a better answer: it does the font rendering on the server side and caches it, so you have more control over the look/font/etc. It still puts the original text there, for SEO purposes as well as for easy copy/paste, but works in all browsers , even without JS.

Posted by Seth (not verified) on Tue, 2009-03-31 11:03
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.