http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95842

Revision: 95842
Author:   nikerabbit
Date:     2011-08-31 10:00:44 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
Move the list of available fonts into a module, so that they are not increasing 
the html source nor cached there.
Fixes bug 29318 (It would still be possible to squeeze the list more, but I 
think the low hanging fruit is now done)

Modified Paths:
--------------
    trunk/extensions/WebFonts/WebFonts.hooks.php
    trunk/extensions/WebFonts/WebFonts.php
    trunk/extensions/WebFonts/js/webfonts.js

Added Paths:
-----------
    trunk/extensions/WebFonts/js/webfonts.fontlist.js

Removed Paths:
-------------
    trunk/extensions/WebFonts/WebFonts.config.php

Deleted: trunk/extensions/WebFonts/WebFonts.config.php
===================================================================
--- trunk/extensions/WebFonts/WebFonts.config.php       2011-08-31 08:44:49 UTC 
(rev 95841)
+++ trunk/extensions/WebFonts/WebFonts.config.php       2011-08-31 10:00:44 UTC 
(rev 95842)
@@ -1,246 +0,0 @@
-<?php
-/**
- * Configuration file for webfonts
- * First font is the default font for the language
- * @file
- * @ingroup Extensions
- */
-$wgWebFonts = array(
-       'basepath' => "$wgScriptPath/extensions/WebFonts/fonts/",
-       'fonts' => array(
-               'RufScript' => array(
-                       'eot' => "en/Rufscript.eot",
-                       'ttf' => "en/Rufscript.ttf",
-                       'woff' => "en/Rufscript.woff",
-               ),
-
-               'Perizia' => array(
-                       'eot' => "en/Perizia.eot",
-                       'ttf' => "en/Perizia.ttf",
-                       'woff' => "en/Perizia.woff",
-               ),
-               'Ubuntu' => array(
-                       'eot' => "en/ubuntu-r-webfont.eot",
-                       'ttf' => "en/ubuntu-r.ttf",
-                       'woff' => "en/ubuntu-r-webfont.woff",
-                       'svg' => "en/ubuntu-r-webfont.svg",
-                       ),
-               'AnjaliOldLipi' => array(
-                       'eot' => "ml/AnjaliOldLipi.eot",
-                       'ttf' => "ml/AnjaliOldLipi.ttf",
-                       'woff' => "ml/AnjaliOldLipi.woff",
-               ),
-               'Meera' => array(
-                       'eot' => "ml/Meera.eot",
-                       'ttf' => "ml/Meera.ttf",
-                       'woff' => "ml/Meera.woff",
-                       'scale' => 1.5,
-                       'normalization' => array(
-                               "ൾ" => "ള്‍",
-                               "ൻ" => "ന്‍",
-                               "ർ" => "ര്‍",
-                               "ൺ " => "ണ്‍",
-                               "ൽ" => "ല്‍",
-                               "ൿ" => "ക്‍ ",
-                               "ൻ‍റ" => "ന്റ",
-                               "ന്‍റെ" => "ന്റെ"
-                               )
-                               ),
-
-               'Rachana' => array(
-                       'eot' => "ml/Rachana.eot",
-                       'ttf' => "ml/Rachana.ttf",
-                       'woff' => "ml/Rachana.woff",
-                       'normalization' => array(
-                               "ൾ" => "ള്‍",
-                               "ൻ" => "ന്‍",
-                               "ർ" => "ര്‍",
-                               "ൺ " => "ണ്‍",
-                               "ൽ" => "ല്‍",
-                               "ൿ" => "ക്‍ ",
-                               "ൻ‍റ" => "ന്റ",
-                               "ന്‍റെ" => "ന്റെ"
-                               )
-                               ),
-               'RaghuMalayalam' => array(
-                       'eot' => "ml/RaghuMalayalam.eot",
-                       'ttf' => "ml/RaghuMalayalam.ttf",
-                       'woff' => "ml/RaghuMalayalam.woff",
-                       'normalization' => array(
-                               "ൾ" => "ള്‍",
-                               "ൻ" => "ന്‍",
-                               "ർ" => "ര്‍",
-                               "ൺ " => "ണ്‍",
-                               "ൽ" => "ല്‍",
-                               "ൿ" => "ക്‍ ",
-                               "ൻ‍റ" => "ന്റ",
-                               "ന്‍റെ" => "ന്റെ"
-                               )
-                               ),
-               'Lohit Oriya' => array(
-                       'eot' => "or/Lohit-Oriya.eot",
-                       'ttf' => "or/Lohit-Oriya.ttf",
-                       'woff' => "or/Lohit-Oriya.woff",
-                               ),
-               'Lohit Tamil' => array(
-                       'eot' => "ta/Lohit-Tamil.eot",
-                       'ttf' => "ta/Lohit-Tamil.ttf",
-                       'woff' => "ta/Lohit-Tamil.woff",
-                               ),
-               'Lohit Telugu' => array(
-                       'eot' => "te/LohitTelugu.eot",
-                       'ttf' => "te/LohitTelugu.ttf",
-                       'woff' => "te/LohitTelugu.woff",
-                               ),
-               'Lohit Bengali' => array(
-                       'eot' => "bn/LohitBengali.eot",
-                       'ttf' => "bn/LohitBengali.ttf",
-                       'woff' => "bn/LohitBengali.woff",
-                               ),
-               'Samyak Gujarati' => array(
-                       'eot' => "gu/SamyakGujarati.eot",
-                       'ttf' => "gu/SamyakGujarati.ttf",
-                       'woff' => "gu/SamyakGujarati.woff",
-                               ),
-               'Lohit Hindi' => array(
-                       'eot' => "hi/LohitHindi.eot",
-                       'ttf' => "hi/LohitHindi.ttf",
-                       'woff' => "hi/LohitHindi.woff",
-                               ),
-               'Samyak Devanagari' => array(
-                       'eot' => "hi/SamyakDevanagari.eot",
-                       'ttf' => "hi/SamyakDevanagari.ttf",
-                       'woff' => "hi/SamyakDevanagari.woff",
-                               ),
-               'Miriam CLM' => array(
-                       'eot' => "he/MiriamCLM-Book.eot",
-                       'ttf' => "he/MiriamCLM-Book.ttf",
-                       'woff' => "he/MiriamCLM-Book.woff",
-                               ),              
-               'Taamey Frank CLM' => array(
-                       'eot' => "he/TaameyFrankCLM.eot",
-                       'ttf' => "he/TaameyFrankCLM.ttf",
-                       'woff' => "he/TaameyFrankCLM.woff",
-                       'svg' => "he/TaameyFrankCLM.svg",
-                               ),
-               'Kedage' => array(
-                       'eot' => "kn/Kedage.eot",
-                       'ttf' => "kn/Kedage.ttf",
-                       'woff' => "kn/Kedage.woff",
-                               ),
-               'Lohit Kannada' => array(
-                       'eot' => "kn/LohitKannada.eot",
-                       'ttf' => "kn/LohitKannada.ttf",
-                       'woff' => "kn/LohitKannada.woff",
-                               ),
-               'Masterpiece Uni Sans' => array(
-                       'eot' => "my/MasterpieceUniSans.eot",
-                       'ttf' => "my/MasterpieceUniSans.ttf",
-                       'woff' => "my/MasterpieceUniSans.woff",
-                       'svg' =>  "my/MasterpieceUniSans.svg",
-               ),
-               'Padauk-Regular' => array(
-                       'eot' => "my/Padauk-Regular.eot",
-                       'ttf' => "my/Padauk-Regular.ttf",
-                       'woff' => "my/Padauk-Regular.woff",
-                       'svg' =>  "my/Padauk-Regular.svg",
-               ),
-               'Myanmar3' => array(
-                       'eot' => "my/Myanmar3.eot",
-                       'ttf' => "my/Myanmar3.ttf",
-                       'woff' => "my/Myanmar3.woff",
-                       'svg' =>  "my/Myanmar3.svg",
-               ),
-               'Yunghkio' => array(
-                       'eot' => "my/Yunghkio.eot",
-                       'ttf' => "my/Yunghkio.ttf",
-                       'woff' => "my/Yunghkio.woff",
-                       'svg' =>  "my/Yunghkio.svg",
-               ),
-               'KhmerOSbattambang' => array(
-                       'eot' => "km/KhmerOSbattambang.eot",
-                       'ttf' => "km/KhmerOSbattambang.ttf",
-                       'woff' => "km/KhmerOSbattambang.woff",
-                       'svg' =>  "km/KhmerOSbattambang.svg",
-               ),
-               'KhmerOSbokor' => array(
-                       'eot' => "km/KhmerOSbokor.eot",
-                       'ttf' => "km/KhmerOSbokor.ttf",
-                       'woff' => "km/KhmerOSbokor.woff",
-                       'svg' =>  "km/KhmerOSbokor.svg",
-               ),
-               'KhmerOS' => array(
-                       'eot' => "km/KhmerOS.eot",
-                       'ttf' => "km/KhmerOS.ttf",
-                       'woff' => "km/KhmerOS.woff",
-                       'svg' =>  "km/KhmerOS.svg",
-               ),
-               'KhmerOSsiemreap' => array(
-                       'eot' => "km/KhmerOSsiemreap.eot",
-                       'ttf' => "km/KhmerOSsiemreap.ttf",
-                       'woff' => "km/KhmerOSsiemreap.woff",
-                       'svg' =>  "km/KhmerOSsiemreap.svg",
-               ),
-               'KhmerOSmuollight' => array(
-                       'eot' => "km/KhmerOSmuollight.eot",
-                       'ttf' => "km/KhmerOSmuollight.ttf",
-                       'woff' => "km/KhmerOSmuollight.woff",
-                       'svg' =>  "km/KhmerOSmuollight.svg",
-               ),
-               'KhmerOSmuol' => array(
-                       'eot' => "km/KhmerOSmuol.eot",
-                       'ttf' => "km/KhmerOSmuol.ttf",
-                       'woff' => "km/KhmerOSmuol.woff",
-                       'svg' =>  "km/KhmerOSmuol.svg",
-               ),
-               'KhmerOSmuolpali' => array(
-                       'eot' => "km/KhmerOSmuolpali.eot",
-                       'ttf' => "km/KhmerOSmuolpali.ttf",
-                       'woff' => "km/KhmerOSmuolpali.woff",
-                       'svg' =>  "km/KhmerOSmuolpali.svg",
-               ),
-               'KhmerOSfreehand' => array(
-                       'eot' => "km/KhmerOSfreehand.eot",
-                       'ttf' => "km/KhmerOSfreehand.ttf",
-                       'woff' => "km/KhmerOSfreehand.woff",
-                       'svg' =>  "km/KhmerOSfreehand.svg",
-               ),
-               'KhmerOSfasthand' => array(
-                       'eot' => "km/KhmerOSfasthand.eot",
-                       'ttf' => "km/KhmerOSfasthand.ttf",
-                       'woff' => "km/KhmerOSfasthand.woff",
-                       'svg' =>  "km/KhmerOSfasthand.svg",
-               ),
-               'Pagul' => array(
-                       'eot' => "saz/Pagul.eot",
-                       'ttf' => "saz/Pagul.ttf",
-                       'woff' => "saz/Pagul.woff",
-               ),
-               'AbyssinicaSIL'=> array(
-                       'eot' => "gez/AbyssinicaSIL-R.eot",
-                       'ttf' => "gez/AbyssinicaSIL-R.ttf",
-                       'woff' => "gez/AbyssinicaSIL-R.woff",
-               ),
-               ),
-
-       'languages' => array(
-               // 'en' => array( 'RufScript', 'Perizia', 'Ubuntu' ),
-               'ml' => array( 'AnjaliOldLipi', 'Meera', 'Rachana', 
'RaghuMalayalam' ),
-               'or' => array( 'Lohit Oriya' ),
-               'ta' => array( 'Lohit Tamil' ),
-               'te' => array( 'Lohit Telugu' ),
-               'bn' => array( 'Lohit Bengali' ),
-               'as' => array( 'Lohit Bengali' ),
-               'gu' => array( 'Samyak Gujarati' ),
-               'hi' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
-               'mr' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
-               'ks' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
-               'he' => array( 'Miriam CLM', 'Taamey Frank CLM' ),
-               'kn' => array( 'Kedage', 'Lohit Kannada' ),
-               'my' => array( 'Masterpiece Uni Sans', 'Padauk-Regular', 
'Myanmar3', 'Yunghkio' ),
-               'km' => array( 'KhmerOSbattambang', 'KhmerOSsiemreap', 
'KhmerOS', 'KhmerOSbokor', 'KhmerOSmuollight', 'KhmerOSmuol', 
'KhmerOSmuolpali', 'KhmerOSfreehand', 'KhmerOSfasthand' ),
-               'saz' => array( 'Pagul' ),
-               'am' => array( 'AbyssinicaSIL' ),
-               'ti' => array( 'AbyssinicaSIL' ),
-               ),
-       );

