webfontloader 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v1.3.0 (February 28, 2013)
2
+ * New optional configuration parameter `timeout` which lets you customize the default timeout.
3
+ * Change the Typekit module to use `use.typekit.net` instead of `use.typekit.com`.
4
+ * Disable height check on OSX and iOS WebKit based browsers which suffer from a metrics bug when loading web fonts.
5
+
1
6
  v1.2.1 (February 26, 2013)
2
7
  * Fix the possibility of test strings wrapping to a new line and thereby breaking font watching.
3
8
  * Change the FontWatchRunner to not create DOM elements until it is started.
data/docs/EVENTS.md CHANGED
@@ -112,7 +112,18 @@ load. You can use events to gracefully degrade in this situation.
112
112
 
113
113
  > The `Font Inactive` event will be triggered after 5 seconds if the font
114
114
  fails to render. If *at least* one font succesfully renders, the `Active`
115
- event will be triggered, else the `Inative` even will be triggered.
115
+ event will be triggered, else the `Inactive` even will be triggered.
116
+
117
+ You can configure the timeout by using the `timeout` configuration on the
118
+ `WebFont.load` function.
119
+
120
+ WebFont.load({
121
+ timeout: 2000, // Set the timeout to two seconds
122
+ ...
123
+ });
124
+
125
+ The timeout value should be in milliseconds, and defaults to 5 seconds if
126
+ not supplied.
116
127
 
117
128
  ### Browser Support
118
129
 
data/lib/webfontloader.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.2.1'
6
+ VERSION = '1.3.0'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
@@ -7,7 +7,7 @@ describe('WebFont', function () {
7
7
  userAgent = null;
8
8
 
9
9
  beforeEach(function () {
10
- userAgent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false));
10
+ userAgent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false));
11
11
  fontModuleLoader = new FontModuleLoader();
12
12
  });
13
13
 
