Aweber - Email Marketing Made Easy
Use Cufon In Your Thesis Theme Without a Plugin

Use Cufon In Your Thesis Theme Without a Plugin

July 29, 2010 · 10 comments

in Thesis

I am a fan of using Cufón for non-standard web fonts on the sites that I build. I’ve used it extensively and have become really familiar with the system and its ease of use. I thought I’d put together this simple tutorial on how to use Cufón and then also how to integrate it into your Thesis theme. I’ll also share some quick tips that I picked up which have really helped.

Once you become familiar with how to use it, you can literally get custom fonts implemented within minutes. It’s probably not as fast to get going as say the Google Font API, but I just prefer the way Cufón renders the fonts. You could also use the @font-face method which works well, although this tutorial is specifically about Cufón.

Adding custom web fonts to your site can go a long way to improving the overall design, but one thing to keep in mind is that you should use them sparingly. I typically use custom fonts for such things as headers and titles. I wouldn’t recommend replacing all the text in your paragraph tags with custom fonts. Anyway, lets get started.

Step 1 – Generate your font

Although there isn’t a specific order of events, I basically do this first. Also, as I’m going through these steps, I’m going to show you how I complete the process. There are other options as you will discover, but this is how I do it and which I’ve found works best.

You need to use the Cufón font generator to generate the .js file of your font. Before you even start, make sure the EULAs of the font you want to use allows for web embedding. You can read more about that on the Cufón site. Once you know which custom font you want to use, copy the font file to your desktop temporarily. You’ll delete it when done. Currently only TrueType (TTF), OpenType (OTF), Printer Font Binary (PFB) and PostScript fonts are supported.

Open the Cufón font generator in your browser. There are many options on that page, but here’s the parts I complete. You can click the images for a larger view:

Select the fonts you’d like to use
Mostly I just have a need for a specific font and don’t care about bold or italic, so I just use the “Regular Typeface” field and upload the font file. You can upload the bold, italic and bold italic variations if you’d like. So over here, you’re just uploading the font file you had saved on your desktop. Then be sure to click the EULA box to confirm they allow web embedding.

Cufon Generator Options

Include the following glyphs (if available)
These next set of options are also up to you as to which ones you want to select. I usually check Uppercase, Lowercase, Numerals and Punctuation. I leave “Basic Latin” checked.

Cufon Font Generator Options

Performance & file size
You can use the security field for the purposes shown on the Cufón site if you’d like. For the Performance & file size option, I check the “No thanks” box. I found by doing this it solves some issues I’d experienced with font size.

Cufon Font Options

Terms
And the last part here is to agree to the terms by checking the applicable box. Then click the “Lets do this!” button.

Step 2 – Copy the files to your server

Okay, great. We’re making good progress here. After completing the first step, you will have downloaded a new file with a .js extension. This is the font file that the Cufón generator created and which will be used to render the font. At the top of the page you just used to generate your font file, you will see a button that says “Download”. Right-click that (if you’re using a Windows PC), if you’re using a Mac, well you don’t have a right mouse button. I’ve always been perplexed by that. But if you’re using a Mac, I’m sure you’ll know what to do. You just need the main Cufón file called cufon-yui.js. Download it and save to your desktop.

Now make a new folder called “js” inside your custom folder. So here: /wp-content/themes/thesis_x/custom/js. Copy the font file along with the cufón file to this folder using filezilla, or other FTP program.

Step 3 – Update your custom-functions.php file

Alright! Let’s make this work now on your website. Go ahead and paste the following code into your custom-functions.php file and then save and upload it to the custom folder inside your Thesis theme. Before you upload it though, keep reading because you will need to change some lines according to your unique requirements.

function cufon() {
?>
<!-- cufon -->
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/custom/js/cufon-yui.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/custom/js/your_font_filename_here.font.js"></script>
<script type="text/javascript">
	cufon.replace('h1', { fontFamily: 'My Favorite Font' });
</script>
<!--end cufon -->
<?php
}

add_action ('wp_head','cufon');

// added for IE
function cufonie() {
?>
<script type="text/javascript"> cufon.now(); </script>
<?php
}

add_action ('thesis_hook_after_html','cufonie');

