1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

So here’s my problem. I have Cufon font replacement which works fine. When the page loads, Cufon works as expected:

Cufon.replace('a.prettyFont', { fontFamily: 'First Font', hover: true }); 

All links with the prettyFont class are replaced, with hover functionality enabled. The problem comes when I replace the Cufon font after page load using this code:

$.getScript('newfont.js', function() {
    Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: true });
    Cufon.refresh();
});

The new font shows up, but when I hover over any of the Cufon elements, it changes back to the old font. It seems that the hover option binds to the mouseover or mouseenter event to switch to the hover version of the original font, but it doesn’t change when you change the font. I was able to work around it using jQuery clone (cycle through each element Cufon replaced, swap out all HTML inside each element for just the text(), and then use jQuery replaceWith() to swap each item for its clone(). But that seems a little roundabout.

Is there an easier or more efficient way?

140 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
weblusive says

I am not sure, but try using jquery’s live() function. There are always issues with this cufon font dynamic replacement methods, hope this will be of little help.

2123 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+9 more
revaxarts says
Try
Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: 'true' });
1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

Try
Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: 'true' });

That’s the same as the code I’m using…it replaces the font, but the hover state is still the old font.

2123 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+9 more
revaxarts says


Try
Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: 'true' });
That’s the same as the code I’m using…it replaces the font, but the hover state is still the old font.

Did you noticed the apostrophe around true ?

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says



Try
Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: 'true' });
That’s the same as the code I’m using…it replaces the font, but the hover state is still the old font.
Did you noticed the apostrophe around true ?

Ah…I missed that. I tried it with the single quotes, and it is still the same. I guess I’ll have to stick with the jQuery clone hack:

$.getScript('newfont.js', function() {
    $('a.prettyFont').each(function() {
        $(this).html($(this).text());
        var clone = $(this).clone();
        $(this).replaceWith(clone);
    });
    Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: true });
    Cufon.refresh();
});

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by