@@ -190,7 +190,7 @@ describe('WebFont', function () {
190
190
  testModule = null;
191
191
 
192
192
  beforeEach(function () {
193
- font = new WebFont(window, fontModuleLoader, function (func, timeout) { func(); }, new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(false, false)));
193
+ font = new WebFont(window, fontModuleLoader, function (func, timeout) { func(); }, new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(false, false, false)));
194
194
  font.addModule('test', function (conf, domHelper) {
195
195
  testModule = new function () {
196
196
  this.conf = conf;
@@ -6,13 +6,15 @@ describe('FontWatcher', function () {
6
6
  domHelper = new DomHelper(window),
7
7
  eventDispatcher = {},
8
8
  testStrings = null,
9
+ timeout = null,
9
10
  userAgent = null,
10
11
  activeFontFamilies = [];
11
12
 
12
13
  beforeEach(function () {
13
- userAgent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.3', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false));
14
+ userAgent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.3', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false));
14
15
  activeFontFamilies = [];
15
16
  testStrings = jasmine.createSpy('testStrings');
17
+ timeout = jasmine.createSpy('timeout');
16
18
  eventDispatcher.dispatchLoading = jasmine.createSpy('dispatchLoading');
17
19
  eventDispatcher.dispatchFontLoading = jasmine.createSpy('dispatchFontLoading');
18
20
  eventDispatcher.dispatchFontActive = jasmine.createSpy('dispatchFontActive');
@@ -22,11 +24,12 @@ describe('FontWatcher', function () {
22
24
  });
23
25
 
24
26
  function FakeFontWatchRunner(activeCallback, inactiveCallback, domHelper, fontSizer, asyncCall, getTime,
25
- fontFamily, fontDescription, hasWebKitFallbackBug, opt_metricCompatibleFonts, opt_fontTestString) {
27
+ fontFamily, fontDescription, hasWebKitFallbackBug, opt_timeout, opt_metricCompatibleFonts, opt_fontTestString) {
26
28
  this.activeCallback = activeCallback;
27
29
  this.inactiveCallback = inactiveCallback;
28
30
  this.fontFamily = fontFamily;
29
31
  this.fontDescription = fontDescription;
32
+ timeout(opt_timeout);
30
33
 
31
34
  if (opt_fontTestString) {
32
35
  testStrings(opt_fontTestString);
@@ -201,4 +204,13 @@ describe('FontWatcher', function () {
201
204
  expect(testStrings).toHaveBeenCalledWith('testString2');
202
205
  });
203
206
  });
207
+
208
+ it('should pass on the timeout to FontWatchRunner', function () {
209
+ var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher, jasmine.createSpy('fakeFontSizer'),
210
+ jasmine.createSpy('fakeAsyncCall'), jasmine.createSpy('fakeGetTime'), 4000);
211
+
212
+ fontWatcher.watch(['fontFamily1'], {}, {}, FakeFontWatchRunner, true);
213
+
214
+ expect(timeout).toHaveBeenCalledWith(4000);
215
+ });
204
216
  });
@@ -1,5 +1,6 @@
1
1
  describe('FontWatchRunner', function () {
2
2
  var FontWatchRunner = webfont.FontWatchRunner,
3
+ BrowserInfo = webfont.BrowserInfo,
3
4
  UserAgentParser = webfont.UserAgentParser,
4
5
  Size = webfont.Size,
5
6
  DomHelper = webfont.DomHelper,
@@ -14,6 +15,7 @@ describe('FontWatchRunner', function () {
14
15
  FALLBACK_SIZE_B = new Size(2, 2),
15
16
  LAST_RESORT_SIZE = new Size(4, 4),
16
17
 
18
+ browserInfo = new BrowserInfo(true, false, false),
17
19
  setupSizes = [FALLBACK_SIZE_A, FALLBACK_SIZE_B, LAST_RESORT_SIZE],
18
20
  actualSizes = [],
19
21
  fakeGetSizeCount = 0,
@@ -85,7 +87,7 @@ describe('FontWatchRunner', function () {
85
87
  ];
86
88
 
87
89
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
88
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, false);
90
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
89
91
 
90
92
  fontWatchRunner.start();
91
93
 
@@ -102,7 +104,7 @@ describe('FontWatchRunner', function () {
102
104
  ];
103
105
 
104
106
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
105
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, false);
107
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
106
108
 
107
109
  fontWatchRunner.start();
108
110
  expect(asyncCount).toEqual(3);
@@ -121,7 +123,7 @@ describe('FontWatchRunner', function () {
121
123
  ];
122
124
 
123
125
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
124
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, false);
126
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
125
127
 
126
128
  fontWatchRunner.start();
127
129
 
@@ -130,6 +132,12 @@ describe('FontWatchRunner', function () {
130
132
  });
131
133
 
132
134
  describe('WebKit fallback bug', function () {
135
+ var fallbackBugBrowserInfo = null;
136
+
137
+ beforeEach(function () {
138
+ fallbackBugBrowserInfo = new BrowserInfo(true, true, false);
139
+ });
140
+
133
141
  it('should ignore fallback size and call active', function () {
134
142
  actualSizes = [
135
143
  LAST_RESORT_SIZE, LAST_RESORT_SIZE,
@@ -137,7 +145,7 @@ describe('FontWatchRunner', function () {
137
145
  ];
138
146
 
139
147
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
140
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
148
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, fallbackBugBrowserInfo);
141
149
 
142
150
  fontWatchRunner.start();
143
151
 
@@ -154,7 +162,7 @@ describe('FontWatchRunner', function () {
154
162
  timesToGetTimeBeforeTimeout = 2;
155
163
 
156
164
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
157
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
165
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, fallbackBugBrowserInfo);
158
166
 
159
167
  fontWatchRunner.start();
160
168
 
@@ -172,7 +180,7 @@ describe('FontWatchRunner', function () {
172
180
  timesToGetTimeBeforeTimeout = 3;
173
181
 
174
182
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
175
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
183
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, fallbackBugBrowserInfo);
176
184
 
177
185
  fontWatchRunner.start();
178
186
 
@@ -189,8 +197,8 @@ describe('FontWatchRunner', function () {
189
197
  timesToGetTimeBeforeTimeout = 2;
190
198
 
191
199
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
192
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true,
193
- { 'My Other Family': true });
200
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, fallbackBugBrowserInfo,
201
+ 0, { 'My Other Family': true });
194
202
 
195
203
  fontWatchRunner.start();
196
204
  expect(asyncCount).toEqual(1);
@@ -206,8 +214,8 @@ describe('FontWatchRunner', function () {
206
214
  timesToGetTimeBeforeTimeout = 2;
207
215
 
208
216
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
209
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true,
210
- { 'My Family': true });
217
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, fallbackBugBrowserInfo,
218
+ 0, { 'My Family': true });
211
219
 
212
220
  fontWatchRunner.start();
213
221
  expect(asyncCount).toEqual(1);
@@ -215,6 +223,24 @@ describe('FontWatchRunner', function () {
215
223
  });
216
224
  });
217
225
 
226
+ describe('webkit metrics bug', function () {
227
+ it('should correctly call active even though the height is different', function () {
228
+ actualSizes = [
229
+ FALLBACK_SIZE_A, FALLBACK_SIZE_B,
230
+ new Size(1, 2), new Size(2, 3), // Same as FALLBACK_SIZE_A and FALLBACK_SIZE_B except that the height is different.
231
+ TARGET_SIZE, TARGET_SIZE
232
+ ];
233
+
234
+ var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
235
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, new BrowserInfo(true, false, true));
236
+
237
+ fontWatchRunner.start();
238
+
239
+ expect(asyncCount).toEqual(2);
240
+ expect(activeCallback).toHaveBeenCalledWith('My Family', 'n4');
241
+ });
242
+ });
243
+
218
244
  describe('real browser testing', function () {
219
245
  var fontSizer = null,
220
246
  asyncCall = null,
@@ -243,7 +269,8 @@ describe('FontWatchRunner', function () {
243
269
 
244
270
  it('should fail to load a null font', function () {
245
271
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
246
- domHelper, fontSizer, asyncCall, getTime, '__webfontloader_test__', '', userAgent.getBrowserInfo().hasWebKitFallbackBug());
272
+ domHelper, fontSizer, asyncCall, getTime, '__webfontloader_test__', '',
273
+ userAgent.getBrowserInfo(), 500);
247
274
 
248
275
  runs(function () {
249
276
  fontWatchRunner.start();
@@ -260,7 +287,8 @@ describe('FontWatchRunner', function () {
260
287
 
261
288
  it('should load font succesfully', function () {
262
289
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
263
- domHelper, fontSizer, asyncCall, getTime, 'SourceSansA', '', userAgent.getBrowserInfo().hasWebKitFallbackBug()),
290
+ domHelper, fontSizer, asyncCall, getTime, 'SourceSansA', '',
291
+ userAgent.getBrowserInfo(), 500),
264
292
  ruler = new FontRuler(domHelper, fontSizer, 'abcdef'),
265
293
  activeSize = null,
266
294
  originalSize = null,
@@ -300,7 +328,8 @@ describe('FontWatchRunner', function () {
300
328
 
301
329
  it('should attempt to load a non-existing font', function () {
302
330
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
303
- domHelper, fontSizer, asyncCall, getTime, 'Elena', '', userAgent.getBrowserInfo().hasWebKitFallbackBug());
331
+ domHelper, fontSizer, asyncCall, getTime, 'Elena', '',
332
+ userAgent.getBrowserInfo(), 500);
304
333
 
305
334
  runs(function () {
306
335
  fontWatchRunner.start();
@@ -317,7 +346,8 @@ describe('FontWatchRunner', function () {
317
346
 
318
347
  it('should load even if @font-face is inserted after watching has started', function () {
319
348
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
320
- domHelper, fontSizer, asyncCall, getTime, 'SourceSansB', '', userAgent.getBrowserInfo().hasWebKitFallbackBug()),
349
+ domHelper, fontSizer, asyncCall, getTime, 'SourceSansB', '',
350
+ userAgent.getBrowserInfo(), 500),
321
351
  ruler = new FontRuler(domHelper, fontSizer, 'abcdef'),
322
352
  activeSize = null,
323
353
  originalSize = null,
@@ -375,7 +405,7 @@ describe('FontWatchRunner', function () {
375
405
  ];
376
406
 
377
407
  fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
378
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, false);
408
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
379
409
 
380
410
  fontWatchRunner.start();
381
411
 
@@ -388,7 +418,8 @@ describe('FontWatchRunner', function () {
388
418
  ];
389
419
 
390
420
  fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
391
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, false, {}, 'TestString');
421
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily,
422
+ fontDescription, browserInfo, 0, {}, 'TestString');
392
423
 
393
424
  fontWatchRunner.start();
394
425
 
@@ -58,6 +58,11 @@ describe('UserAgentParser', function () {
58
58
  return false;
59
59
  }
60
60
 
61
+ if (actual.getBrowserInfo().hasWebKitMetricsBug() !== expected.browserInfo.hasWebKitMetricsBug) {
62
+ this.message = msg('web kit metrics bug', actual.getBrowserInfo().hasWebKitMetricsBug(), expected.browserInfo.hasWebKitFallbackBug);
63
+ return false;
64
+ }
65
+
61
66
  return true;
62
67
  }
63
68
  });
@@ -81,7 +86,8 @@ describe('UserAgentParser', function () {
81
86
  documentMode: undefined,
82
87
  browserInfo: {
83
88
  hasWebFontSupport: true,
84
- hasWebKitFallbackBug: true
89
+ hasWebKitFallbackBug: true,
90
+ hasWebKitMetricsBug: true
85
91
  }
86
92
  });
87
93
  });
@@ -98,7 +104,8 @@ describe('UserAgentParser', function () {
98
104
  documentMode: undefined,
99
105
  browserInfo: {
100
106
  hasWebFontSupport: false,
101
- hasWebKitFallbackBug: true
107
+ hasWebKitFallbackBug: true,
108
+ hasWebKitMetricsBug: true
102
109
  }
103
110
  });
104
111
  });
@@ -117,7 +124,8 @@ describe('UserAgentParser', function () {
117
124
  documentMode: undefined,
118
125
  browserInfo: {
119
126
  hasWebFontSupport: true,
120
- hasWebKitFallbackBug: false
127
+ hasWebKitFallbackBug: false,
128
+ hasWebKitMetricsBug: false
121
129
  }
122
130
  });
123
131
 
@@ -132,7 +140,8 @@ describe('UserAgentParser', function () {
132
140
  documentMode: undefined,
133
141
  browserInfo: {
134
142
  hasWebFontSupport: true,
135
- hasWebKitFallbackBug: false
143
+ hasWebKitFallbackBug: false,
144
+ hasWebKitMetricsBug: false
136
145
  }
137
146
  });
138
147
  });
@@ -149,7 +158,8 @@ describe('UserAgentParser', function () {
149
158
  documentMode: undefined,
150
159
  browserInfo: {
151
160
  hasWebFontSupport: true,
152
- hasWebKitFallbackBug: false
161
+ hasWebKitFallbackBug: false,
162
+ hasWebKitMetricsBug: false
153
163
  }
154
164
  });
155
165
  });
@@ -168,7 +178,8 @@ describe('UserAgentParser', function () {
168
178
  documentMode: undefined,
169
179
  browserInfo: {
170
180
  hasWebFontSupport: true,
171
- hasWebKitFallbackBug: false
181
+ hasWebKitFallbackBug: false,
182
+ hasWebKitMetricsBug: false
172
183
  }
173
184
  });
174
185
  });
@@ -185,7 +196,8 @@ describe('UserAgentParser', function () {
185
196
  documentMode: undefined,
186
197
  browserInfo: {
187
198
  hasWebFontSupport: false,
188
- hasWebKitFallbackBug: false
199
+ hasWebKitFallbackBug: false,
200
+ hasWebKitMetricsBug: false
189
201
  }
190
202
  });
191
203
  });
@@ -204,7 +216,8 @@ describe('UserAgentParser', function () {
204
216
  documentMode: undefined,
205
217
  browserInfo: {
206
218
  hasWebFontSupport: true,
207
- hasWebKitFallbackBug: true
219
+ hasWebKitFallbackBug: true,
220
+ hasWebKitMetricsBug: true
208
221
  }
209
222
  });
210
223
  });
@@ -221,7 +234,8 @@ describe('UserAgentParser', function () {
221
234
  documentMode: undefined,
222
235
  browserInfo: {
223
236
  hasWebFontSupport: true,
224
- hasWebKitFallbackBug: true
237
+ hasWebKitFallbackBug: true,
238
+ hasWebKitMetricsBug: false
225
239
  }
226
240
  });
227
241
  });
@@ -238,7 +252,8 @@ describe('UserAgentParser', function () {
238
252
  documentMode: undefined,
239
253
  browserInfo: {
240
254
  hasWebFontSupport: true,
241
- hasWebKitFallbackBug: true
255
+ hasWebKitFallbackBug: true,
256
+ hasWebKitMetricsBug: false
242
257
  }
243
258
  });
244
259
  });
@@ -255,7 +270,8 @@ describe('UserAgentParser', function () {
255
270
  documentMode: undefined,
256
271
  browserInfo: {
257
272
  hasWebFontSupport: true,
258
- hasWebKitFallbackBug: true
273
+ hasWebKitFallbackBug: true,
274
+ hasWebKitMetricsBug: true
259
275
  }
260
276
  });
261
277
  });
@@ -272,7 +288,8 @@ describe('UserAgentParser', function () {
272
288
  documentMode: undefined,
273
289
  browserInfo: {
274
290
  hasWebFontSupport: true,
275
- hasWebKitFallbackBug: true
291
+ hasWebKitFallbackBug: true,
292
+ hasWebKitMetricsBug: true
276
293
  }
277
294
  });
278
295
  });
@@ -291,7 +308,8 @@ describe('UserAgentParser', function () {
291
308
  documentMode: undefined,
292
309
  browserInfo: {
293
310
  hasWebFontSupport: true,
294
- hasWebKitFallbackBug: true
311
+ hasWebKitFallbackBug: true,
312
+ hasWebKitMetricsBug: true
295
313
  }
296
314
  });
297
315
 
@@ -306,7 +324,8 @@ describe('UserAgentParser', function () {
306
324
  documentMode: undefined,
307
325
  browserInfo: {
308
326
  hasWebFontSupport: true,
309
- hasWebKitFallbackBug: true
327
+ hasWebKitFallbackBug: true,
328
+ hasWebKitMetricsBug: true
310
329
  }
311
330
  });
312
331
  });
@@ -323,7 +342,8 @@ describe('UserAgentParser', function () {
323
342
  documentMode: undefined,
324
343
  browserInfo: {
325
344
  hasWebFontSupport: true,
326
- hasWebKitFallbackBug: true
345
+ hasWebKitFallbackBug: true,
346
+ hasWebKitMetricsBug: true
327
347
  }
328
348
  });
329
349
  });