Quick Tip: After you complete this tutorial and you find the custom font is not showing up, or maybe it’s showing in Firefox and other browsers but not IE (which happened to me) here’s something you can try which worked for me. You can read more about it here (Item #1) Just add this line before line 4 above:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

Now be sure to update the font filename on line #5, and pay close attention to this line:

cufon.replace('h1', { fontFamily: 'My Favorite Font' });

There are so many options you can set here depending on what text effects you’d like to add such as text shadow, whether you want multiple fonts, and also more importantly, which part of your site you want to change to the custom font. You should change the ‘h1′ selector to which ever css selector you want impacted by the new font. And of course be sure to change the font name where it says ‘My Favorite Font’ to the name of the font you just generated.

Quick Tip: To find the correct name of the font, just open up the font file that was generated by Cufón and you will find it right at the top to the right of where it says “Font Family”. Be sure to use the exact name you see within quotes.

You’re done!

That’s it. You should now see the custom font show up on your site.

Some Helpful Cufón Resources

Here’s some links to sites I have found helpful when working with Cufón. You will also need to read some of these if you want to add additional fonts and style your fonts, etc.

And One Final Quick Tip: Something you’ll most likely experience is a delay when the Cufón font is rendered on the page. So what happens is that for a split second, you see the standard web font, and then the custom font is displayed. This can be a little annoying and unprofessional, so here’s a great solution I discovered through one of the links above. Simply add this line to your custom.css file. Replace ‘h1′ which whatever css selector you’re using:

.cufon-loading h1 { visibility: hidden !important; }

Be sure to leave a comment below about your experience with this and if you have other good information to share!

Was this post helpful? Consider subscribing to my blog via RSS or

This Site Runs on the Thesis WordPress Theme

Thesis Theme thumbnail

If you're someone who doesn't understand a lot of PHP, HTML, or CSS, Thesis will give you a ton of functionality without having to alter any code. For the advanced user, Thesis has incredible customization possibilities via extensive hooks and filters. And with so many design options, you can use the template over and over and never have it look like the same site.

If you're more familiar with how websites work, you can use the fantastic Thesis User's Guide and world-class support forums to make more professional customizations than you ever thought possible. The theme is not only highly customizable, but it allows me to build sites with a much more targeted focus on monetization than ever before. You can find out more about Thesis below:

{ 10 comments… read them below or add one }

evgeniy2009 August 14, 2010 at 1:50 am

I would like to exchange links with your site thesis-blogs.com
Is this possible?

Reply

Thesis-Blogs.com August 20, 2010 at 9:28 am

Sure. Just by commenting, you have a link on this site pointing back to your site. If you’d like to add a link on yours to thesis-blogs.com, you can do that. Thanks.

Reply

lawton chiles October 13, 2010 at 8:57 am

Hey, how did you do those cool social media icons at the end of your post? very groovy.

Reply

Thesis-Blogs.com October 13, 2010 at 10:21 am

What’s up Lawton… thanks for asking about this. I decided to go ahead and write a post which will answer your question, instead of trying to cram it all into a comment. You can read it here: Add Social Media Icons to Thesis. Enjoy, and thanks for commenting.

Reply

Paul Chamberlain March 26, 2011 at 1:58 pm

In line 7 above, “cufon.replace” needed to be “Cufon.replace” in order for this to work for me.

Thanks for the post!

Reply

Trisha April 7, 2011 at 10:43 am

capitalizing the C worked for me too Paul. dont know why i was trying to echo the script, this is much easier. Thanks for sharing!

Has anyone had weird spacing issues? Cufon is adding height the menus. When you add a submenu, it adds more height and throws the whole menu off. Anyone experienced this?

Reply

baju kurung May 1, 2011 at 10:05 pm

hi there, this tutorial is for changing all the fonts entirely on the theme or we can customize which place we want such as sidebar only or footer and etc…please advice :)
baju kurung recently posted..extended stay phoenix updated Thu Mar 17 2011 6-33 am CDT

Reply

Thesis-Blogs.com May 1, 2011 at 10:22 pm

Read the article, and you will most likely answer your own question, but yes, you specify exactly which text elements you want to be impacted by the custom Cufon fonts.

Reply

Kara June 16, 2011 at 12:34 am

Thanks for the great tutorial. I love that Thesis integrates Google web fonts, however since they appear to render very poorly on windows I’ve decided to use Cufon or @font-face instead. In general, do you recommend using Cufon or @font-face (for title/H1/H2 replacement)? I see that you use @font-face on this site, so I was wondering if you’ve found it to be better than Cufon.

Reply

Thesis-Blogs.com June 16, 2011 at 12:56 am

Hi Kara. Thanks for commenting. I actually used cufon a lot about a year ago, but lately I’ve been using @font-face exclusively. It wasn’t a conscious decision. I just used it once on a site and was more than satisfied with the results, so I just kept using it.

I don’t really have an opinion as to whether it’s better or worse than using cufon. I’m just happy with the results. I use fontsquirrel.com to generate the font files and it also provides you with the preferred way to render the fonts.

Reply

Leave a Comment

When commenting, you can use basic HTML tags. If you are pasting in any code, please escape it here and then include that code within <pre></pre> tags. Thanks!

CommentLuv badge

Previous post:

Next post: