<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Richard Shepherd &#187; font-face</title>
	<atom:link href="http://www.richardshepherd.com/tag/font-face/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardshepherd.com</link>
	<description>Making the web. Better looking.</description>
	<lastBuildDate>Fri, 04 Jun 2010 18:03:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Custom Fonts in WordPress with Cufon</title>
		<link>http://www.richardshepherd.com/custom-fonts-in-wordpress-with-cufon/</link>
		<comments>http://www.richardshepherd.com/custom-fonts-in-wordpress-with-cufon/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 14:33:10 +0000</pubDate>
		<dc:creator>richardshepherd</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[cufon]]></category>
		<category><![CDATA[custom fonts]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[sifr]]></category>
		<category><![CDATA[typekit]]></category>

		<guid isPermaLink="false">http://www.richardshepherd.com/?p=1100</guid>
		<description><![CDATA[A couple of weeks ago I got an email from Ben who said &#8220;I would love to know how you do those header custom fonts &#8230;!!&#8221; Well, without wanting to turn this blog into an episode of Why Don&#8217;t You I thought I should really answer this question on the blog so that others could [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I got an email from Ben who said</p>
<p><em>&#8220;I would love to know how you do those header custom fonts &#8230;!!&#8221;</em></p>
<p>Well, without wanting to turn this blog into an episode of <a href="http://en.wikipedia.org/wiki/Why_Don%27t_You" target="_blank">Why Don&#8217;t You</a> I thought I should really answer this question on the blog so that others could have a read.<span id="more-1100"></span></p>
<h3>Custom Fonts, different options and the pros and cons</h3>
<p><img class="alignnone size-full wp-image-1144" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/cufon.jpg" alt="cufon" width="490" height="122" /></p>
<p>First of all, there has always been some debate on the pros and cons of using custom fonts. In the old days, when people used to use IE6&#8230; What? They still do? Oh. Okay, well a few years ago the only way to use custom fonts on your site was using images. Image replacement has got more sophisticated with CSS techniques, and there&#8217;s a comprehensive round-up of these techniques over at the marvelous <a href="http://css-tricks.com/css-image-replacement/" target="_blank">CSS Tricks</a>. However, this is still <em>image replacement</em> &#8211; in other words, you&#8217;re looking at a graphical representation of the text and not the text itself.</p>
<p><img class="alignright size-full wp-image-1141" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/sifr.jpg" alt="sifr" width="192" height="116" />Another popular way to use custom fonts is the flash replacement technique, and <a href="http://www.mikeindustries.com/blog/sifr">sIFR</a> is one of the heavyweights in this area.  Until relatively recently this was the most popular way to get &#8216;real&#8217; fonts on your page with only a couple of drawbacks &#8211; the (slight) increase in page load time, and the fact that some browsers are set up to block flash (adverts).</p>
<p>There is some truth that not <em>everyone</em> has Flash installed but to be honest I&#8217;m not that interested in supporting them. We&#8217;re talking about a handful of visitors a year and, like the 1% (or less) that have JavaScript turned off I simply can&#8217;t justify penalising the other 99%. Sure, make your site IE6 compatible, but don&#8217;t lose any sleep over supporting Flash or Javascript.</p>
<p>Which brings us nicely on to Cufon, which uses Javascript to display custom fonts.</p>
<h4>Javascript? Fonts? How does THAT work?!?!</h4>
<p><img class="size-full wp-image-1138 alignright" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/cufon-logo.jpg" alt="Cufon" width="134" height="49" />The special headings on this site (which is an open-source font called Chunk Five) are rendered using <a href="http://cufon.shoqolate.com/generate/" target="_blank">Cufon</a>. For the techinically minded amongst you (and I don&#8217;t count myself in that illustrious bunch ) Cufon converts font paths to VML paths, stores this information as JSON (JavaScript Object Notation) and then renders the fonts using JavaScript. This is clever stuff, but we need not worry about the complex jiggery-pokery.</p>
<p>There are three (fairly) easy steps to WordPress custom font heaven with Cufon:</p>
<ol>
<li>Choose a font, and upload it to the Cufon Generator</li>
<li>Let Cufon work it&#8217;s magic, and then download the new font .js file</li>
<li>Upload this file, and add a couple of bits of javascript to the  of your page</li>
</ol>
<h3>Step One</h3>
<h4>Choose your font</h4>
<p>Step one is easy enough; just place the TrueType/OpenType/Printer Font Binary/PostScript file(s) somewhere handy, like on your desktop. Now you may have downloaded these files from an <a href="http://www.dafont.com">free font library</a>, or you may be copying them from your fonts directory, but you must consider the <em>legal implications</em> of using the font.</p>
<h4>A word on the law</h4>
<p>Do you own the right to use the font? If it&#8217;s a commercial font, have you paid for it? If you downloaded it from somewhere like <a href="http://www.dafont.com/">DaFont</a> you must check the licensing that accompanies the font. In short: keep it legal, kids.</p>
<p>If you&#8217;re not sure if you have permission to use your font then you might want to look at a service like TypeKit which I talk about below!</p>
<p>If you&#8217;re happy with your font then it&#8217;s time to upload it to Cufon, which you do over at <a href="http://cufon.shoqolate.com/generate/" target="_blank">http://cufon.shoqolate.com/generate/</a>.</p>
<h3>Step Two</h3>
<h4>Let Cufon work it&#8217;s magic</h4>
<p>There are a few things to fill in, but they&#8217;re fairly straightforward. Let&#8217;s look at some of the common options&#8230;</p>
<p><img class="alignnone size-full wp-image-1134" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/select-the-font.jpg" alt="Select the font" width="466" height="305" /></p>
<p>To save space, and therefore page load time, only choose the styles that you know you&#8217;re going to use. For example, I didn&#8217;t use the Italic or Bold Italic typefaces for  this site which makes the font.js file that little bit smaller (and so load that little bit quicker).</p>
<p><img class="alignnone size-full wp-image-1142" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/include-these-glyphs1.jpg" alt="Use the following glyphs" width="487" height="405" /></p>
<p>Take your pick really. You may adopt a &#8216;kitchen sink&#8217; approach and go for the lot (as above) or again just choose those glyphs you know you&#8217;ll need. There are further options such as &#8216;Latin Extended&#8217; and &#8216;Russian&#8217; but you probably won&#8217;t need these. Unless you Russian. Or Roman.</p>
<p><img class="alignnone size-full wp-image-1143" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/security1.jpg" alt="security" width="517" height="171" /></p>
<p>This is a <em>really</em> good idea. Restrict use to your own domain to stop thieves, squatters, and copyright issues!</p>
<p><img class="alignnone size-full wp-image-1137" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2010/02/lets-do-this.jpg" alt="Let's do this" width="178" height="48" /></p>
<p>Finally click the Let&#8217;s do this! button to download your newly created .font.js file!</p>
<h3>Step Three</h3>
<h4>Upload and add some script</h4>
<p>This next bit is entirely down to you &#8211; you&#8217;ll need to upload the .js file to your site somewhere, and make a note of the path. Let&#8217;s assume you upload <strong>ChunkFive_400.font.js</strong> to the <strong>www.example.com/js/</strong> folder. We could include this file in a page using the following:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/js/ChunkFive_400.font.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>You need to to do the same with the Cufon file, which you can download from <a href="http://cufon.shoqolate.com/js/cufon-yui.js" target="_blank">http://cufon.shoqolate.com/js/cufon-yui.js</a>. Again, you&#8217;ll need to include this in your page like so:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/js/cufon-yui.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>Of course, you could change that path to wherever your Cufon .js files are located. We now need to add them to your site, by placing them somewhere in the section. If you don&#8217;t know how to do this, the easiest way is to enter your WordPress admin area, and go to Appearance &gt; Editor. In the editor, select the file called <strong>header.php</strong> where you&#8217;ll find the head section, and problem see some other javascript files that are included. Just drop your two lines of code in there!</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/js/ChunkFive_400.font.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/js/cufon-yui.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>One final thing. You need declare which bits of your page to change to the new custom font. Again this is pretty easy to do. If you want all your heading tags to take on this new font you might use something like this:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; Cufon.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'h1, h2, h3, h4, h5, h6'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>You could even describe specific areas on the page using jQuery, like so:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; Cufon.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#introduction'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>This would make all text in take on the custom font. Cool :)</p>
<p>If you wanted, just take a look at the source code for this page &#8211; that might help explain things a little better!</p>
<h3>Wp-Cufon</h3>
<p>If that sounds too much like hard work, and it <em>really</em> shouldn&#8217;t, you could take a look at a WordPress plugin which does some of the heavy lifting for you. You can find Wp-Cufon at <a href="http://wordpress.org/extend/plugins/wp-cufon/installation/" target="_blank">http://wordpress.org/extend/plugins/wp-cufon/installation/</a> but, to be honest, I encourage you to do this yourself because you&#8217;ll learn so much more about how Cufon works. In fact, even if you use the plug-in you still have to create the .js font file yourself.</p>
<h3>font-face, Typekit and others</h3>
<p>This post is already quite long enough, so I&#8217;m going to postpone looking at @font-face and Typekit for a later post. I&#8217;m going to <em>post</em>pone. Geddit?! I&#8217;ll be here all week&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardshepherd.com/custom-fonts-in-wordpress-with-cufon/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