@@ -340,7 +360,8 @@ describe('UserAgentParser', function () {
340
360
  documentMode: undefined,
341
361
  browserInfo: {
342
362
  hasWebFontSupport: true,
343
- hasWebKitFallbackBug: true
363
+ hasWebKitFallbackBug: true,
364
+ hasWebKitMetricsBug: true
344
365
  }
345
366
  });
346
367
 
@@ -355,7 +376,8 @@ describe('UserAgentParser', function () {
355
376
  documentMode: undefined,
356
377
  browserInfo: {
357
378
  hasWebFontSupport: true,
358
- hasWebKitFallbackBug: true
379
+ hasWebKitFallbackBug: true,
380
+ hasWebKitMetricsBug: true
359
381
  }
360
382
  });
361
383
 
@@ -370,7 +392,8 @@ describe('UserAgentParser', function () {
370
392
  documentMode: undefined,
371
393
  browserInfo: {
372
394
  hasWebFontSupport: true,
373
- hasWebKitFallbackBug: true
395
+ hasWebKitFallbackBug: true,
396
+ hasWebKitMetricsBug: true
374
397
  }
375
398
  });
376
399
  });
@@ -387,7 +410,8 @@ describe('UserAgentParser', function () {
387
410
  documentMode: undefined,
388
411
  browserInfo: {
389
412
  hasWebFontSupport: true,
390
- hasWebKitFallbackBug: true
413
+ hasWebKitFallbackBug: true,
414
+ hasWebKitMetricsBug: true
391
415
  }
392
416
  });
