(bug 39560) Bring fix from upstream
Change-Id: I22bb979475511ec6354ff61411248e134c4a14a8
This commit is contained in:
@@ -82,8 +82,10 @@
|
|||||||
* @param fontFamily String: font family name
|
* @param fontFamily String: font family name
|
||||||
*/
|
*/
|
||||||
apply: function( fontFamily, $element ) {
|
apply: function( fontFamily, $element ) {
|
||||||
$element = $element || this.$element;
|
|
||||||
var fontStack = this.options.fontStack.slice( 0 );
|
var fontStack = this.options.fontStack.slice( 0 );
|
||||||
|
|
||||||
|
$element = $element || this.$element;
|
||||||
|
|
||||||
// Loading an empty string is pointless.
|
// Loading an empty string is pointless.
|
||||||
// Putting an empty string into a font-family list doesn't work with
|
// Putting an empty string into a font-family list doesn't work with
|
||||||
// jQuery.css().
|
// jQuery.css().
|
||||||
@@ -91,9 +93,16 @@
|
|||||||
this.load( fontFamily );
|
this.load( fontFamily );
|
||||||
fontStack.unshift( fontFamily );
|
fontStack.unshift( fontFamily );
|
||||||
}
|
}
|
||||||
$element.css( 'font-family', fontStack.join() );
|
|
||||||
$element.find( 'textarea, input' ).not( this.options.exclude ).css( 'font-family',
|
// Set the font of this element if it's not excluded
|
||||||
fontStack.join() );
|
if ( !$element.is( this.options.exclude ) ) {
|
||||||
|
$element.css( 'font-family', fontStack.join() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the font of this element's children if they are not excluded
|
||||||
|
$element.find( 'textarea, input' )
|
||||||
|
.not( this.options.exclude )
|
||||||
|
.css( 'font-family', fontStack.join() );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,27 +130,33 @@
|
|||||||
* different language than element
|
* different language than element
|
||||||
*/
|
*/
|
||||||
parse: function() {
|
parse: function() {
|
||||||
var that = this;
|
var webfonts = this;
|
||||||
that.$element.find( '*[lang], [style], [class]' ).each( function( i, element ) {
|
|
||||||
var fontFamilyStyle, fontFamily, $element = $( element );
|
webfonts.$element.find( '*[lang], [style], [class]' ).each( function( i, element ) {
|
||||||
|
var fontFamilyStyle, fontFamily,
|
||||||
|
$element = $( element );
|
||||||
|
|
||||||
fontFamilyStyle = $element.css( 'fontFamily' );
|
fontFamilyStyle = $element.css( 'fontFamily' );
|
||||||
|
|
||||||
if ( fontFamilyStyle ) {
|
if ( fontFamilyStyle ) {
|
||||||
fontFamily = fontFamilyStyle.split( ',' )[0];
|
fontFamily = fontFamilyStyle.split( ',' )[0];
|
||||||
|
|
||||||
// Remove the ' and " characters if any.
|
// Remove the ' and " characters if any.
|
||||||
fontFamily = $.trim( fontFamily.replace( /["']/g, '' ) );
|
fontFamily = $.trim( fontFamily.replace( /["']/g, '' ) );
|
||||||
if ( that.load( fontFamily ) ) {
|
|
||||||
// Font family overrides lang attribute
|
if ( webfonts.load( fontFamily ) ) {
|
||||||
// But was it the fontfamily allocated for the current
|
// Font family overrides the lang attribute,
|
||||||
|
// but was it the fontfamily allocated for the current
|
||||||
// language?
|
// language?
|
||||||
if ( fontFamily === that.getFont( element.lang ) ) {
|
if ( fontFamily === webfonts.getFont( element.lang ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( element.lang && element.lang !== that.$element.attr( 'lang' ) ) {
|
|
||||||
fontFamily = that.getFont( element.lang );
|
if ( element.lang && element.lang !== webfonts.$element.attr( 'lang' ) ) {
|
||||||
that.apply( fontFamily, $( element ) );
|
fontFamily = webfonts.getFont( element.lang );
|
||||||
|
webfonts.apply( fontFamily, $( element ) );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user