r95840 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95839‎ | r95840 | r95841 >
Date:08:23, 31 August 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Condense the font definition structure by isolating basepath - part of bug 29318
Modified paths:
  • /trunk/extensions/WebFonts/WebFonts.config.php (modified) (history)
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/WebFonts.config.php
@@ -5,35 +5,35 @@
66 * @file
77 * @ingroup Extensions
88 */
9 -$fontsPath = "$wgScriptPath/extensions/WebFonts/fonts";
109 $wgWebFonts = array(
 10+ 'basepath' => "$wgScriptPath/extensions/WebFonts/fonts/",
1111 'fonts' => array(
1212 'RufScript' => array(
13 - 'eot' => "$fontsPath/en/Rufscript.eot",
14 - 'ttf' => "$fontsPath/en/Rufscript.ttf",
15 - 'woff' => "$fontsPath/en/Rufscript.woff",
 13+ 'eot' => "en/Rufscript.eot",
 14+ 'ttf' => "en/Rufscript.ttf",
 15+ 'woff' => "en/Rufscript.woff",
1616 ),
1717
1818 'Perizia' => array(
19 - 'eot' => "$fontsPath/en/Perizia.eot",
20 - 'ttf' => "$fontsPath/en/Perizia.ttf",
21 - 'woff' => "$fontsPath/en/Perizia.woff",
 19+ 'eot' => "en/Perizia.eot",
 20+ 'ttf' => "en/Perizia.ttf",
 21+ 'woff' => "en/Perizia.woff",
2222 ),
2323 'Ubuntu' => array(
24 - 'eot' => "$fontsPath/en/ubuntu-r-webfont.eot",
25 - 'ttf' => "$fontsPath/en/ubuntu-r.ttf",
26 - 'woff' => "$fontsPath/en/ubuntu-r-webfont.woff",
27 - 'svg' => "$fontsPath/en/ubuntu-r-webfont.svg",
 24+ 'eot' => "en/ubuntu-r-webfont.eot",
 25+ 'ttf' => "en/ubuntu-r.ttf",
 26+ 'woff' => "en/ubuntu-r-webfont.woff",
 27+ 'svg' => "en/ubuntu-r-webfont.svg",
2828 ),
29 - 'AnjaliOldLipi' => array(
30 - 'eot' => "$fontsPath/ml/AnjaliOldLipi.eot",
31 - 'ttf' => "$fontsPath/ml/AnjaliOldLipi.ttf",
32 - 'woff' => "$fontsPath/ml/AnjaliOldLipi.woff",
 29+ 'AnjaliOldLipi' => array(
 30+ 'eot' => "ml/AnjaliOldLipi.eot",
 31+ 'ttf' => "ml/AnjaliOldLipi.ttf",
 32+ 'woff' => "ml/AnjaliOldLipi.woff",
3333 ),
3434 'Meera' => array(
35 - 'eot' => "$fontsPath/ml/Meera.eot",
36 - 'ttf' => "$fontsPath/ml/Meera.ttf",
37 - 'woff' => "$fontsPath/ml/Meera.woff",
 35+ 'eot' => "ml/Meera.eot",
 36+ 'ttf' => "ml/Meera.ttf",
 37+ 'woff' => "ml/Meera.woff",
3838 'scale' => 1.5,
3939 'normalization' => array(
4040 "ൾ" => "ള്‍",
@@ -48,9 +48,9 @@
4949 ),
5050
5151 'Rachana' => array(
52 - 'eot' => "$fontsPath/ml/Rachana.eot",
53 - 'ttf' => "$fontsPath/ml/Rachana.ttf",
54 - 'woff' => "$fontsPath/ml/Rachana.woff",
 52+ 'eot' => "ml/Rachana.eot",
 53+ 'ttf' => "ml/Rachana.ttf",
 54+ 'woff' => "ml/Rachana.woff",
5555 'normalization' => array(
5656 "ൾ" => "ള്‍",
5757 "ൻ" => "ന്‍",
@@ -63,9 +63,9 @@
6464 )
6565 ),
6666 'RaghuMalayalam' => array(
67 - 'eot' => "$fontsPath/ml/RaghuMalayalam.eot",
68 - 'ttf' => "$fontsPath/ml/RaghuMalayalam.ttf",
69 - 'woff' => "$fontsPath/ml/RaghuMalayalam.woff",
 67+ 'eot' => "ml/RaghuMalayalam.eot",
 68+ 'ttf' => "ml/RaghuMalayalam.ttf",
 69+ 'woff' => "ml/RaghuMalayalam.woff",
7070 'normalization' => array(
7171 "ൾ" => "ള്‍",
7272 "ൻ" => "ന്‍",
@@ -78,148 +78,148 @@
7979 )
8080 ),
8181 'Lohit Oriya' => array(
82 - 'eot' => "$fontsPath/or/Lohit-Oriya.eot",
83 - 'ttf' => "$fontsPath/or/Lohit-Oriya.ttf",
84 - 'woff' => "$fontsPath/or/Lohit-Oriya.woff",
 82+ 'eot' => "or/Lohit-Oriya.eot",
 83+ 'ttf' => "or/Lohit-Oriya.ttf",
 84+ 'woff' => "or/Lohit-Oriya.woff",
8585 ),
8686 'Lohit Tamil' => array(
87 - 'eot' => "$fontsPath/ta/Lohit-Tamil.eot",
88 - 'ttf' => "$fontsPath/ta/Lohit-Tamil.ttf",
89 - 'woff' => "$fontsPath/ta/Lohit-Tamil.woff",
 87+ 'eot' => "ta/Lohit-Tamil.eot",
 88+ 'ttf' => "ta/Lohit-Tamil.ttf",
 89+ 'woff' => "ta/Lohit-Tamil.woff",
9090 ),
9191 'Lohit Telugu' => array(
92 - 'eot' => "$fontsPath/te/LohitTelugu.eot",
93 - 'ttf' => "$fontsPath/te/LohitTelugu.ttf",
94 - 'woff' => "$fontsPath/te/LohitTelugu.woff",
 92+ 'eot' => "te/LohitTelugu.eot",
 93+ 'ttf' => "te/LohitTelugu.ttf",
 94+ 'woff' => "te/LohitTelugu.woff",
9595 ),
9696 'Lohit Bengali' => array(
97 - 'eot' => "$fontsPath/bn/LohitBengali.eot",
98 - 'ttf' => "$fontsPath/bn/LohitBengali.ttf",
99 - 'woff' => "$fontsPath/bn/LohitBengali.woff",
 97+ 'eot' => "bn/LohitBengali.eot",
 98+ 'ttf' => "bn/LohitBengali.ttf",
 99+ 'woff' => "bn/LohitBengali.woff",
100100 ),
101101 'Samyak Gujarati' => array(
102 - 'eot' => "$fontsPath/gu/SamyakGujarati.eot",
103 - 'ttf' => "$fontsPath/gu/SamyakGujarati.ttf",
104 - 'woff' => "$fontsPath/gu/SamyakGujarati.woff",
 102+ 'eot' => "gu/SamyakGujarati.eot",
 103+ 'ttf' => "gu/SamyakGujarati.ttf",
 104+ 'woff' => "gu/SamyakGujarati.woff",
105105 ),
106106 'Lohit Hindi' => array(
107 - 'eot' => "$fontsPath/hi/LohitHindi.eot",
108 - 'ttf' => "$fontsPath/hi/LohitHindi.ttf",
109 - 'woff' => "$fontsPath/hi/LohitHindi.woff",
 107+ 'eot' => "hi/LohitHindi.eot",
 108+ 'ttf' => "hi/LohitHindi.ttf",
 109+ 'woff' => "hi/LohitHindi.woff",
110110 ),
111111 'Samyak Devanagari' => array(
112 - 'eot' => "$fontsPath/hi/SamyakDevanagari.eot",
113 - 'ttf' => "$fontsPath/hi/SamyakDevanagari.ttf",
114 - 'woff' => "$fontsPath/hi/SamyakDevanagari.woff",
 112+ 'eot' => "hi/SamyakDevanagari.eot",
 113+ 'ttf' => "hi/SamyakDevanagari.ttf",
 114+ 'woff' => "hi/SamyakDevanagari.woff",
115115 ),
116116 'Miriam CLM' => array(
117 - 'eot' => "$fontsPath/he/MiriamCLM-Book.eot",
118 - 'ttf' => "$fontsPath/he/MiriamCLM-Book.ttf",
119 - 'woff' => "$fontsPath/he/MiriamCLM-Book.woff",
 117+ 'eot' => "he/MiriamCLM-Book.eot",
 118+ 'ttf' => "he/MiriamCLM-Book.ttf",
 119+ 'woff' => "he/MiriamCLM-Book.woff",
120120 ),
121121 'Taamey Frank CLM' => array(
122 - 'eot' => "$fontsPath/he/TaameyFrankCLM.eot",
123 - 'ttf' => "$fontsPath/he/TaameyFrankCLM.ttf",
124 - 'woff' => "$fontsPath/he/TaameyFrankCLM.woff",
125 - 'svg' => "$fontsPath/he/TaameyFrankCLM.svg",
 122+ 'eot' => "he/TaameyFrankCLM.eot",
 123+ 'ttf' => "he/TaameyFrankCLM.ttf",
 124+ 'woff' => "he/TaameyFrankCLM.woff",
 125+ 'svg' => "he/TaameyFrankCLM.svg",
126126 ),
127127 'Kedage' => array(
128 - 'eot' => "$fontsPath/kn/Kedage.eot",
129 - 'ttf' => "$fontsPath/kn/Kedage.ttf",
130 - 'woff' => "$fontsPath/kn/Kedage.woff",
 128+ 'eot' => "kn/Kedage.eot",
 129+ 'ttf' => "kn/Kedage.ttf",
 130+ 'woff' => "kn/Kedage.woff",
131131 ),
132132 'Lohit Kannada' => array(
133 - 'eot' => "$fontsPath/kn/LohitKannada.eot",
134 - 'ttf' => "$fontsPath/kn/LohitKannada.ttf",
135 - 'woff' => "$fontsPath/kn/LohitKannada.woff",
 133+ 'eot' => "kn/LohitKannada.eot",
 134+ 'ttf' => "kn/LohitKannada.ttf",
 135+ 'woff' => "kn/LohitKannada.woff",
136136 ),
137137 'Masterpiece Uni Sans' => array(
138 - 'eot' => "$fontsPath/my/MasterpieceUniSans.eot",
139 - 'ttf' => "$fontsPath/my/MasterpieceUniSans.ttf",
140 - 'woff' => "$fontsPath/my/MasterpieceUniSans.woff",
141 - 'svg' => "$fontsPath/my/MasterpieceUniSans.svg",
 138+ 'eot' => "my/MasterpieceUniSans.eot",
 139+ 'ttf' => "my/MasterpieceUniSans.ttf",
 140+ 'woff' => "my/MasterpieceUniSans.woff",
 141+ 'svg' => "my/MasterpieceUniSans.svg",
142142 ),
143143 'Padauk-Regular' => array(
144 - 'eot' => "$fontsPath/my/Padauk-Regular.eot",
145 - 'ttf' => "$fontsPath/my/Padauk-Regular.ttf",
146 - 'woff' => "$fontsPath/my/Padauk-Regular.woff",
147 - 'svg' => "$fontsPath/my/Padauk-Regular.svg",
 144+ 'eot' => "my/Padauk-Regular.eot",
 145+ 'ttf' => "my/Padauk-Regular.ttf",
 146+ 'woff' => "my/Padauk-Regular.woff",
 147+ 'svg' => "my/Padauk-Regular.svg",
148148 ),
149149 'Myanmar3' => array(
150 - 'eot' => "$fontsPath/my/Myanmar3.eot",
151 - 'ttf' => "$fontsPath/my/Myanmar3.ttf",
152 - 'woff' => "$fontsPath/my/Myanmar3.woff",
153 - 'svg' => "$fontsPath/my/Myanmar3.svg",
 150+ 'eot' => "my/Myanmar3.eot",
 151+ 'ttf' => "my/Myanmar3.ttf",
 152+ 'woff' => "my/Myanmar3.woff",
 153+ 'svg' => "my/Myanmar3.svg",
154154 ),
155155 'Yunghkio' => array(
156 - 'eot' => "$fontsPath/my/Yunghkio.eot",
157 - 'ttf' => "$fontsPath/my/Yunghkio.ttf",
158 - 'woff' => "$fontsPath/my/Yunghkio.woff",
159 - 'svg' => "$fontsPath/my/Yunghkio.svg",
 156+ 'eot' => "my/Yunghkio.eot",
 157+ 'ttf' => "my/Yunghkio.ttf",
 158+ 'woff' => "my/Yunghkio.woff",
 159+ 'svg' => "my/Yunghkio.svg",
160160 ),
161161 'KhmerOSbattambang' => array(
162 - 'eot' => "$fontsPath/km/KhmerOSbattambang.eot",
163 - 'ttf' => "$fontsPath/km/KhmerOSbattambang.ttf",
164 - 'woff' => "$fontsPath/km/KhmerOSbattambang.woff",
165 - 'svg' => "$fontsPath/km/KhmerOSbattambang.svg",
 162+ 'eot' => "km/KhmerOSbattambang.eot",
 163+ 'ttf' => "km/KhmerOSbattambang.ttf",
 164+ 'woff' => "km/KhmerOSbattambang.woff",
 165+ 'svg' => "km/KhmerOSbattambang.svg",
166166 ),
167167 'KhmerOSbokor' => array(
168 - 'eot' => "$fontsPath/km/KhmerOSbokor.eot",
169 - 'ttf' => "$fontsPath/km/KhmerOSbokor.ttf",
170 - 'woff' => "$fontsPath/km/KhmerOSbokor.woff",
171 - 'svg' => "$fontsPath/km/KhmerOSbokor.svg",
 168+ 'eot' => "km/KhmerOSbokor.eot",
 169+ 'ttf' => "km/KhmerOSbokor.ttf",
 170+ 'woff' => "km/KhmerOSbokor.woff",
 171+ 'svg' => "km/KhmerOSbokor.svg",
172172 ),
173173 'KhmerOS' => array(
174 - 'eot' => "$fontsPath/km/KhmerOS.eot",
175 - 'ttf' => "$fontsPath/km/KhmerOS.ttf",
176 - 'woff' => "$fontsPath/km/KhmerOS.woff",
177 - 'svg' => "$fontsPath/km/KhmerOS.svg",
 174+ 'eot' => "km/KhmerOS.eot",
 175+ 'ttf' => "km/KhmerOS.ttf",
 176+ 'woff' => "km/KhmerOS.woff",
 177+ 'svg' => "km/KhmerOS.svg",
178178 ),
179179 'KhmerOSsiemreap' => array(
180 - 'eot' => "$fontsPath/km/KhmerOSsiemreap.eot",
181 - 'ttf' => "$fontsPath/km/KhmerOSsiemreap.ttf",
182 - 'woff' => "$fontsPath/km/KhmerOSsiemreap.woff",
183 - 'svg' => "$fontsPath/km/KhmerOSsiemreap.svg",
 180+ 'eot' => "km/KhmerOSsiemreap.eot",
 181+ 'ttf' => "km/KhmerOSsiemreap.ttf",
 182+ 'woff' => "km/KhmerOSsiemreap.woff",
 183+ 'svg' => "km/KhmerOSsiemreap.svg",
184184 ),
185185 'KhmerOSmuollight' => array(
186 - 'eot' => "$fontsPath/km/KhmerOSmuollight.eot",
187 - 'ttf' => "$fontsPath/km/KhmerOSmuollight.ttf",
188 - 'woff' => "$fontsPath/km/KhmerOSmuollight.woff",
189 - 'svg' => "$fontsPath/km/KhmerOSmuollight.svg",
 186+ 'eot' => "km/KhmerOSmuollight.eot",
 187+ 'ttf' => "km/KhmerOSmuollight.ttf",
 188+ 'woff' => "km/KhmerOSmuollight.woff",
 189+ 'svg' => "km/KhmerOSmuollight.svg",
190190 ),
191191 'KhmerOSmuol' => array(
192 - 'eot' => "$fontsPath/km/KhmerOSmuol.eot",
193 - 'ttf' => "$fontsPath/km/KhmerOSmuol.ttf",
194 - 'woff' => "$fontsPath/km/KhmerOSmuol.woff",
195 - 'svg' => "$fontsPath/km/KhmerOSmuol.svg",
 192+ 'eot' => "km/KhmerOSmuol.eot",
 193+ 'ttf' => "km/KhmerOSmuol.ttf",
 194+ 'woff' => "km/KhmerOSmuol.woff",
 195+ 'svg' => "km/KhmerOSmuol.svg",
196196 ),
197197 'KhmerOSmuolpali' => array(
198 - 'eot' => "$fontsPath/km/KhmerOSmuolpali.eot",
199 - 'ttf' => "$fontsPath/km/KhmerOSmuolpali.ttf",
200 - 'woff' => "$fontsPath/km/KhmerOSmuolpali.woff",
201 - 'svg' => "$fontsPath/km/KhmerOSmuolpali.svg",
 198+ 'eot' => "km/KhmerOSmuolpali.eot",
 199+ 'ttf' => "km/KhmerOSmuolpali.ttf",
 200+ 'woff' => "km/KhmerOSmuolpali.woff",
 201+ 'svg' => "km/KhmerOSmuolpali.svg",
202202 ),
203203 'KhmerOSfreehand' => array(
204 - 'eot' => "$fontsPath/km/KhmerOSfreehand.eot",
205 - 'ttf' => "$fontsPath/km/KhmerOSfreehand.ttf",
206 - 'woff' => "$fontsPath/km/KhmerOSfreehand.woff",
207 - 'svg' => "$fontsPath/km/KhmerOSfreehand.svg",
 204+ 'eot' => "km/KhmerOSfreehand.eot",
 205+ 'ttf' => "km/KhmerOSfreehand.ttf",
 206+ 'woff' => "km/KhmerOSfreehand.woff",
 207+ 'svg' => "km/KhmerOSfreehand.svg",
208208 ),
209209 'KhmerOSfasthand' => array(
210 - 'eot' => "$fontsPath/km/KhmerOSfasthand.eot",
211 - 'ttf' => "$fontsPath/km/KhmerOSfasthand.ttf",
212 - 'woff' => "$fontsPath/km/KhmerOSfasthand.woff",
213 - 'svg' => "$fontsPath/km/KhmerOSfasthand.svg",
 210+ 'eot' => "km/KhmerOSfasthand.eot",
 211+ 'ttf' => "km/KhmerOSfasthand.ttf",
 212+ 'woff' => "km/KhmerOSfasthand.woff",
 213+ 'svg' => "km/KhmerOSfasthand.svg",
214214 ),
215215 'Pagul' => array(
216 - 'eot' => "$fontsPath/saz/Pagul.eot",
217 - 'ttf' => "$fontsPath/saz/Pagul.ttf",
218 - 'woff' => "$fontsPath/saz/Pagul.woff",
 216+ 'eot' => "saz/Pagul.eot",
 217+ 'ttf' => "saz/Pagul.ttf",
 218+ 'woff' => "saz/Pagul.woff",
219219 ),
220220 'AbyssinicaSIL'=> array(
221 - 'eot' => "$fontsPath/gez/AbyssinicaSIL-R.eot",
222 - 'ttf' => "$fontsPath/gez/AbyssinicaSIL-R.ttf",
223 - 'woff' => "$fontsPath/gez/AbyssinicaSIL-R.woff",
 221+ 'eot' => "gez/AbyssinicaSIL-R.eot",
 222+ 'ttf' => "gez/AbyssinicaSIL-R.ttf",
 223+ 'woff' => "gez/AbyssinicaSIL-R.woff",
224224 ),
225225 ),
226226
Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -108,23 +108,24 @@
109109 */
110110 loadcss: function(fontfamily){
111111 var fontconfig = $.webfonts.config.fonts[fontfamily];
 112+ var base = $.webfonts.config.basepath;
112113 var styleString =
113114 "<style type='text/css'>\n@font-face {\n"
114115 + "\tfont-family: '"+fontfamily+"';\n";
115116 if ( 'eot' in fontconfig ) {
116 - styleString += "\tsrc: url('"+fontconfig.eot+"');\n";
 117+ styleString += "\tsrc: url('"+base+fontconfig.eot+"');\n";
117118 }
118119 //If the font is present locally, use it.
119120 styleString += "\tsrc: local('"+ fontfamily +"'),";
120121
121122 if ( 'woff' in fontconfig ) {
122 - styleString += "\t\turl('"+fontconfig.woff+"') format('woff'),";
 123+ styleString += "\t\turl('"+base+fontconfig.woff+"') format('woff'),";
123124 }
124125 if ( 'svg' in fontconfig ) {
125 - styleString += "\t\turl('"+fontconfig.svg+"#"+fontfamily+"') format('svg'),";
 126+ styleString += "\t\turl('"+base+fontconfig.svg+"#"+fontfamily+"') format('svg'),";
126127 }
127128 if ( 'ttf' in fontconfig ) {
128 - styleString += "\t\turl('"+fontconfig.ttf+"') format('truetype');\n";
 129+ styleString += "\t\turl('"+base+fontconfig.ttf+"') format('truetype');\n";
129130 }
130131
131132 styleString += "\tfont-weight: normal;\n}\n</style>\n";

Follow-up revisions

RevisionCommit summaryAuthorDate
r95842Move the list of available fonts into a module, so that they are not increasi...nikerabbit10:00, 31 August 2011

Status & tagging log