1040 posts
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
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
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • United States
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.

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says
Try
Cufon.replace('a.prettyFont', { fontFamily: 'New Font', hover: 'true' });
1040 posts
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
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.

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 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 ?

1040 posts
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
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();
});
by
by
by
by
by
by