393
417
 
@@ -402,7 +426,8 @@ describe('UserAgentParser', function () {
402
426
  documentMode: undefined,
403
427
  browserInfo: {
404
428
  hasWebFontSupport: true,
405
- hasWebKitFallbackBug: true
429
+ hasWebKitFallbackBug: true,
430
+ hasWebKitMetricsBug: true
406
431
  }
407
432
  });
408
433
  });
@@ -421,7 +446,8 @@ describe('UserAgentParser', function () {
421
446
  documentMode: undefined,
422
447
  browserInfo: {
423
448
  hasWebFontSupport: true,
424
- hasWebKitFallbackBug: false
449
+ hasWebKitFallbackBug: false,
450
+ hasWebKitMetricsBug: false
425
451
  }
426
452
  });
427
453
 
@@ -436,7 +462,8 @@ describe('UserAgentParser', function () {
436
462
  documentMode: undefined,
437
463
  browserInfo: {
438
464
  hasWebFontSupport: true,
439
- hasWebKitFallbackBug: false
465
+ hasWebKitFallbackBug: false,
466
+ hasWebKitMetricsBug: false
440
467
  }
441
468
  });
442
469
  });
@@ -453,7 +480,8 @@ describe('UserAgentParser', function () {
453
480
  documentMode: undefined,
454
481
  browserInfo: {
455
482
  hasWebFontSupport: true,
456
- hasWebKitFallbackBug: false
483
+ hasWebKitFallbackBug: false,
484
+ hasWebKitMetricsBug: false
457
485
  }
458
486
  });
459
487
  });
@@ -470,7 +498,8 @@ describe('UserAgentParser', function () {
470
498
  documentMode: undefined,
471
499
  browserInfo: {
472
500
  hasWebFontSupport: true,
473
- hasWebKitFallbackBug: false
501
+ hasWebKitFallbackBug: false,
502
+ hasWebKitMetricsBug: false
474
503
  }
475
504
  });
476
505
  });
@@ -487,7 +516,8 @@ describe('UserAgentParser', function () {
487
516
  documentMode: undefined,
488
517
  browserInfo: {
489
518
  hasWebFontSupport: false,
490
- hasWebKitFallbackBug: false
519
+ hasWebKitFallbackBug: false,
520
+ hasWebKitMetricsBug: false
491
521
  }
492
522
  });
493
523
  });
@@ -504,7 +534,8 @@ describe('UserAgentParser', function () {
504
534
  documentMode: undefined,
505
535
  browserInfo: {
506
536
  hasWebFontSupport: false,
507
- hasWebKitFallbackBug: false
537
+ hasWebKitFallbackBug: false,
538
+ hasWebKitMetricsBug: false
508
539
  }
509
540
  });
510
541
  });
@@ -521,7 +552,8 @@ describe('UserAgentParser', function () {
521
552
  documentMode: 8,
522
553
  browserInfo: {
523
554
  hasWebFontSupport: true,
524
- hasWebKitFallbackBug: false
555
+ hasWebKitFallbackBug: false,
556
+ hasWebKitMetricsBug: false
525
557
  }
526
558
  });
527
559
  });
@@ -540,7 +572,8 @@ describe('UserAgentParser', function () {
540
572
  documentMode: undefined,
541
573
  browserInfo: {
542
574
  hasWebFontSupport: true,
543
- hasWebKitFallbackBug: true
575
+ hasWebKitFallbackBug: true,
576
+ hasWebKitMetricsBug: false
544
577
  }
545
578
  });
546
579
  });
@@ -557,7 +590,8 @@ describe('UserAgentParser', function () {
557
590
  documentMode: undefined,
558
591
  browserInfo: {
559
592
  hasWebFontSupport: false,
560
- hasWebKitFallbackBug: true
593
+ hasWebKitFallbackBug: true,
594
+ hasWebKitMetricsBug: false
561
595
  }
562
596
  });
563
597
  });
@@ -574,7 +608,8 @@ describe('UserAgentParser', function () {
574
608
  documentMode: undefined,
575
609
  browserInfo: {
576
610
  hasWebFontSupport: true,
577
- hasWebKitFallbackBug: true
611
+ hasWebKitFallbackBug: true,
612
+ hasWebKitMetricsBug: false
578
613
  }
579
614
  });
580
615
  });
@@ -591,7 +626,8 @@ describe('UserAgentParser', function () {
591
626
  documentMode: undefined,
592
627
  browserInfo: {
593
628
  hasWebFontSupport: true,
594
- hasWebKitFallbackBug: true
629
+ hasWebKitFallbackBug: true,
630
+ hasWebKitMetricsBug: false
595
631
  }
596
632
  });
597
633
  });
@@ -608,7 +644,8 @@ describe('UserAgentParser', function () {
608
644
  documentMode: undefined,
609
645
  browserInfo: {
610
646
  hasWebFontSupport: true,
611
- hasWebKitFallbackBug: true
647
+ hasWebKitFallbackBug: true,
648
+ hasWebKitMetricsBug: false
612
649
  }
613
650
  });
614
651
  });
@@ -625,7 +662,8 @@ describe('UserAgentParser', function () {
625
662
  documentMode: undefined,
626
663
  browserInfo: {
627
664
  hasWebFontSupport: true,
628
- hasWebKitFallbackBug: true
665
+ hasWebKitFallbackBug: true,
666
+ hasWebKitMetricsBug: false
629
667
  }
630
668
  });
631
669
  });
@@ -642,7 +680,8 @@ describe('UserAgentParser', function () {
642
680
  documentMode: undefined,
643
681
  browserInfo: {
644
682
  hasWebFontSupport: true,
645
- hasWebKitFallbackBug: false
683
+ hasWebKitFallbackBug: false,
684
+ hasWebKitMetricsBug: false
646
685
  }
647
686
  });
