webfontloader 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README.md +20 -0
- data/lib/webfontloader.rb +1 -1
- data/spec/core/webfont_spec.js +51 -0
- data/src/core/webfont.js +9 -11
- data/webfontloader.gemspec +5 -2
- metadata +6 -6
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
v1.5.1 (October 15, 2013)
|
2
|
+
* Dispatch wf-loading event synchronously instead of waiting for asynchronous modules
|
3
|
+
* Update README explaining how to use custom fonts without a stylesheet
|
4
|
+
* Add license information to gemspec
|
5
|
+
|
1
6
|
v1.5.0 (September 9, 2013)
|
2
7
|
* Correctly categorize Internet Explorer 11 as an Internet Explorer version.
|
3
8
|
* Add support for custom test strings in the custom module.
|
data/README.md
CHANGED
@@ -180,6 +180,26 @@ In this example, the `fonts.css` file might look something like this:
|
|
180
180
|
src: ...;
|
181
181
|
}
|
182
182
|
|
183
|
+
Alternatively, you can load your fonts from a stylesheet not specified in WebFontConfig. As long as the names match those that are declared in the `families` array, the proper loading classes will be applied to the html element.
|
184
|
+
|
185
|
+
```
|
186
|
+
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
|
187
|
+
<script>
|
188
|
+
WebFont.load({
|
189
|
+
custom: {
|
190
|
+
families: ['My Font']
|
191
|
+
}
|
192
|
+
});
|
193
|
+
</script>
|
194
|
+
|
195
|
+
<style type="text/css">
|
196
|
+
@font-face {
|
197
|
+
font-family:"My Font";
|
198
|
+
src:url("assets/fonts/my_font.woff") format("woff");
|
199
|
+
}
|
200
|
+
</style>
|
201
|
+
```
|
202
|
+
|
183
203
|
The custom module also supports customizing the test strings that are used to determine whether or not a font has loaded. This can be used to load fonts with custom subsets or glyphs in the private use unicode area.
|
184
204
|
|
185
205
|
WebFontConfig = {
|
data/lib/webfontloader.rb
CHANGED
data/spec/core/webfont_spec.js
CHANGED
@@ -313,4 +313,55 @@ describe('WebFont', function () {
|
|
313
313
|
});
|
314
314
|
});
|
315
315
|
});
|
316
|
+
|
317
|
+
describe('synchronous load event', function () {
|
318
|
+
var font = null,
|
319
|
+
testModule = null,
|
320
|
+
inactive = null,
|
321
|
+
loading = null,
|
322
|
+
active = null;
|
323
|
+
|
324
|
+
beforeEach(function () {
|
325
|
+
inactive = jasmine.createSpy('inactive'),
|
326
|
+
active = jasmine.createSpy('active');
|
327
|
+
loading = jasmine.createSpy('loading');
|
328
|
+
|
329
|
+
font = new WebFont(window, fontModuleLoader, userAgent);
|
330
|
+
|
331
|
+
font.addModule('test', function (conf, domHelper) {
|
332
|
+
testModule = new function () {};
|
333
|
+
testModule.supportUserAgent = function (ua, support) {
|
334
|
+
window.setTimeout(function () {
|
335
|
+
support(true);
|
336
|
+
}, 100);
|
337
|
+
};
|
338
|
+
testModule.load = function (onReady) {
|
339
|
+
onReady([]);
|
340
|
+
};
|
341
|
+
|
342
|
+
return testModule;
|
343
|
+
});
|
344
|
+
});
|
345
|
+
|
346
|
+
it('fires loading event correctly', function () {
|
347
|
+
runs(function () {
|
348
|
+
font.load({
|
349
|
+
'test': {},
|
350
|
+
inactive: inactive,
|
351
|
+
active: active,
|
352
|
+
loading: loading
|
353
|
+
});
|
354
|
+
expect(loading).toHaveBeenCalled();
|
355
|
+
});
|
356
|
+
|
357
|
+
waitsFor(function () {
|
358
|
+
return active.wasCalled || inactive.wasCalled;
|
359
|
+
});
|
360
|
+
|
361
|
+
runs(function () {
|
362
|
+
expect(inactive).toHaveBeenCalled();
|
363
|
+
expect(active).not.toHaveBeenCalled();
|
364
|
+
});
|
365
|
+
});
|
366
|
+
});
|
316
367
|
});
|
data/src/core/webfont.js
CHANGED
@@ -66,12 +66,8 @@ goog.scope(function () {
|
|
66
66
|
|
67
67
|
this.moduleFailedLoading_--;
|
68
68
|
|
69
|
-
if (allModulesLoaded) {
|
70
|
-
|
71
|
-
eventDispatcher.dispatchInactive();
|
72
|
-
} else {
|
73
|
-
eventDispatcher.dispatchLoading();
|
74
|
-
}
|
69
|
+
if (allModulesLoaded && this.moduleFailedLoading_ == 0) {
|
70
|
+
eventDispatcher.dispatchInactive();
|
75
71
|
}
|
76
72
|
fontWatcher.watchFonts([], {}, null, allModulesLoaded);
|
77
73
|
}
|
@@ -87,10 +83,6 @@ goog.scope(function () {
|
|
87
83
|
WebFont.prototype.onModuleReady_ = function(eventDispatcher, fontWatcher, fonts, opt_fontTestStrings, opt_metricCompatibleFonts) {
|
88
84
|
var allModulesLoaded = --this.moduleLoading_ == 0;
|
89
85
|
|
90
|
-
if (allModulesLoaded) {
|
91
|
-
eventDispatcher.dispatchLoading();
|
92
|
-
}
|
93
|
-
|
94
86
|
setTimeout(function () {
|
95
87
|
fontWatcher.watchFonts(fonts, opt_fontTestStrings || {}, opt_metricCompatibleFonts || null, allModulesLoaded);
|
96
88
|
}, 0);
|
@@ -101,10 +93,16 @@ goog.scope(function () {
|
|
101
93
|
* @param {Object} configuration
|
102
94
|
*/
|
103
95
|
WebFont.prototype.load_ = function(eventDispatcher, configuration) {
|
104
|
-
var modules =
|
96
|
+
var modules = [],
|
105
97
|
timeout = configuration['timeout'],
|
106
98
|
self = this;
|
107
99
|
|
100
|
+
// Immediately dispatch the loading event before initializing the modules
|
101
|
+
// so we know for sure that the loading event is synchronous.
|
102
|
+
eventDispatcher.dispatchLoading();
|
103
|
+
|
104
|
+
modules = this.fontModuleLoader_.getModules(configuration, this.domHelper_);
|
105
|
+
|
108
106
|
this.moduleFailedLoading_ = this.moduleLoading_ = modules.length;
|
109
107
|
|
110
108
|
var fontWatcher = new webfont.FontWatcher(this.userAgent_, this.domHelper_, eventDispatcher, timeout);
|
data/webfontloader.gemspec
CHANGED
@@ -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.5.
|
17
|
-
s.date = '2013-
|
16
|
+
s.version = '1.5.1'
|
17
|
+
s.date = '2013-10-15'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -33,6 +33,9 @@ DESC
|
|
33
33
|
s.email = 'ryan@typekit.com'
|
34
34
|
s.homepage = 'http://github.com/typekit/webfontloader'
|
35
35
|
|
36
|
+
## License
|
37
|
+
s.license = "Apache 2.0"
|
38
|
+
|
36
39
|
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
37
40
|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
38
41
|
s.require_paths = %w[lib]
|
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:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 1
|
10
|
+
version: 1.5.1
|
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-
|
19
|
+
date: 2013-10-15 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rake
|
@@ -204,8 +204,8 @@ files:
|
|
204
204
|
- tools/jasmine/jasmine.js
|
205
205
|
- webfontloader.gemspec
|
206
206
|
homepage: http://github.com/typekit/webfontloader
|
207
|
-
licenses:
|
208
|
-
|
207
|
+
licenses:
|
208
|
+
- Apache 2.0
|
209
209
|
post_install_message:
|
210
210
|
rdoc_options:
|
211
211
|
- --charset=UTF-8
|