Sunday, April 1, 2012

Cufon and IE7

Hi everybody, I am going to discuss on cufon and the difficulties we might face while developing a website. Often i had to use cufon script to embed fonts in websites, where we can apply the font to one class or id. Webfontkit (fontsquirrel[dot]com/fontface/generator) method is much better because it dosent convert the text with cufon or canvas tag. But some fonts are restricted or not permitted in this method or site (ex:Myriad-Pro)

So for cufon the class or id can be define in a script straight below of the script as below.

<script src="js/Myriad_Pro_400-Myriad_Pro_600.font.js" type="text/javascript"></script>
<script type="text/javascript">Cufon.replace('.myclass', { fontFamily: 'Myriad Pro', fontWeight: '400'});</script>

as above script, i have used ".myclass" the css class, but a browser cant get the script or method. Because for cufon IE7 reads only tags (ex: h1, div, body, span, li). so i wrap the class with h1 or h2 tag as below ex:.

<script type="text/javascript">Cufon.replace('h1', { fontFamily: 'Myriad Pro', fontWeight: '400'});</script>
<script type="text/javascript">Cufon.replace('h2', { fontFamily: 'Myriad Pro', fontWeight: '600'});</script>

I don't know how many of you know the trick for IE7, lets share thoughts.

No comments:

Post a Comment