From bd8aa89c2b45fafe8dafd51fe41c92c4503e0eab Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Wed, 14 Nov 2012 15:19:36 +0530 Subject: [PATCH] Update jquery.webfonts from upstream Has proper font variant support Change-Id: I5af7243106b140ed87e729b3fd6563d57e21ca7d --- lib/jquery.webfonts.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/jquery.webfonts.js b/lib/jquery.webfonts.js index 053cd697..33cb5dd0 100644 --- a/lib/jquery.webfonts.js +++ b/lib/jquery.webfonts.js @@ -234,14 +234,14 @@ * normal. */ 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'; fontconfig = this.repository.get( fontFamily ); if ( variant !== 'normal' ) { if ( fontconfig.variants !== undefined && fontconfig.variants[variant] ) { - fontFamily = fontconfig.variants[variant]; - fontconfig = this.repository.get( fontFamily ); + fontconfig = this.repository.get( fontconfig.variants[variant] ); } } if ( !fontconfig ) { @@ -283,7 +283,24 @@ styleString += "\tfont-weight:" + fontconfig.fontweight + ";"; } 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 += "}"; + + if ( fontconfig.variants !== undefined ) { + $.each( fontconfig.variants, function ( variant, variantFontFamily ) { + styleString += webfonts.getCSS( fontFamily, variant ); + } ); + } + return styleString; } };