Update jquery.webfonts from upstream

Has proper font variant support

Change-Id: I5af7243106b140ed87e729b3fd6563d57e21ca7d
This commit is contained in:
Santhosh Thottingal
2012-11-14 15:19:36 +05:30
parent 1c6876ba8b
commit bd8aa89c2b

View File

@@ -234,14 +234,14 @@
* normal. * normal.
*/ */
getCSS: function( fontFamily, variant ) { getCSS: function( fontFamily, variant ) {
var fontconfig, base, version, versionSuffix, styleString, userAgent, fontStyle, fontFormats; var webfonts, fontconfig, base, version, versionSuffix, styleString, userAgent, fontStyle, fontFormats;
webfonts = this;
variant = variant || 'normal'; variant = variant || 'normal';
fontconfig = this.repository.get( fontFamily ); fontconfig = this.repository.get( fontFamily );
if ( variant !== 'normal' ) { if ( variant !== 'normal' ) {
if ( fontconfig.variants !== undefined && fontconfig.variants[variant] ) { if ( fontconfig.variants !== undefined && fontconfig.variants[variant] ) {
fontFamily = fontconfig.variants[variant]; fontconfig = this.repository.get( fontconfig.variants[variant] );
fontconfig = this.repository.get( fontFamily );
} }
} }
if ( !fontconfig ) { if ( !fontconfig ) {
@@ -283,7 +283,24 @@
styleString += "\tfont-weight:" + fontconfig.fontweight + ";"; styleString += "\tfont-weight:" + fontconfig.fontweight + ";";
} }
styleString += "\tfont-style:" + fontStyle + ";"; styleString += "\tfont-style:" + fontStyle + ";";
if ( fontconfig.fontweight !== undefined ) {
styleString += "\tfont-weight:" + fontconfig.fontweight + ";";
}
if ( fontconfig.fontstyle !== undefined ) {
styleString += "\tfont-style:" + fontconfig.fontstyle + ";";
} else {
styleString += "\tfont-style: normal;";
}
styleString += "}"; styleString += "}";
if ( fontconfig.variants !== undefined ) {
$.each( fontconfig.variants, function ( variant, variantFontFamily ) {
styleString += webfonts.getCSS( fontFamily, variant );
} );
}
return styleString; return styleString;
} }
}; };