Modified: trunk/extensions/WebFonts/WebFonts.hooks.php
===================================================================
--- trunk/extensions/WebFonts/WebFonts.hooks.php        2011-08-31 08:44:49 UTC 
(rev 95841)
+++ trunk/extensions/WebFonts/WebFonts.hooks.php        2011-08-31 10:00:44 UTC 
(rev 95842)
@@ -9,49 +9,15 @@
 // WebFonts hooks
 class WebFontsHooks {
 
-       /* Functions */
-       public static function addConfig( &$vars ) {
-               global $wgWebFontsEnabled;
-               global $wgUser;
-               if ( $wgUser->getOption( 'webfontsDisable' ) ) {
-                       // User disabled WebFonts
-                       return true;
-               }
-               $vars['wgWebFontsEnabled'] = $wgWebFontsEnabled;
-               return true; // Hooks must return value
-       }
-
-       public static function addVariables( &$vars ) {
-               global $wgWebFonts, $wgLang;
-               $vars['wgWebFonts'] = (array)$wgWebFonts;
-               $vars['wgWebFontsAvailable'] = self::getSchemes(); // Note: 
scheme names must be keys, not values
-               return true;
-       }
-
        public static function addModules( $out, $skin ) {
                global $wgUser;
-               if ( $wgUser->getOption( 'webfontsDisable' ) ) {
-                       // User disabled WebFonts
-                       return true;
+               if ( !$wgUser->getOption( 'webfontsDisable' ) ) {
+                       $out->addModules( 'webfonts' );
                }
-               $out->addModules( 'webfonts' );
+
                return true; // Hooks must return value
        }
 
-       /**
-        * Get the available schemes for the user and content language
-        * @return array( scheme name => module name )
-        */
-       protected static function getSchemes() {
-               global $wgLanguageCode, $wgLang, $wgWebFonts;
-               $userlangCode = $wgLang->getCode();
-               $contlangSchemes = isset( 
$wgWebFonts['languages'][$wgLanguageCode] ) ?
-                       $wgWebFonts['languages'][$wgLanguageCode] : array();
-               $userlangSchemes = isset( 
$wgWebFonts['languages'][$userlangCode] ) ?
-                       $wgWebFonts['languages'][$userlangCode] : array();
-               return $userlangSchemes + $contlangSchemes;
-       }
-
        public static function addPreference( $user, &$preferences ) {
                // A checkbox in preferences to disable WebFonts
                $preferences['webfontsDisable'] = array(

Modified: trunk/extensions/WebFonts/WebFonts.php
===================================================================
--- trunk/extensions/WebFonts/WebFonts.php      2011-08-31 08:44:49 UTC (rev 
95841)
+++ trunk/extensions/WebFonts/WebFonts.php      2011-08-31 10:00:44 UTC (rev 
95842)
@@ -32,11 +32,8 @@
 
 // Register auto load for the page class
 $wgAutoloadClasses['WebFontsHooks'] = "$dir/WebFonts.hooks.php";
-require_once( "$dir/WebFonts.config.php" );
 
 $wgHooks['BeforePageDisplay'][] = 'WebFontsHooks::addModules';
-$wgHooks['ResourceLoaderGetConfigVars'][] = 'WebFontsHooks::addConfig';
-$wgHooks['MakeGlobalVariablesScript'][] = 'WebFontsHooks::addVariables';
 $wgHooks['GetPreferences'][] = 'WebFontsHooks::addPreference';
 
 $wgWebFontsEnabled = true;
@@ -47,4 +44,11 @@
        'localBasePath' => dirname( __FILE__ ),
        'remoteExtPath' => 'WebFonts',
        'messages' => array( 'webfonts-load', 'webfonts-reset' ),
+       'dependencies' => 'webfonts.fontlist',
 );
+
+$wgResourceModules['webfonts.fontlist'] = array(
+       'scripts' => 'js/webfonts.fontlist.js',
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'WebFonts',
+);

Added: trunk/extensions/WebFonts/js/webfonts.fontlist.js
===================================================================
--- trunk/extensions/WebFonts/js/webfonts.fontlist.js                           
(rev 0)
+++ trunk/extensions/WebFonts/js/webfonts.fontlist.js   2011-08-31 10:00:44 UTC 
(rev 95842)
@@ -0,0 +1,258 @@
+/**
+ * Configuration file for webfonts
+ * First font is the default font for the language
+ */
+
+(function ($) {
+       $.webfonts = {};
+
+       $.webfonts.config = {
+               fonts: {
+                       RufScript: {
+                               eot: "en/Rufscript.eot",
+                               ttf: "en/Rufscript.ttf",
+                               woff: "en/Rufscript.woff"
+                       },
+                       Perizia: {
+                               eot: "en/Perizia.eot",
+                               ttf: "en/Perizia.ttf",
+                               woff: "en/Perizia.woff"
+                       },
+                       Ubuntu: {
+                               eot: "en/ubuntu-r-webfont.eot",
+                               ttf: "en/ubuntu-r.ttf",
+                               woff: "en/ubuntu-r-webfont.woff",
+                               svg: "en/ubuntu-r-webfont.svg"
+                       },
+                       
+                       AnjaliOldLipi: {
+                               eot: "ml/AnjaliOldLipi.eot",
+                               ttf: "ml/AnjaliOldLipi.ttf",
+                               woff: "ml/AnjaliOldLipi.woff"
+                       },
+                       Meera: {
+                               eot: "ml/Meera.eot",
+                               ttf: "ml/Meera.ttf",
+                               woff: "ml/Meera.woff",
+                               scale: 1.5,
+                               normalization: {
+                                       "ൾ": "ള്‍",
+                                       "ൻ": "ന്‍",
+                                       "ർ": "ര്‍",
+                                       "ൺ ": "ണ്‍",
+                                       "ൽ": "ല്‍",
+                                       "ൿ": "ക്‍ ",
+                                       "ൻ‍റ": "ന്റ",
+                                       "ന്‍റെ": "ന്റെ"
+                               }
+                       },
+                       Rachana: {
+                               eot: "ml/Rachana.eot",
+                               ttf: "ml/Rachana.ttf",
+                               woff: "ml/Rachana.woff",
+                               normalization: {
+                                       "ൾ": "ള്‍",
+                                       "ൻ": "ന്‍",
+                                       "ർ": "ര്‍",
+                                       "ൺ ": "ണ്‍",
+                                       "ൽ": "ല്‍",
+                                       "ൿ": "ക്‍ ",
+                                       "ൻ‍റ": "ന്റ",
+                                       "ന്‍റെ": "ന്റെ"
+                               }
+                       },
+                       RaghuMalayalam: {
+                               eot: "ml/RaghuMalayalam.eot",
+                               ttf: "ml/RaghuMalayalam.ttf",
+                               woff: "ml/RaghuMalayalam.woff",
+                               normalization: {
+                                       "ൾ": "ള്‍",
+                                       "ൻ": "ന്‍",
+                                       "ർ": "ര്‍",
+                                       "ൺ ": "ണ്‍",
+                                       "ൽ": "ല്‍",
+                                       "ൿ": "ക്‍ ",
+                                       "ൻ‍റ": "ന്റ",
+                                       "ന്‍റെ": "ന്റെ"
+                               }
+                       },
+                       
+                       "Lohit Oriya": {
+                               eot: "or/Lohit-Oriya.eot",
+                               ttf: "or/Lohit-Oriya.ttf",
+                               woff: "or/Lohit-Oriya.woff"
+                       },
+                       "Lohit Tamil": {
+                               eot: "ta/Lohit-Tamil.eot",
+                               ttf: "ta/Lohit-Tamil.ttf",
+                               woff: "ta/Lohit-Tamil.woff"
+                       },
+                       
+                       "Lohit Telugu": {
+                               eot: "te/LohitTelugu.eot",
+                               ttf: "te/LohitTelugu.ttf",
+                               woff: "te/LohitTelugu.woff"
+                       },
+                       
+                       "Lohit Bengali": {
+                               eot: "bn/LohitBengali.eot",
+                               ttf: "bn/LohitBengali.ttf",
+                               woff: "bn/LohitBengali.woff"
+                       },
+                       
+                       "Samyak Gujarati": {
+                               eot: "gu/SamyakGujarati.eot",
+                               ttf: "gu/SamyakGujarati.ttf",
+                               woff: "gu/SamyakGujarati.woff"
+                       },
+                       
+                       "Lohit Hindi": {
+                               eot: "hi/LohitHindi.eot",
+                               ttf: "hi/LohitHindi.ttf",
+                               woff: "hi/LohitHindi.woff"
+                       },
+                       "Samyak Devanagari": {
+                               eot: "hi/SamyakDevanagari.eot",
+                               ttf: "hi/SamyakDevanagari.ttf",
+                               woff: "hi/SamyakDevanagari.woff"
+                       },
+                       
+                       "Miriam CLM": {
+                               eot: "he/MiriamCLM-Book.eot",
+                               ttf: "he/MiriamCLM-Book.ttf",
+                               woff: "he/MiriamCLM-Book.woff"
+                       },
+                       "Taamey Frank CLM": {
+                               eot: "he/TaameyFrankCLM.eot",
+                               ttf: "he/TaameyFrankCLM.ttf",
+                               woff: "he/TaameyFrankCLM.woff",
+                               svg: "he/TaameyFrankCLM.svg"
+                       },
+                       
+                       Kedage: {
+                               eot: "kn/Kedage.eot",
+                               ttf: "kn/Kedage.ttf",
+                               woff: "kn/Kedage.woff"
+                       },
+                       "Lohit Kannada": {
+                               eot: "kn/LohitKannada.eot",
+                               ttf: "kn/LohitKannada.ttf",
+                               woff: "kn/LohitKannada.woff"
+                       },
+                       
+                       "Masterpiece Uni Sans": {
+                               eot: "my/MasterpieceUniSans.eot",
+                               ttf: "my/MasterpieceUniSans.ttf",
+                               woff: "my/MasterpieceUniSans.woff",
+                               svg:  "my/MasterpieceUniSans.svg"
+                       },
+                       "Padauk-Regular": {
+                               eot: "my/Padauk-Regular.eot",
+                               ttf: "my/Padauk-Regular.ttf",
+                               woff: "my/Padauk-Regular.woff",
+                               svg:  "my/Padauk-Regular.svg"
+                       },
+                       Myanmar3: {
+                               eot: "my/Myanmar3.eot",
+                               ttf: "my/Myanmar3.ttf",
+                               woff: "my/Myanmar3.woff",
+                               svg:  "my/Myanmar3.svg"
+                       },
+                       Yunghkio: {
+                               eot: "my/Yunghkio.eot",
+                               ttf: "my/Yunghkio.ttf",
+                               woff: "my/Yunghkio.woff",
+                               svg:  "my/Yunghkio.svg"
+                       },
+                       
+                       KhmerOSbattambang: {
+                               eot: "km/KhmerOSbattambang.eot",
+                               ttf: "km/KhmerOSbattambang.ttf",
+                               woff: "km/KhmerOSbattambang.woff",
+                               svg:  "km/KhmerOSbattambang.svg"
+                       },
+                       KhmerOSbokor: {
+                               eot: "km/KhmerOSbokor.eot",
+                               ttf: "km/KhmerOSbokor.ttf",
+                               woff: "km/KhmerOSbokor.woff",
+                               svg:  "km/KhmerOSbokor.svg"
+                       },
+                       KhmerOS: {
+                               eot: "km/KhmerOS.eot",
+                               ttf: "km/KhmerOS.ttf",
+                               woff: "km/KhmerOS.woff",
+                               svg:  "km/KhmerOS.svg"
+                       },
+                       KhmerOSsiemreap: {
+                               eot: "km/KhmerOSsiemreap.eot",
+                               ttf: "km/KhmerOSsiemreap.ttf",
+                               woff: "km/KhmerOSsiemreap.woff",
+                               svg:  "km/KhmerOSsiemreap.svg"
+                       },
+                       KhmerOSmuollight: {
+                               eot: "km/KhmerOSmuollight.eot",
+                               ttf: "km/KhmerOSmuollight.ttf",
+                               woff: "km/KhmerOSmuollight.woff",
+                               svg:  "km/KhmerOSmuollight.svg"
+                       },
+                       KhmerOSmuol: {
+                               eot: "km/KhmerOSmuol.eot",
+                               ttf: "km/KhmerOSmuol.ttf",
+                               woff: "km/KhmerOSmuol.woff",
+                               svg:  "km/KhmerOSmuol.svg"
+                       },
+                       KhmerOSmuolpali: {
+                               eot: "km/KhmerOSmuolpali.eot",
+                               ttf: "km/KhmerOSmuolpali.ttf",
+                               woff: "km/KhmerOSmuolpali.woff",
+                               svg:  "km/KhmerOSmuolpali.svg"
+                       },
+                       KhmerOSfreehand: {
+                               eot: "km/KhmerOSfreehand.eot",
+                               ttf: "km/KhmerOSfreehand.ttf",
+                               woff: "km/KhmerOSfreehand.woff",
+                               svg:  "km/KhmerOSfreehand.svg"
+                       },
+                       KhmerOSfasthand: {
+                               eot: "km/KhmerOSfasthand.eot",
+                               ttf: "km/KhmerOSfasthand.ttf",
+                               woff: "km/KhmerOSfasthand.woff",
+                               svg:  "km/KhmerOSfasthand.svg"
+                       },
+                       
+                       Pagul: {
+                               eot: "saz/Pagul.eot",
+                               ttf: "saz/Pagul.ttf",
+                               woff: "saz/Pagul.woff"
+                       },
+                       AbyssinicaSIL: {
+                               eot: "gez/AbyssinicaSIL-R.eot",
+                               ttf: "gez/AbyssinicaSIL-R.ttf",
+                               woff: "gez/AbyssinicaSIL-R.woff"
+                       }
+               },
+
+               languages: {
+                       // en: [ "RufScript", "Perizia", "Ubuntu" ],
+                       ml: [ "AnjaliOldLipi", "Meera", "Rachana", 
"RaghuMalayalam" ],
+                       or: [ "Lohit Oriya" ],
+                       ta: [ "Lohit Tamil" ],
+                       te: [ "Lohit Telugu" ],
+                       bn: [ "Lohit Bengali" ],
+                       as: [ "Lohit Bengali" ],
+                       gu: [ "Samyak Gujarati" ],
+                       hi: [ "Samyak Devanagari", "Lohit Hindi" ],
+                       mr: [ "Samyak Devanagari", "Lohit Hindi" ],
+                       ks: [ "Samyak Devanagari", "Lohit Hindi" ],
+                       he: [ "Miriam CLM", "Taamey Frank CLM" ],
+                       kn: [ "Kedage", "Lohit Kannada" ],
+                       my: [ "Masterpiece Uni Sans", "Padauk-Regular", 
"Myanmar3", "Yunghkio" ],
+                       km: [ "KhmerOSbattambang", "KhmerOSsiemreap", 
"KhmerOS", "KhmerOSbokor",
+                             "KhmerOSmuollight", "KhmerOSmuol", 
"KhmerOSmuolpali",
+                             "KhmerOSfreehand", "KhmerOSfasthand" ],
+                       saz: [ "Pagul" ],
+                       am: [ "AbyssinicaSIL" ],
+                       ti: [ "AbyssinicaSIL" ]
+               }
+       };
+})(jQuery);
\ No newline at end of file


Property changes on: trunk/extensions/WebFonts/js/webfonts.fontlist.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/WebFonts/js/webfonts.js
===================================================================
--- trunk/extensions/WebFonts/js/webfonts.js    2011-08-31 08:44:49 UTC (rev 
95841)
+++ trunk/extensions/WebFonts/js/webfonts.js    2011-08-31 10:00:44 UTC (rev 
95842)
@@ -4,7 +4,7 @@
 
                
                oldconfig: false,
-               config : mw.config.get( "wgWebFonts" ),
+               config : $.webfonts.config,
                /* Version number */
                version: "0.1.2",
                set: function( font ) {
@@ -16,9 +16,9 @@
                        if ( !font in $.webfonts.config.fonts ) {
                                console.log( "Requested unknown font", font );
                                return;
-                       } else {
-                               config = $.webfonts.config.fonts[font];
                        }
+                       var config = $.webfonts.config.fonts[font];
+
                        //load the style sheet for the font
                        $.webfonts.loadcss(font);
 
@@ -27,7 +27,7 @@
                                $.webfonts.oldconfig = {
                                        "font-family": 
$("body").css('font-family'),
                                        "font-size":   
$("body").css('font-size')
-                               }
+                               };
                        }
 
                        //Set the font, fallback fonts.Need to change the fonts 
of Input Select and Textarea explicitly.
@@ -108,7 +108,7 @@
                 */
                loadcss: function(fontfamily){
                        var fontconfig = $.webfonts.config.fonts[fontfamily];
-                       var base = $.webfonts.config.basepath;
+                       var base = mw.config.get( "wgExtensionAssetsPath" ) + 
"/WebFonts/fonts/";
                        var styleString =
                                "<style type='text/css'>\n@font-face {\n"
                                + "\tfont-family: '"+fontfamily+"';\n";
@@ -139,7 +139,20 @@
                  * It also apply the font from cookie, if any.
                  */
                setup: function() {
-                       var config = mw.config.get( "wgWebFontsAvailable" );
+                       var config = [];
+                       var languages = $.webfonts.config.languages;
+                       var requested = [wgUserLanguage, wgContentLanguage];
+                       for (var i = 0; i < requested.length; i++) {
+                               if (requested[i] in languages) {
+                                       var fonts = languages[requested[i]];
+                                       for (var j = 0; j < fonts.length; j++) {
+                                               if ( $.inArray(fonts[j], 
config) === -1 ) {
+                                                       config.push(fonts[j]);
+                                               }
+                                       }
+                               }
+                       }
+
                        // Build font dropdown
                        $.webfonts.buildMenu(config );
                        //see if there is a font in cookie


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to