webfontloader 1.4.1 → 1.4.2

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,9 @@
1
+ v1.4.2 (April 11, 2013)
2
+ * Namespace is now configurable at compile time
3
+ * BrowserInfo and UserAgent are exported so Typekit KitJS and the standalone webfontloader can share data
4
+ * Add "aria-hidden=true" to test spans so screen readers do not read test spans
5
+ * Fix passing the test strings from the modules to core.
6
+
1
7
  v1.4.1 (April 8, 2013)
2
8
  * Internal rewrite of font and variations
3
9
  * Fix for the configurable timeout on the Google module
data/README.md CHANGED
@@ -171,6 +171,6 @@ WebFont Loader is released under the [Apache 2.0][lic] license.
171
171
  [evt]: http://github.com/typekit/webfontloader/blob/master/docs/EVENTS.md
172
172
  [lic]: http://github.com/typekit/webfontloader/blob/master/LICENSE
173
173
  [demos]: http://github.com/typekit/webfontloader/blob/master/lib/webfontloader/demo/public
174
- [gfontapi]: https://code.google.com/apis/webfonts/
175
- [gajax]: http://code.google.com/apis/ajaxlibs/
174
+ [gfontapi]: https://developers.google.com/fonts/
175
+ [gajax]: https://developers.google.com/speed/libraries/
176
176
  [issues]: https://github.com/typekit/webfontloader/issues
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.4.1'
6
+ VERSION = '1.4.2'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
@@ -258,6 +258,8 @@ describe('FontWatchRunner', function () {
258
258
  nullFont = null,
259
259
  sourceSansA = null,
260
260
  sourceSansB = null,
261
+ sourceSansC = null,
262
+ sourceSansCBold = null,
261
263
  elena = null;
262
264
 
263
265
  beforeEach(function () {
@@ -266,6 +268,8 @@ describe('FontWatchRunner', function () {
266
268
  nullFont = new Font('__webfontloader_test__');
267
269
  sourceSansA = new Font('SourceSansA');
268
270
  sourceSansB = new Font('SourceSansB');
271
+ sourceSansC = new Font('SourceSansC');
272
+ sourceSansCBold = new Font('SourceSansC', 'n7');
269
273
  elena = new Font('Elena');
270
274
 
271
275
  userAgent = userAgentParser.parse();
@@ -397,15 +401,15 @@ describe('FontWatchRunner', function () {
397
401
 
398
402
  it('should load one weight after another', function () {
399
403
  var fontWatchRunnerRegular = new FontWatchRunner(activeCallback, inactiveCallback,
400
- domHelper, 'SourceSansC', 'n4', userAgent.getBrowserInfo(), 500),
404
+ domHelper, sourceSansC, userAgent.getBrowserInfo(), 500),
401
405
  fontWatchRunnerBold = new FontWatchRunner(activeCallback, inactiveCallback,
402
- domHelper, 'SourceSansC', 'n7', userAgent.getBrowserInfo(), 500),
406
+ domHelper, sourceSansCBold, userAgent.getBrowserInfo(), 500),
403
407
  fontRulerA = new FontRuler(domHelper, 'abcdef'),
404
408
  fontRulerB = new FontRuler(domHelper, 'abcdef');
405
409
 
406
410
  runs(function () {
407
411
  fontRulerA.insert();
408
- fontRulerA.setFont('SourceSansC', 'n4');
412
+ fontRulerA.setFont(sourceSansC);
409
413
  fontWatchRunnerRegular.start();
410
414
  });
411
415
 
@@ -414,13 +418,13 @@ describe('FontWatchRunner', function () {
414
418
  });
415
419
 
416
420
  runs(function () {
417
- expect(activeCallback).toHaveBeenCalledWith('SourceSansC', 'n4');
421
+ expect(activeCallback).toHaveBeenCalledWith(sourceSansC);
418
422
 
419
423
  activeCallback.reset();
420
424
  inactiveCallback.reset();
421
425
 
422
426
  fontRulerB.insert();
423
- fontRulerB.setFont('SourceSansC', 'n7');
427
+ fontRulerB.setFont(sourceSansCBold);
424
428
  fontWatchRunnerBold.start();
425
429
  });
426
430
 
@@ -429,8 +433,8 @@ describe('FontWatchRunner', function () {
429
433
  });
430
434
 
431
435
  runs(function () {
432
- expect(activeCallback).toHaveBeenCalledWith('SourceSansC', 'n7');
433
- expect(fontRulerA.getSize()).not.toEqual(fontRulerB.getSize());
436
+ expect(activeCallback).toHaveBeenCalledWith(sourceSansCBold);
437
+ expect(fontRulerA.getWidth()).not.toEqual(fontRulerB.getWidth());
434
438
  });
435
439
  });
436
440
  });
@@ -191,6 +191,38 @@ describe('WebFont', function () {
191
191
  });
192
192
  });
193
193
 
194
+ describe('should pass both fonts and test strings to onready', function () {
195
+ var font = null,
196
+ fontTestStrings = null,
197
+ testModule = null;
198
+
199
+ beforeEach(function () {
200
+ font = new WebFont(window, fontModuleLoader, new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false)));
201
+
202
+ font.addModule('test', function (conf, domHelper) {
203
+ testModule = new function () {};
204
+ testModule.supportUserAgent = function (ua, support) { support(true); };
205
+ testModule.load = function (onReady) {
206
+ onReady([new Font('Elena')], { 'Elena': '1234567' });
207
+ };
208
+
209
+ return testModule;
210
+ });
211
+
212
+ spyOn(font, 'onModuleReady_');
213
+ });
214
+
215
+ it('should have called onModuleReady with the correct font and test string', function () {
216
+ font.load({
217
+ 'test': {}
218
+ });
219
+
220
+ expect(font.onModuleReady_).toHaveBeenCalled();
221
+ expect(font.onModuleReady_.calls[0].args[3]).toEqual([new Font('Elena')]);
222
+ expect(font.onModuleReady_.calls[0].args[4]).toEqual({ 'Elena': '1234567' });
223
+ });
224
+ });
225
+
194
226
  describe('font inactive', function () {
195
227
  var font = null,
196
228
  testModule = null;
@@ -1,6 +1,7 @@
1
1
  goog.provide('webfont.BrowserInfo');
2
2
 
3
3
  /**
4
+ * @export
4
5
  * @constructor
5
6
  * @param {boolean} webfontSupport
6
7
  * @param {boolean} webKitFallbackBug
@@ -16,6 +17,7 @@ goog.scope(function () {
16
17
  var BrowserInfo = webfont.BrowserInfo;
17
18
 
18
19
  /**
20
+ * @export
19
21
  * Returns true if the browser supports web fonts.
20
22
  *
21
23
  * @return {boolean}
@@ -25,6 +27,8 @@ goog.scope(function () {
25
27
  };
26
28
 
27
29
  /**
30
+ * @export
31
+ *
28
32
  * Returns true if the browser has the WebKit fallback bug.
29
33
  *
30
34
  * The bug causes the normal CSS font stack to be ignored while
@@ -49,6 +53,8 @@ goog.scope(function () {
49
53
  };
50
54
 
51
55
  /**
56
+ * @export
57
+ *
52
58
  * Returns true if the browser has the WebKit metrics bug
53
59
  *
54
60
  * The metrics bug causes WebKit to change the height of a font
@@ -10,7 +10,9 @@ goog.provide('webfont.FontRuler');
10
10
  webfont.FontRuler = function (domHelper, fontTestString) {
11
11
  this.domHelper_ = domHelper;
12
12
  this.fontTestString_ = fontTestString;
13
- this.el_ = this.domHelper_.createElement('span', {}, this.fontTestString_);
13
+ this.el_ = this.domHelper_.createElement('span', {
14
+ "aria-hidden": "true"
15
+ }, this.fontTestString_);
14
16
  };
15
17
 
16
18
  goog.scope(function () {
@@ -9,11 +9,15 @@ goog.require('webfont.WebFont');
9
9
  */
10
10
  webfont.FontTestStrings;
11
11
 
12
- // Name of the global object.
13
- var globalName = 'WebFont';
12
+ /**
13
+ * Name of the global object
14
+ *
15
+ * @define {string}
16
+ */
17
+ var GLOBAL_NAME = 'WebFont';
14
18
 
15
19
  // Provide an instance of WebFont in the global namespace.
16
- var globalNamespaceObject = window[globalName] = (function() {
20
+ var globalNamespaceObject = window[GLOBAL_NAME] = (function() {
17
21
  var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
18
22
  var userAgent = userAgentParser.parse();
19
23
  var fontModuleLoader = new webfont.FontModuleLoader();
@@ -1,6 +1,7 @@
1
1
  goog.provide('webfont.UserAgent');
2
2
 
3
3
  /**
4
+ * @export
4
5
  * @param {string} name
5
6
  * @param {string} version
6
7
  * @param {string} engine
@@ -27,6 +28,7 @@ goog.scope(function () {
27
28
  var UserAgent = webfont.UserAgent;
28
29
 
29
30
  /**
31
+ * @export
30
32
  * @return {string}
31
33
  */
32
34
  UserAgent.prototype.getName = function() {
@@ -34,6 +36,7 @@ goog.scope(function () {
34
36
  };
35
37
 
36
38
  /**
39
+ * @export
37
40
  * @return {string}
38
41
  */
39
42
  UserAgent.prototype.getVersion = function() {
@@ -41,6 +44,7 @@ goog.scope(function () {
41
44
  };
42
45
 
43
46
  /**
47
+ * @export
44
48
  * @return {string}
45
49
  */
46
50
  UserAgent.prototype.getEngine = function() {
@@ -48,6 +52,7 @@ goog.scope(function () {
48
52
  };
49
53
 
50
54
  /**
55
+ * @export
51
56
  * @return {string}
52
57
  */
53
58
  UserAgent.prototype.getEngineVersion = function() {
@@ -55,6 +60,7 @@ goog.scope(function () {
55
60
  };
56
61
 
57
62
  /**
63
+ * @export
58
64
  * @return {string}
59
65
  */
60
66
  UserAgent.prototype.getPlatform = function() {
@@ -62,6 +68,7 @@ goog.scope(function () {
62
68
  };
63
69
 
64
70
  /**
71
+ * @export
65
72
  * @return {string}
66
73
  */
67
74
  UserAgent.prototype.getPlatformVersion = function() {
@@ -69,6 +76,7 @@ goog.scope(function () {
69
76
  };
70
77
 
71
78
  /**
79
+ * @export
72
80
  * @return {number|undefined}
73
81
  */
74
82
  UserAgent.prototype.getDocumentMode = function() {
@@ -76,6 +84,7 @@ goog.scope(function () {
76
84
  };
77
85
 
78
86
  /**
87
+ * @export
79
88
  * @return {webfont.BrowserInfo}
80
89
  */
81
90
  UserAgent.prototype.getBrowserInfo = function() {
@@ -77,8 +77,8 @@ goog.scope(function () {
77
77
  return;
78
78
  }
79
79
 
80
- module.load(function (fonts) {
81
- that.onModuleReady_(eventDispatcher, fontWatcher, fontWatchRunnerCtor, fonts);
80
+ module.load(function (fonts, opt_fontTestStrings) {
81
+ that.onModuleReady_(eventDispatcher, fontWatcher, fontWatchRunnerCtor, fonts, opt_fontTestStrings);
82
82
  });
83
83
  };
84
84
 
@@ -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.4.1'
17
- s.date = '2013-04-08'
16
+ s.version = '1.4.2'
17
+ s.date = '2013-04-11'
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 1
10
- version: 1.4.1
9
+ - 2
10
+ version: 1.4.2
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-04-08 00:00:00 Z
19
+ date: 2013-04-11 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rake