648
687
  });
@@ -659,7 +698,8 @@ describe('UserAgentParser', function () {
659
698
  documentMode: undefined,
660
699
  browserInfo: {
661
700
  hasWebFontSupport: false,
662
- hasWebKitFallbackBug: true
701
+ hasWebKitFallbackBug: true,
702
+ hasWebKitMetricsBug: false
663
703
  }
664
704
  });
665
705
  });
@@ -678,7 +718,8 @@ describe('UserAgentParser', function () {
678
718
  documentMode: undefined,
679
719
  browserInfo: {
680
720
  hasWebFontSupport: true,
681
- hasWebKitFallbackBug: false
721
+ hasWebKitFallbackBug: false,
722
+ hasWebKitMetricsBug: false
682
723
  }
683
724
  });
684
725
  });
@@ -695,7 +736,8 @@ describe('UserAgentParser', function () {
695
736
  documentMode: undefined,
696
737
  browserInfo: {
697
738
  hasWebFontSupport: false,
698
- hasWebKitFallbackBug: false
739
+ hasWebKitFallbackBug: false,
740
+ hasWebKitMetricsBug: false
699
741
  }
700
742
  });
701
743
  });
@@ -712,7 +754,8 @@ describe('UserAgentParser', function () {
712
754
  documentMode: undefined,
713
755
  browserInfo: {
714
756
  hasWebFontSupport: false,
715
- hasWebKitFallbackBug: false
757
+ hasWebKitFallbackBug: false,
758
+ hasWebKitMetricsBug: false
716
759
  }
717
760
  });
718
761
  });
@@ -729,7 +772,8 @@ describe('UserAgentParser', function () {
729
772
  documentMode: undefined,
730
773
  browserInfo: {
731
774
  hasWebFontSupport: true,
732
- hasWebKitFallbackBug: false
775
+ hasWebKitFallbackBug: false,
776
+ hasWebKitMetricsBug: false
733
777
  }
734
778
  });
735
779
  });
@@ -746,7 +790,8 @@ describe('UserAgentParser', function () {
746
790
  documentMode: undefined,
747
791
  browserInfo: {
748
792
  hasWebFontSupport: false,
749
- hasWebKitFallbackBug: false
793
+ hasWebKitFallbackBug: false,
794
+ hasWebKitMetricsBug: false
750
795
  }
751
796
  });
752
797
  });
@@ -765,7 +810,8 @@ describe('UserAgentParser', function () {
765
810
  documentMode: undefined,
766
811
  browserInfo: {
767
812
  hasWebFontSupport: true,
768
- hasWebKitFallbackBug: true
813
+ hasWebKitFallbackBug: true,
814
+ hasWebKitMetricsBug: false
769
815
  }
770
816
  });
771
817
  });
@@ -782,7 +828,8 @@ describe('UserAgentParser', function () {
782
828
  documentMode: undefined,
783
829
  browserInfo: {
784
830
  hasWebFontSupport: true,
785
- hasWebKitFallbackBug: false
831
+ hasWebKitFallbackBug: false,
832
+ hasWebKitMetricsBug: false
786
833
  }
787
834
  });
788
835
  });
@@ -801,7 +848,8 @@ describe('UserAgentParser', function () {
801
848
  documentMode: undefined,
802
849
  browserInfo: {
803
850
  hasWebFontSupport: true,
804
- hasWebKitFallbackBug: false
851
+ hasWebKitFallbackBug: false,
852
+ hasWebKitMetricsBug: false
805
853
  }
806
854
  });
807
855
  });
@@ -818,7 +866,8 @@ describe('UserAgentParser', function () {
818
866
  documentMode: undefined,
819
867
  browserInfo: {
820
868
  hasWebFontSupport: true,
821
- hasWebKitFallbackBug: false
869
+ hasWebKitFallbackBug: false,
870
+ hasWebKitMetricsBug: false
822
871
  }
823
872
  });
824
873
  });
@@ -835,7 +884,8 @@ describe('UserAgentParser', function () {
835
884
  documentMode: undefined,
836
885
  browserInfo: {
837
886
  hasWebFontSupport: true,
838
- hasWebKitFallbackBug: false
887
+ hasWebKitFallbackBug: false,
888
+ hasWebKitMetricsBug: false
839
889
  }
840
890
  });
841
891
  });
@@ -852,7 +902,8 @@ describe('UserAgentParser', function () {
852
902
  documentMode: undefined,
853
903
  browserInfo: {
854
904
  hasWebFontSupport: false,
855
- hasWebKitFallbackBug: false
905
+ hasWebKitFallbackBug: false,
906
+ hasWebKitMetricsBug: false
856
907
  }
857
908
  });
858
909
 
@@ -867,7 +918,8 @@ describe('UserAgentParser', function () {
867
918
  documentMode: undefined,
868
919
  browserInfo: {
869
920
  hasWebFontSupport: false,
870
- hasWebKitFallbackBug: false
921
+ hasWebKitFallbackBug: false,
922
+ hasWebKitMetricsBug: false
871
923
  }
872
924
  });
873
925
 
@@ -882,7 +934,8 @@ describe('UserAgentParser', function () {
882
934
  documentMode: undefined,
883
935
  browserInfo: {
884
936
  hasWebFontSupport: false,
885
- hasWebKitFallbackBug: false
937
+ hasWebKitFallbackBug: false,
938
+ hasWebKitMetricsBug: false
886
939
  }
887
940
  });
888
941
 
@@ -897,7 +950,8 @@ describe('UserAgentParser', function () {
897
950
  documentMode: undefined,
898
951
  browserInfo: {
899
952
  hasWebFontSupport: false,
900
- hasWebKitFallbackBug: false
953
+ hasWebKitFallbackBug: false,
954
+ hasWebKitMetricsBug: false
901
955
  }
902
956
  });
903
957
 
@@ -912,7 +966,8 @@ describe('UserAgentParser', function () {
912
966
  documentMode: undefined,
913
967
  browserInfo: {
914
968
  hasWebFontSupport: false,
915
- hasWebKitFallbackBug: false
969
+ hasWebKitFallbackBug: false,
970
+ hasWebKitMetricsBug: false
916
971
  }
917
972
  });
918
973
  });
