diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js index 03e1c32a..f315c173 100644 --- a/resources/js/ext.uls.webfonts.js +++ b/resources/js/ext.uls.webfonts.js @@ -84,14 +84,21 @@ return excludes; }() ) } ); - $( 'body' ).webfonts(); - // Load the css required for Autonym font. Note that this wont download the font. - // Browsers are smart enough to delay it till some element with this font-family - // become visible. For eg: If there is a popup div with an element with class - // 'autonym', without explicitly calling .webfonts() on it, Autonym font will not - // be applied in general. But we ensure that css is ready so that automatically - // the font get applied to such future elements. - $( 'body' ).data( 'webfonts' ).load( 'Autonym' ); + + // Execute after task queue is processed so that the rendering is complete. + // This is important because webfonts behavior depends on the font-family + // property values set by stylesheets. + setTimeout( function() { + $( 'body' ).webfonts(); + + // Load the CSS required for the Autonym font. Note that this won't download the font. + // Browsers are smart enough to delay it till some element with this font-family + // becomes visible. For example: If there is a popup div with an element with class + // 'autonym', without explicitly calling .webfonts() on it, Autonym font will not + // be applied in general. But we ensure that the CSS is ready so that the font + // will be applied automatically to such future elements. + $( 'body' ).data( 'webfonts' ).load( 'Autonym' ); + }, 0 ); }; $( document ).ready( function () {