Hi,

I am hoping that someone knows the answer, I've been looking for days but I can't find the solution. Basically I need to trigger my own script as soon as the (typekit) font has loaded. Is there any way I can do this outside of 'try{Typekit.load();}catch(e){}'? I have my own jQuery set up in my theme, and now I need to run something in it as soon as 'active' is triggered. My eternal gratitute if someone points me in the right direction!

Cheers,

Dagomar

Comments

sreynen’s picture

Status: Active » Fixed

See http://blog.typekit.com/2010/10/18/more-control-with-typekits-font-events/ toward the bottom. Typekit.load() can take a list of callback functions on different statuses.

dagomar’s picture

Hi sreyen,

Thanks for the follow up. I have seen that piece of code, but when I paste that in my page header for testing purposes, i get no result.

<script type="text/javascript">
 try {
   Typekit.load({
     loading: function() {
console.log('loading');
     },
     active: function() {
      console.log('active');
alert('active');
     },
     inactive: function() {
console.log('inactive');
     }
   })
 } catch(e) {}
 </script>

That code does nothing, even though typekit is loading it's fonts (through fontyourface). If I add that code in the module itself instead of 'try{Typekit.load();}catch(e){}', then I do get console.log entries. Any ideas?

sreynen’s picture

My guess is the Typekit.load() call in the module causes your call to not work, so you'd need to prevent the first call and make your own. You could do that with hook_js_alter().

dagomar’s picture

Hi sreyen,

I think you're right. I was just wondering if it could be done with javascript, but that is fine. Thanks!

Cheers,

Dagomar

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.