Index: trunk/extensions/WebFonts/resources/ext.webfonts.js |
— | — | @@ -103,8 +103,9 @@ |
104 | 104 | loadCSS: function( fontFamily ) { |
105 | 105 | var fontconfig = $.webfonts.config.fonts[fontFamily]; |
106 | 106 | var base = mw.config.get( 'wgExtensionAssetsPath' ) + '/WebFonts/fonts/'; |
| 107 | + var fontFormats = []; |
107 | 108 | var styleString = |
108 | | - "<style type='text/css'>\n@font-face {\n" |
| 109 | + "@font-face {\n" |
109 | 110 | + "\tfont-family: '"+fontFamily+"';\n"; |
110 | 111 | |
111 | 112 | if ( 'eot' in fontconfig ) { |
— | — | @@ -121,22 +122,22 @@ |
122 | 123 | } |
123 | 124 | |
124 | 125 | if ( 'woff' in fontconfig ) { |
125 | | - styleString += "\t\turl('"+base+fontconfig.woff+"') format('woff'),"; |
| 126 | + fontFormats.push( "\t\turl('"+base+fontconfig.woff+"') format('woff')" ); |
126 | 127 | } |
127 | 128 | |
128 | 129 | if ( 'svg' in fontconfig ) { |
129 | | - styleString += "\t\turl('"+base+fontconfig.svg+"#"+fontFamily+"') format('svg'),"; |
| 130 | + fontFormats.push( "\t\turl('"+base+fontconfig.svg+"#"+fontFamily+"') format('svg')" ); |
130 | 131 | } |
131 | 132 | |
132 | 133 | if ( 'ttf' in fontconfig ) { |
133 | | - styleString += "\t\turl('"+base+fontconfig.ttf+"') format('truetype');\n"; |
| 134 | + fontFormats.push( "\t\turl('"+base+fontconfig.ttf+"') format('truetype')" ); |
134 | 135 | } |
| 136 | + |
| 137 | + styleString += fontFormats.join() + ";\n" |
| 138 | + styleString += "\tfont-weight: normal;\n}\n"; |
135 | 139 | |
136 | | - styleString += "\tfont-weight: normal;\n}\n</style>\n"; |
137 | | - |
138 | 140 | //inject the css to the head of the page. |
139 | | - $( styleString ).appendTo( 'head' ); |
140 | | - |
| 141 | + mw.util.addCSS( styleString ); |
141 | 142 | }, |
142 | 143 | |
143 | 144 | /** |
Index: trunk/extensions/WebFonts/WebFonts.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | 'localBasePath' => $dir, |
48 | 48 | 'remoteExtPath' => 'WebFonts', |
49 | 49 | 'messages' => array( 'webfonts-load', 'webfonts-reset' ), |
50 | | - 'dependencies' => array( 'jquery.cookie', 'ext.webfonts.fontlist'), |
| 50 | + 'dependencies' => array( 'mediawiki.util', 'jquery.cookie', 'ext.webfonts.fontlist'), |
51 | 51 | ); |
52 | 52 | |
53 | 53 | $wgResourceModules['ext.webfonts.fontlist'] = array( |