@@ -1,5 +1,6 @@
1
1
  describe('LastResortWebKitFontWatchRunner', function () {
2
2
  var LastResortWebKitFontWatchRunner = webfont.LastResortWebKitFontWatchRunner,
3
+ BrowserInfo = webfont.BrowserInfo,
3
4
  Size = webfont.Size,
4
5
  DomHelper = webfont.DomHelper,
5
6
  domHelper = new DomHelper(window),
@@ -12,6 +13,7 @@ describe('LastResortWebKitFontWatchRunner', function () {
12
13
  FALLBACK_SIZE_B = new Size(2, 2),
13
14
  LAST_RESORT_SIZE = new Size(4, 4),
14
15
 
16
+ browserInfo = new BrowserInfo(true, true, false),
15
17
  setupSizes = [FALLBACK_SIZE_A, FALLBACK_SIZE_B, LAST_RESORT_SIZE],
16
18
  actualSizes = [],
17
19
  fakeGetSizeCount = 0,
@@ -84,7 +86,7 @@ describe('LastResortWebKitFontWatchRunner', function () {
84
86
  ];
85
87
 
86
88
  var fontWatchRunner = new LastResortWebKitFontWatchRunner(activeCallback, inactiveCallback,
87
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
89
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
88
90
 
89
91
  fontWatchRunner.start();
90
92
 
@@ -101,7 +103,7 @@ describe('LastResortWebKitFontWatchRunner', function () {
101
103
  timesToGetTimeBeforeTimeout = 2;
102
104
 
103
105
  var fontWatchRunner = new LastResortWebKitFontWatchRunner(activeCallback, inactiveCallback,
104
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, 'Arimo', fontDescription, true);
106
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, 'Arimo', fontDescription, browserInfo);
105
107
 
106
108
  fontWatchRunner.start();
107
109
 
@@ -119,7 +121,7 @@ describe('LastResortWebKitFontWatchRunner', function () {
119
121
  timesToGetTimeBeforeTimeout = 3;
120
122
 
121
123
  var fontWatchRunner = new LastResortWebKitFontWatchRunner(activeCallback, inactiveCallback,
122
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
124
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
123
125
 
124
126
  fontWatchRunner.start();
125
127
 
@@ -136,7 +138,7 @@ describe('LastResortWebKitFontWatchRunner', function () {
136
138
  timesToGetTimeBeforeTimeout = 2;
137
139
 
138
140
  var fontWatchRunner = new LastResortWebKitFontWatchRunner(activeCallback, inactiveCallback,
139
- domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, true);
141
+ domHelper, fakeFontSizer, fakeAsyncCall, fakeGetTime, fontFamily, fontDescription, browserInfo);
140
142
 
141
143
  fontWatchRunner.start();
142
144
  expect(asyncCount).toEqual(1);
@@ -27,7 +27,7 @@ describe('MonotypeScript', function () {
27
27
  };
28
28
  support = jasmine.createSpy('support');
29
29
  load = jasmine.createSpy('load');
30
- useragent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.3', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false));
30
+ useragent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.3', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false));
31
31
 
32
32
  monotype = new MonotypeScript(useragent, fakeDomHelper, configuration);
33
33
  monotype.supportUserAgent(useragent, support);
@@ -31,7 +31,7 @@ describe('TypekitScript', function () {
31
31
  typekit.supportUserAgent('useragent', support);
32
32
 
33
33
  expect(fakeDomHelper.insertInto.calls[0].args[0]).toEqual('head');
34
- expect(fakeDomHelper.createScriptSrc).toHaveBeenCalledWith('http://use.typekit.com/abc.js');
34
+ expect(fakeDomHelper.createScriptSrc).toHaveBeenCalledWith('http://use.typekit.net/abc.js');
35
35
  expect(support).not.toHaveBeenCalled();
36
36
 
37
37
  expect(global.__webfonttypekitmodule__).not.toBeNull();
@@ -2,13 +2,17 @@
2
2
  * @constructor
3
3
  * @param {boolean} webfontSupport
4
4
  * @param {boolean} webKitFallbackBug
5
+ * @param {boolean} webKitMetricsBug
5
6
  */
6
- webfont.BrowserInfo = function (webfontSupport, webKitFallbackBug) {
7
+ webfont.BrowserInfo = function (webfontSupport, webKitFallbackBug, webKitMetricsBug) {
7
8
  this.webfontSupport_ = webfontSupport;
8
9
  this.webKitFallbackBug_ = webKitFallbackBug;
10
+ this.webKitMetricsBug_ = webKitMetricsBug;
9
11
  };
10
12
 
11
13
  /**
14
+ * Returns true if the browser supports web fonts.
15
+ *
12
16
  * @return {boolean}
13
17
  */
14
18
  webfont.BrowserInfo.prototype.hasWebFontSupport = function () {
@@ -16,8 +20,42 @@ webfont.BrowserInfo.prototype.hasWebFontSupport = function () {
16
20
  };
17
21
 
18
22
  /**
23
+ * Returns true if the browser has the WebKit fallback bug.
24
+ *
25
+ * The bug causes the normal CSS font stack to be ignored while
26
+ * loading web fonts. Instead it picks the generic font family
27
+ * (or the default generic font family) of the first instance
28
+ * the web font is mentioned in CSS. It switches to this font
29
+ * immediately while loading web font, causing two changes in
30
+ * font to occur (compared to other browsers which only change
31
+ * font once the web font has loaded.)
32
+ *
33
+ * The bug has been fixed and is only happens in WebKit versions
34
+ * below 536.11. Even though it is fixed we still have a large
35
+ * percentage of users on older WebKit versions, mostly on mobile
36
+ * platforms.
37
+ *
38
+ * Also see: https://bugs.webkit.org/show_bug.cgi?id=76684
39
+ *
19
40
  * @return {boolean}
20
41
  */
21
42
  webfont.BrowserInfo.prototype.hasWebKitFallbackBug = function () {
22
43
  return this.webKitFallbackBug_;
23
44
  };
45
+
46
+ /**
47
+ * Returns true if the browser has the WebKit metrics bug
48
+ *
49
+ * The metrics bug causes WebKit to change the height of a font
50
+ * while loading a web font. Other browsers do not modify
51
+ * the width or height of the fallback font while a web font is
52
+ * loading. This caused our width and height check to be incorrect,
53
+ * triggering a false positive.
54
+ *
55
+ * Also see: https://bugs.webkit.org/show_bug.cgi?id=110977
56
+ *
57
+ * @return {boolean}
58
+ */
59
+ webfont.BrowserInfo.prototype.hasWebKitMetricsBug = function () {
60
+ return this.webKitMetricsBug_;
61
+ };
data/src/core/font.js CHANGED
@@ -73,6 +73,7 @@ webfont.WebFont.prototype.onModuleReady_ = function(eventDispatcher, fontWatcher
73
73
 
74
74
  webfont.WebFont.prototype.load_ = function(eventDispatcher, configuration) {
75
75
  var modules = this.fontModuleLoader_.getModules(configuration, this.domHelper_),
76
+ timeout = configuration['timeout'],
76
77
  self = this;
77
78
 
78
79
  this.moduleFailedLoading_ = this.moduleLoading_ = modules.length;
@@ -83,7 +84,7 @@ webfont.WebFont.prototype.load_ = function(eventDispatcher, configuration) {
83
84
  return new webfont.Size(elem.offsetWidth, elem.offsetHeight);
84
85
  }}, self.asyncCall_, function() {
85
86
  return new Date().getTime();
86
- });
87
+ }, timeout);
87
88
 
88
89
  for (var i = 0, len = modules.length; i < len; i++) {
89
90
  var module = modules[i];
@@ -6,9 +6,10 @@
6
6
  * @param {Object.<string, function(Object): webfont.Size>} fontSizer
7
7
  * @param {function(function(), number=)} asyncCall
8
8
  * @param {function(): number} getTime
9
+ * @param {number=} opt_timeout
9
10
  */
10
11
  webfont.FontWatcher = function(userAgent, domHelper, eventDispatcher, fontSizer,
11
- asyncCall, getTime) {
12
+ asyncCall, getTime, opt_timeout) {
12
13
  this.domHelper_ = domHelper;
13
14
  this.eventDispatcher_ = eventDispatcher;
14
15
  this.fontSizer_ = fontSizer;
@@ -17,8 +18,9 @@ webfont.FontWatcher = function(userAgent, domHelper, eventDispatcher, fontSizer,
17
18
  this.currentlyWatched_ = 0;
18
19
  this.last_ = false;
19
20
  this.success_ = false;
21
+ this.timeout_ = opt_timeout;
20
22
 
21
- this.hasWebKitFallbackBug_ = userAgent.getBrowserInfo().hasWebKitFallbackBug();
23
+ this.browserInfo_ = userAgent.getBrowserInfo();
22
24
  };
23
25
 
24
26
  /**
@@ -38,7 +40,7 @@ webfont.FontWatcher.DEFAULT_VARIATION = 'n4';
38
40
  * function(string, string), webfont.DomHelper,
39
41
  * Object.<string, function(Object): number>,
40
42
  * function(function(), number=), function(): number, string, string,
41
- * boolean, Object.<string,boolean>=, string=)} fontWatchRunnerCtor The font watch runner constructor.
43
+ * webfont.BrowserInfo, number=, Object.<string,boolean>=, string=)} fontWatchRunnerCtor The font watch runner constructor.
42
44
  * @param {boolean} last True if this is the last set of families to watch.
43
45
  */
44
46
  webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
@@ -76,7 +78,8 @@ webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
76
78
  var inactiveCallback = webfont.bind(this, this.fontInactive_)
77
79
  var fontWatchRunner = new fontWatchRunnerCtor(activeCallback,
78
80
  inactiveCallback, this.domHelper_, this.fontSizer_, this.asyncCall_,
79
- this.getTime_, fontFamily, fontDescription, this.hasWebKitFallbackBug_, null, fontTestString);
81
+ this.getTime_, fontFamily, fontDescription,
82
+ this.browserInfo_, this.timeout_, null, fontTestString);
80
83
 
81
84
  fontWatchRunner.start();
82
85
  }
@@ -8,12 +8,14 @@
8
8
  * @param {function(): number} getTime
9
9
  * @param {string} fontFamily
10
10
  * @param {string} fontDescription
11
- * @param {boolean} hasWebKitFallbackBug
11
+ * @param {webfont.BrowserInfo} browserInfo
12
+ * @param {number=} opt_timeout
12
13
  * @param {Object.<string, boolean>=} opt_metricCompatibleFonts
13
14
  * @param {string=} opt_fontTestString
14
15
  */
15
16
  webfont.FontWatchRunner = function(activeCallback, inactiveCallback, domHelper,
16
- fontSizer, asyncCall, getTime, fontFamily, fontDescription, hasWebKitFallbackBug, opt_metricCompatibleFonts, opt_fontTestString) {
17
+ fontSizer, asyncCall, getTime, fontFamily, fontDescription, browserInfo,
18
+ opt_timeout, opt_metricCompatibleFonts, opt_fontTestString) {
17
19
  this.activeCallback_ = activeCallback;
18
20
  this.inactiveCallback_ = inactiveCallback;
19
21
  this.domHelper_ = domHelper;
@@ -23,8 +25,9 @@ webfont.FontWatchRunner = function(activeCallback, inactiveCallback, domHelper,
23
25
  this.fontFamily_ = fontFamily;
24
26
  this.fontDescription_ = fontDescription;
25
27
  this.fontTestString_ = opt_fontTestString || webfont.FontWatchRunner.DEFAULT_TEST_STRING;
26
- this.hasWebKitFallbackBug_ = hasWebKitFallbackBug;
28
+ this.browserInfo_ = browserInfo;
27
29
  this.lastResortSizes_ = {};
30
+ this.timeout_ = opt_timeout || 5000;
28
31
 
29
32
  this.metricCompatibleFonts_ = opt_metricCompatibleFonts || null;
30
33
 
@@ -102,7 +105,11 @@ webfont.FontWatchRunner.prototype.start = function() {
102
105
  * @return {boolean}
103
106
  */
104
107
  webfont.FontWatchRunner.prototype.sizeMatches_ = function(size, lastResortFont) {
105
- return size.equals(this.lastResortSizes_[lastResortFont]);
108
+ if (this.browserInfo_.hasWebKitMetricsBug()) {
109
+ return size.equalsWidth(this.lastResortSizes_[lastResortFont]);
110
+ } else {
111
+ return size.equals(this.lastResortSizes_[lastResortFont]);
112
+ }
106
113
  };
107
114
 
108
115
  /**
@@ -132,7 +139,7 @@ webfont.FontWatchRunner.prototype.sizesMatchLastResortSizes_ = function(a, b) {
132
139
  * @return {boolean}
133
140
  */
134
141
  webfont.FontWatchRunner.prototype.hasTimedOut_ = function() {
135
- return this.getTime_() - this.started_ >= 5000;
142
+ return this.getTime_() - this.started_ >= this.timeout_;
136
143
  };
137
144
 
138
145
  /**
@@ -157,7 +164,7 @@ webfont.FontWatchRunner.prototype.isFallbackFont_ = function (sizeA, sizeB) {
157
164
  * @return {boolean}
158
165
  */
159
166
  webfont.FontWatchRunner.prototype.isLastResortFont_ = function (sizeA, sizeB) {
160
- return this.hasWebKitFallbackBug_ && this.sizesMatchLastResortSizes_(sizeA, sizeB);
167
+ return this.browserInfo_.hasWebKitFallbackBug() && this.sizesMatchLastResortSizes_(sizeA, sizeB);
161
168
  };
162
169
 
163
170
  /**
data/src/core/size.js CHANGED
@@ -15,5 +15,23 @@ webfont.Size = function (width, height) {
15
15
  * @return {boolean}
16
16
  */
17
17
  webfont.Size.prototype.equals = function (other) {
18
- return !!other && this.width == other.width && this.height == other.height;
18
+ return this.equalsWidth(other) && this.equalsHeight(other);
19
+ };
20
+
21
+ /**
22
+ * Returns true if this.width equals other.width
23
+ * @param {webfont.Size} other
24
+ * @return {boolean}
25
+ */
26
+ webfont.Size.prototype.equalsWidth = function (other) {
27
+ return !!other && this.width == other.width;
28
+ };
29
+
30
+ /**
31
+ * Returns true if this.height equals other.height
32
+ * @param {webfont.Size} other
33
+ * @return {boolean}
34
+ */
35
+ webfont.Size.prototype.equalsHeight = function (other) {
36
+ return !!other && this.height == other.height;
19
37
  };
@@ -35,7 +35,7 @@ webfont.UserAgentParser.UNKNOWN_USER_AGENT = new webfont.UserAgent(
35
35
  webfont.UserAgentParser.UNKNOWN,
36
36
  webfont.UserAgentParser.UNKNOWN,
37
37
  undefined,
38
- new webfont.BrowserInfo(false, false));
38
+ new webfont.BrowserInfo(false, false, false));
39
39
 
40
40
  /**
41
41
  * Parses the user agent string and returns an object.
@@ -142,12 +142,12 @@ webfont.UserAgentParser.prototype.parseIeUserAgentString_ = function() {
142
142
  (platform == "Windows Phone" && platformVersion.major >= 8);
143
143
 
144
144
  return new webfont.UserAgent(name, version, name, version,
145
- platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, false));
145
+ platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, false, false));
146
146
  }
147
147
 
148
148
  return new webfont.UserAgent("MSIE", webfont.UserAgentParser.UNKNOWN,
149
149
  "MSIE", webfont.UserAgentParser.UNKNOWN,
150
- platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false));
150
+ platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false, false));
151
151
  };
152
152
 
153
153
  /**
@@ -192,7 +192,7 @@ webfont.UserAgentParser.prototype.parseOperaUserAgentString_ = function() {
192
192
 
193
193
  return new webfont.UserAgent("OperaMini", version, engineName,
194
194
  engineVersion, this.getPlatform_(), this.getPlatformVersion_(),
195
- this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false));
195
+ this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false, false));
196
196
  }
197
197
 
198
198
  // Otherwise, find version information for normal Opera or Opera Mobile
@@ -203,7 +203,7 @@ webfont.UserAgentParser.prototype.parseOperaUserAgentString_ = function() {
203
203
  var version = this.parseVersion_(versionString);
204
204
  return new webfont.UserAgent("Opera", versionString, engineName, engineVersion,
205
205
  this.getPlatform_(), this.getPlatformVersion_(),
206
- this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(version.major >= 10, false));
206
+ this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(version.major >= 10, false, false));
207
207
  }
208
208
  }
209
209
  var versionString = this.getMatchingGroup_(this.userAgent_, /Opera[\/ ]([\d\.]+)/, 1);
@@ -212,11 +212,11 @@ webfont.UserAgentParser.prototype.parseOperaUserAgentString_ = function() {
212
212
  var version = this.parseVersion_(versionString);
213
213
  return new webfont.UserAgent("Opera", versionString, engineName, engineVersion,
214
214
  this.getPlatform_(), this.getPlatformVersion_(),
215
- this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(version.major >= 10, false));
215
+ this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(version.major >= 10, false, false));
216
216
  }
217
217
  return new webfont.UserAgent("Opera", webfont.UserAgentParser.UNKNOWN,
218
218
  engineName, engineVersion, this.getPlatform_(),
219
- this.getPlatformVersion_(), this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false));
219
+ this.getPlatformVersion_(), this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(false, false, false));
220
220
  };
221
221
 
222
222
  /**
@@ -279,10 +279,11 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
279
279
  supportWebFont = webKitVersion.major >= 526 || webKitVersion.major >= 525 && webKitVersion.minor >= 13;
280
280
  }
281
281
 
282
- var hasWebKitFallbackBug = webKitVersion.major < 536 || (webKitVersion.major == 536 && webKitVersion.minor < 11);
282
+ var hasWebKitFallbackBug = webKitVersion.major < 536 || (webKitVersion.major == 536 && webKitVersion.minor < 11),
283
+ hasWebKitMetricsBug = platform == 'iPhone' || platform == 'iPad' || platform == 'iPod' || platform == 'Macintosh';
283
284
 
284
285
  return new webfont.UserAgent(name, version, "AppleWebKit", webKitVersionString,
285
- platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, hasWebKitFallbackBug));
286
+ platform, platformVersionString, this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, hasWebKitFallbackBug, hasWebKitMetricsBug));
286
287
  };
287
288
 
288
289
  /**
@@ -331,7 +332,7 @@ webfont.UserAgentParser.prototype.parseGeckoUserAgentString_ = function() {
331
332
  }
332
333
  }
333
334
  return new webfont.UserAgent(name, version, "Gecko", geckoVersionString,
334
- this.getPlatform_(), this.getPlatformVersion_(), this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, false));
335
+ this.getPlatform_(), this.getPlatformVersion_(), this.getDocumentMode_(this.doc_), new webfont.BrowserInfo(supportWebFont, false, false));
335
336
  };
336
337
 
337
338
  /**
@@ -13,7 +13,7 @@ webfont.TypekitScript.HOOK = '__webfonttypekitmodule__';
13
13
 
14
14
  webfont.TypekitScript.prototype.getScriptSrc = function(kitId) {
15
15
  var protocol = this.domHelper_.getProtocol();
16
- var api = this.configuration_['api'] || protocol + '//use.typekit.com';
16
+ var api = this.configuration_['api'] || protocol + '//use.typekit.net';
17
17
  return api + '/' + kitId + '.js';
18
18
  };
19
19
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'webfontloader'
16
- s.version = '1.2.1'
17
- s.date = '2013-02-26'
16
+ s.version = '1.3.0'
17
+ s.date = '2013-02-28'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webfontloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Carver
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-02-26 00:00:00 Z
19
+ date: 2013-02-28 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false