Wait till rendering thread completion before applying webfonts

So that the fontfamily values are always 'seen' by the webfonts jquery
plugin. Missing this was causing incorrect behavior -overriding the
fontfamiliy from css- in random cases.

The stylesheet ext.uls.webfonts.css define font family values for
interlanguge links and autonym class. This patch make sure that that
css values are read by jquery.webfonts while deciding which font to
apply. Autonym font is supposed to be used for them. If jquery.webfonts
does not read that these elements has a font family defined in css as
"'Autonym', sans-serif", it will attempt to apply fonts as per user
preference or default fonts based on lang attribute. That will cause
applying bigger fonts.

jquery.webfonts does not apply any fonts, if an element has explicit
font family value defined by inline css or by external style sheets.

Bug: 59958
Change-Id: I2da436caa618bc2318e20e3c0492a6bf1c03e162
This commit is contained in:
Santhosh Thottingal
2014-01-12 18:31:02 +05:30
parent 5f57b41101
commit 61e1f95a4c

View File

@@ -84,14 +84,21 @@
return excludes;
}() )
} );
// 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 Autonym font. Note that this wont download the font.
// 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
// become visible. For eg: If there is a popup div with an element with class
// 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 css is ready so that automatically
// the font get applied to such future elements.
// 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 () {