webfontloader 1.4.10 → 1.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/LICENSE +0 -25
- data/README.md +9 -17
- data/lib/webfontloader/demo/public/index.html +2 -4
- data/lib/webfontloader.rb +1 -1
- data/spec/deps.js +0 -1
- data/spec/index.html +0 -2
- data/spec/modules/monotype_spec.js +2 -2
- data/src/modules/monotype.js +1 -1
- data/src/modules.yml +1 -2
- data/webfontloader.gemspec +2 -6
- metadata +4 -8
- data/lib/webfontloader/demo/public/ascender-iframe.html +0 -46
- data/lib/webfontloader/demo/public/ascender.html +0 -99
- data/spec/modules/ascender_spec.js +0 -64
- data/src/modules/ascender.js +0 -107
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
v1.4.11 (August 8, 2013)
|
2
|
+
* Remove Ascender module (according to Monotype the service has now been shutdown completely.)
|
3
|
+
* Switch Monotype module to use fast.fonts.net instead of fast.fonts.com
|
4
|
+
* Update license
|
5
|
+
|
1
6
|
v1.4.10 (July 31, 2013)
|
2
7
|
* Add loadStylesheet method with optional callback that replaces createCssLink
|
3
8
|
* Remove supportForStyle check because it breaks XHTML/SVG and is no longer necessary
|
data/LICENSE
CHANGED
@@ -174,28 +174,3 @@
|
|
174
174
|
of your accepting any such warranty or additional liability.
|
175
175
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
177
|
-
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
179
|
-
|
180
|
-
To apply the Apache License to your work, attach the following
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
-
replaced with your own identifying information. (Don't include
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
184
|
-
comment syntax for the file format. We also recommend that a
|
185
|
-
file or class name and description of purpose be included on the
|
186
|
-
same "printed page" as the copyright notice for easier
|
187
|
-
identification within third-party archives.
|
188
|
-
|
189
|
-
Copyright [2010] [Small Batch Inc]
|
190
|
-
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
-
you may not use this file except in compliance with the License.
|
193
|
-
You may obtain a copy of the License at
|
194
|
-
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
-
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
-
See the License for the specific language governing permissions and
|
201
|
-
limitations under the License.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Web Font Loader
|
2
2
|
|
3
|
-
Web Font Loader gives you added control when using linked fonts via `@font-face`. It provides a common interface to loading fonts regardless of the source, then adds a standard set of events you may use to control the loading experience. The Web Font Loader is able to load fonts from [Google Fonts](http://www.google.com/fonts/), [Typekit](http://www.typekit.com/),
|
3
|
+
Web Font Loader gives you added control when using linked fonts via `@font-face`. It provides a common interface to loading fonts regardless of the source, then adds a standard set of events you may use to control the loading experience. The Web Font Loader is able to load fonts from [Google Fonts](http://www.google.com/fonts/), [Typekit](http://www.typekit.com/), [Fonts.com](http://www.fonts.com/), and [Fontdeck](http://fontdeck.com/), as well as self-hosted web fonts. It is co-developed by [Google](http://www.google.com/) and [Typekit](http://www.typekit.com).
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/typekit/webfontloader.png?branch=master)](https://travis-ci.org/typekit/webfontloader)
|
6
6
|
|
@@ -12,7 +12,6 @@ Web Font Loader gives you added control when using linked fonts via `@font-face`
|
|
12
12
|
* [Timeout](#timeout)
|
13
13
|
* [Iframes](#iframes)
|
14
14
|
* [Modules](#modules)
|
15
|
-
* [Ascender](#ascender)
|
16
15
|
* [Custom](#custom)
|
17
16
|
* [Fontdeck](#fontdeck)
|
18
17
|
* [Fonts.com](#fonts.com)
|
@@ -139,19 +138,6 @@ This is an advanced configuration option that isn't needed for most use cases.
|
|
139
138
|
|
140
139
|
Web Font Loader provides a module system so that any web font provider can contribute code that allows their fonts to be loaded. This makes it possible to use multiple web font providers at the same time. The specifics of each provider currently supported by the library are documented here.
|
141
140
|
|
142
|
-
### Ascender
|
143
|
-
|
144
|
-
To load fonts from the FontsLive service use the `ascender` module.
|
145
|
-
|
146
|
-
WebFontConfig = {
|
147
|
-
ascender: {
|
148
|
-
key: 'myAscenderKey',
|
149
|
-
families: [ 'AscenderSans:bold,bolditalic,italic,regular' ]
|
150
|
-
}
|
151
|
-
};
|
152
|
-
|
153
|
-
**NOTE**: The Ascender font service has been acquired by Monotype (Fonts.com) and as such the use of the Fonts.com module is recommended.
|
154
|
-
|
155
141
|
### Custom
|
156
142
|
|
157
143
|
To load fonts from any external stylesheet, use the `custom` module. Here you'll
|
@@ -269,6 +255,12 @@ For example:
|
|
269
255
|
|
270
256
|
If `providerA` can serve fonts to a browser, but `providerB` cannot, The `fontinactive` event will be triggered for `Family2`. The `fontactive` event will be triggered for `Family1` once it loads, as will the `active` event.
|
271
257
|
|
272
|
-
## License
|
258
|
+
## Copyright and License
|
259
|
+
|
260
|
+
Web Font Loader Copyright (c) 2010 Adobe Systems Incorporated, Google Incorporated.
|
261
|
+
|
262
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
263
|
+
|
264
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
273
265
|
|
274
|
-
|
266
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
@@ -23,9 +23,8 @@
|
|
23
23
|
<li><a href="/google.html">Google / Web Font Loader</a>: Load fonts from Google with Web Font Loader.</li>
|
24
24
|
<li><a href="/typekit.html">Typekit / Web Font Loader</a>: Load fonts from Typekit with Web Font Loader.</li>
|
25
25
|
<li><a href="/custom.html">Custom / Web Font Loader</a>: Load fonts from your own CSS with Web Font Loader.</li>
|
26
|
-
<li><a href="/ascender.html">Ascender / Web Font Loader</a>: Load fonts from Ascender with Web Font Loader.</li>
|
27
26
|
<li><a href="/fontdeck.html">Fontdeck / Web Font Loader</a>: Load fonts from Fontdeck with Web Font Loader.</li>
|
28
|
-
<li><a href="/monotype.html">Monotype / Web Font Loader</a>: Load fonts from
|
27
|
+
<li><a href="/monotype.html">Monotype / Web Font Loader</a>: Load fonts from fonts.com with Web Font Loader.</li>
|
29
28
|
</ol>
|
30
29
|
|
31
30
|
<h2>Modules in Iframes</h2>
|
@@ -36,9 +35,8 @@
|
|
36
35
|
<li><a href="/google-iframe.html">Google / Web Font Loader</a>: Load fonts from Google in a child iframe with Web Font Loader.</li>
|
37
36
|
<li><a href="/typekit-iframe.html">Typekit / Web Font Loader</a>: Load fonts from Typekit in a child iframe with Web Font Loader.</li>
|
38
37
|
<li><a href="/custom-iframe.html">Custom / Web Font Loader</a>: Load fonts from your own CSS in a child iframe with Web Font Loader.</li>
|
39
|
-
<li><a href="/ascender-iframe.html">Ascender / Web Font Loader</a>: Load fonts from Ascender in a child iframe with Web Font Loader.</li>
|
40
38
|
<li>Fontdeck / Web Font Loader: Their demo fonts seem to be broken at the moment, so we don't have an iframe demo of this module.</li>
|
41
|
-
<li><a href="/monotype-iframe.html">Monotype / Web Font Loader</a>: Load fonts from
|
39
|
+
<li><a href="/monotype-iframe.html">Monotype / Web Font Loader</a>: Load fonts from fonts.com in a child iframe with Web Font Loader.</li>
|
42
40
|
</ol>
|
43
41
|
|
44
42
|
<h2>Events</h2>
|
data/lib/webfontloader.rb
CHANGED
data/spec/deps.js
CHANGED
@@ -16,7 +16,6 @@ goog.addDependency("../../src/core/useragent.js", ["webfont.UserAgent"], []);
|
|
16
16
|
goog.addDependency("../../src/core/useragentparser.js", ["webfont.UserAgentParser"], ["webfont.BrowserInfo","webfont.UserAgent","webfont.Version"]);
|
17
17
|
goog.addDependency("../../src/core/version.js", ["webfont.Version"], []);
|
18
18
|
goog.addDependency("../../src/core/webfont.js", ["webfont.WebFont"], ["webfont.DomHelper","webfont.EventDispatcher","webfont.FontWatcher"]);
|
19
|
-
goog.addDependency("../../src/modules/ascender.js", ["webfont.modules.Ascender"], ["webfont.Font"]);
|
20
19
|
goog.addDependency("../../src/modules/custom.js", ["webfont.modules.Custom"], ["webfont.Font"]);
|
21
20
|
goog.addDependency("../../src/modules/fontdeck.js", ["webfont.modules.Fontdeck"], ["webfont.Font"]);
|
22
21
|
goog.addDependency("../../src/modules/google/fontapiparser.js", ["webfont.modules.google.FontApiParser"], ["webfont.Font"]);
|
data/spec/index.html
CHANGED
@@ -29,7 +29,6 @@
|
|
29
29
|
// Require the modules because they don't have an explicit
|
30
30
|
// dependency on core.
|
31
31
|
goog.require('webfont.modules.Typekit');
|
32
|
-
goog.require('webfont.modules.Ascender');
|
33
32
|
goog.require('webfont.modules.Fontdeck');
|
34
33
|
goog.require('webfont.modules.Monotype');
|
35
34
|
goog.require('webfont.modules.Custom');
|
@@ -51,7 +50,6 @@
|
|
51
50
|
<script src="../spec/modules/google/fontapiurlbuilder_spec.js"></script>
|
52
51
|
<script src="../spec/modules/google/googlefontapi_spec.js"></script>
|
53
52
|
<script src="../spec/modules/custom_spec.js"></script>
|
54
|
-
<script src="../spec/modules/ascender_spec.js"></script>
|
55
53
|
<script src="../spec/modules/fontdeck_spec.js"></script>
|
56
54
|
<script src="../spec/modules/monotype_spec.js"></script>
|
57
55
|
<script src="../spec/modules/typekit_spec.js"></script>
|
@@ -7,7 +7,7 @@ describe('modules.Monotype', function () {
|
|
7
7
|
|
8
8
|
var configuration = {
|
9
9
|
projectId: '01e2ff27-25bf-4801-a23e-73d328e6c7cc',
|
10
|
-
api: 'http://fast.fonts.
|
10
|
+
api: 'http://fast.fonts.net/jsapidev'
|
11
11
|
};
|
12
12
|
|
13
13
|
var fakeDomHelper = null,
|
@@ -60,7 +60,7 @@ describe('modules.Monotype', function () {
|
|
60
60
|
it('should create a script element', function () {
|
61
61
|
expect(support).toHaveBeenCalled();
|
62
62
|
expect(fakeDomHelper.loadScript).toHaveBeenCalled();
|
63
|
-
expect(fakeDomHelper.loadScript.calls[0].args[0]).toEqual('http://fast.fonts.
|
63
|
+
expect(fakeDomHelper.loadScript.calls[0].args[0]).toEqual('http://fast.fonts.net/jsapidev/01e2ff27-25bf-4801-a23e-73d328e6c7cc.js');
|
64
64
|
expect(load).toHaveBeenCalledWith([new Font('aachen bold'), new Font('kid print regular')]);
|
65
65
|
});
|
66
66
|
});
|
data/src/modules/monotype.js
CHANGED
@@ -79,7 +79,7 @@ goog.scope(function () {
|
|
79
79
|
|
80
80
|
Monotype.prototype.getScriptSrc = function (projectId, version) {
|
81
81
|
var p = this.domHelper_.getProtocol();
|
82
|
-
var api = (this.configuration_['api'] || 'fast.fonts.
|
82
|
+
var api = (this.configuration_['api'] || 'fast.fonts.net/jsapi').replace(/^.*http(s?):(\/\/)?/, "");
|
83
83
|
return p + "//" + api + '/' + projectId + '.js' + ( version ? '?v='+ version : '' );
|
84
84
|
};
|
85
85
|
|
data/src/modules.yml
CHANGED
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.4.
|
17
|
-
s.date = '2013-
|
16
|
+
s.version = '1.4.11'
|
17
|
+
s.date = '2013-08-08'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -75,8 +75,6 @@ DESC
|
|
75
75
|
Rakefile
|
76
76
|
bin/webfontloader-demos
|
77
77
|
lib/webfontloader.rb
|
78
|
-
lib/webfontloader/demo/public/ascender-iframe.html
|
79
|
-
lib/webfontloader/demo/public/ascender.html
|
80
78
|
lib/webfontloader/demo/public/basic.css
|
81
79
|
lib/webfontloader/demo/public/blank.html
|
82
80
|
lib/webfontloader/demo/public/custom-iframe.html
|
@@ -138,7 +136,6 @@ DESC
|
|
138
136
|
spec/fixtures/fonts/sourcesanscbold.css
|
139
137
|
spec/fixtures/fonts/sourcesanscbold.otf
|
140
138
|
spec/index.html
|
141
|
-
spec/modules/ascender_spec.js
|
142
139
|
spec/modules/custom_spec.js
|
143
140
|
spec/modules/fontdeck_spec.js
|
144
141
|
spec/modules/google/fontapiparser_spec.js
|
@@ -164,7 +161,6 @@ DESC
|
|
164
161
|
src/core/version.js
|
165
162
|
src/core/webfont.js
|
166
163
|
src/modules.yml
|
167
|
-
src/modules/ascender.js
|
168
164
|
src/modules/custom.js
|
169
165
|
src/modules/fontdeck.js
|
170
166
|
src/modules/google/fontapiparser.js
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 11
|
10
|
+
version: 1.4.11
|
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-08-08 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rake
|
@@ -103,8 +103,6 @@ files:
|
|
103
103
|
- Rakefile
|
104
104
|
- bin/webfontloader-demos
|
105
105
|
- lib/webfontloader.rb
|
106
|
-
- lib/webfontloader/demo/public/ascender-iframe.html
|
107
|
-
- lib/webfontloader/demo/public/ascender.html
|
108
106
|
- lib/webfontloader/demo/public/basic.css
|
109
107
|
- lib/webfontloader/demo/public/blank.html
|
110
108
|
- lib/webfontloader/demo/public/custom-iframe.html
|
@@ -166,7 +164,6 @@ files:
|
|
166
164
|
- spec/fixtures/fonts/sourcesanscbold.css
|
167
165
|
- spec/fixtures/fonts/sourcesanscbold.otf
|
168
166
|
- spec/index.html
|
169
|
-
- spec/modules/ascender_spec.js
|
170
167
|
- spec/modules/custom_spec.js
|
171
168
|
- spec/modules/fontdeck_spec.js
|
172
169
|
- spec/modules/google/fontapiparser_spec.js
|
@@ -192,7 +189,6 @@ files:
|
|
192
189
|
- src/core/version.js
|
193
190
|
- src/core/webfont.js
|
194
191
|
- src/modules.yml
|
195
|
-
- src/modules/ascender.js
|
196
192
|
- src/modules/custom.js
|
197
193
|
- src/modules/fontdeck.js
|
198
194
|
- src/modules/google/fontapiparser.js
|
@@ -1,46 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Ascender Module Demo</title>
|
5
|
-
<link href="/basic.css" rel="stylesheet" type="text/css">
|
6
|
-
<script type="text/javascript" src="/webfont.js"></script>
|
7
|
-
<style type="text/css">
|
8
|
-
iframe {
|
9
|
-
height: 100px;
|
10
|
-
width: 100%;
|
11
|
-
}
|
12
|
-
</style>
|
13
|
-
</head>
|
14
|
-
<body>
|
15
|
-
<script type="text/javascript">
|
16
|
-
function loaded() {
|
17
|
-
var child = frames["child"];
|
18
|
-
child.document.body.innerHTML = "<h1 style=\"font-family: 'AyitaPro'\">Hello World. I am Ayita Pro.</h1>";
|
19
|
-
WebFont.load({
|
20
|
-
ascender: {
|
21
|
-
key:'ec2de397-11ae-4c10-937f-bf94283a70c1',
|
22
|
-
families:['AyitaPro:regular,bold,bolditalic,italic']
|
23
|
-
},
|
24
|
-
context: child
|
25
|
-
});
|
26
|
-
}
|
27
|
-
</script>
|
28
|
-
|
29
|
-
<iframe name="child" src="/blank.html" onload="loaded()"></iframe>
|
30
|
-
|
31
|
-
<hr>
|
32
|
-
|
33
|
-
<p>
|
34
|
-
<a href="#" onclick="document.getElementsByTagName('body')[0].style.color = '#fff';return false;">Hide Page</a> |
|
35
|
-
<a href="/ascender.html">Reload Cached</a>
|
36
|
-
</p>
|
37
|
-
<p>
|
38
|
-
Note: use "localhost" when testing web fonts.
|
39
|
-
</p>
|
40
|
-
<p>
|
41
|
-
The goal of this page is to show how fonts load from Ascender in a child
|
42
|
-
iframe.
|
43
|
-
</p>
|
44
|
-
|
45
|
-
</body>
|
46
|
-
</html>
|
@@ -1,99 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Ascender Module Demo</title>
|
5
|
-
<link href="/basic.css" rel="stylesheet" type="text/css">
|
6
|
-
<script type="text/javascript" src="/webfont.js"></script>
|
7
|
-
<style type="text/css">
|
8
|
-
/* Use classes to prove that Ascender module triggers the event system correctly */
|
9
|
-
#demo {
|
10
|
-
visibility: hidden;
|
11
|
-
line-height:normal;
|
12
|
-
}
|
13
|
-
.wf-ayitapro-n4-active #demo {
|
14
|
-
font-family: 'AyitaPro';
|
15
|
-
visibility: visible;
|
16
|
-
}
|
17
|
-
</style>
|
18
|
-
</head>
|
19
|
-
<body>
|
20
|
-
<div id="demo">
|
21
|
-
<h1>Hello World. I am Ayita Pro.</h1>
|
22
|
-
|
23
|
-
<h2>Regular:</h2>
|
24
|
-
<p style="font-weight:normal; font-style:normal;">
|
25
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus eleifend aliquam. Nullam eu volutpat orci. Sed scelerisque pulvinar lorem, non ornare risus varius sed. Integer in lorem ut tortor rutrum placerat. Duis quis ante nec nulla luctus tincidunt. Aenean lorem metus, venenatis id sagittis eget, sodales ut justo. Donec quis dictum erat. Nunc ac feugiat sapien. In laoreet nisl in nisl ullamcorper porttitor. Ut vitae tortor leo, nec euismod sapien. Vivamus pellentesque, est in vulputate dictum, lectus diam interdum ipsum, sit amet posuere libero dui et sapien. Curabitur sit amet pulvinar massa.
|
26
|
-
</p>
|
27
|
-
|
28
|
-
<h2>Bold:</h2>
|
29
|
-
<p style="font-weight:bold; font-style:normal;">
|
30
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus eleifend aliquam. Nullam eu volutpat orci. Sed scelerisque pulvinar lorem, non ornare risus varius sed. Integer in lorem ut tortor rutrum placerat. Duis quis ante nec nulla luctus tincidunt. Aenean lorem metus, venenatis id sagittis eget, sodales ut justo. Donec quis dictum erat. Nunc ac feugiat sapien. In laoreet nisl in nisl ullamcorper porttitor. Ut vitae tortor leo, nec euismod sapien. Vivamus pellentesque, est in vulputate dictum, lectus diam interdum ipsum, sit amet posuere libero dui et sapien. Curabitur sit amet pulvinar massa.
|
31
|
-
</p>
|
32
|
-
|
33
|
-
<h2>Italic:</h2>
|
34
|
-
<p style="font-weight:normal; font-style:italic;">
|
35
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus eleifend aliquam. Nullam eu volutpat orci. Sed scelerisque pulvinar lorem, non ornare risus varius sed. Integer in lorem ut tortor rutrum placerat. Duis quis ante nec nulla luctus tincidunt. Aenean lorem metus, venenatis id sagittis eget, sodales ut justo. Donec quis dictum erat. Nunc ac feugiat sapien. In laoreet nisl in nisl ullamcorper porttitor. Ut vitae tortor leo, nec euismod sapien. Vivamus pellentesque, est in vulputate dictum, lectus diam interdum ipsum, sit amet posuere libero dui et sapien. Curabitur sit amet pulvinar massa.
|
36
|
-
</p>
|
37
|
-
|
38
|
-
<h2>Bold Italic:</h2>
|
39
|
-
<p style="font-weight:bold; font-style:italic;">
|
40
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus eleifend aliquam. Nullam eu volutpat orci. Sed scelerisque pulvinar lorem, non ornare risus varius sed. Integer in lorem ut tortor rutrum placerat. Duis quis ante nec nulla luctus tincidunt. Aenean lorem metus, venenatis id sagittis eget, sodales ut justo. Donec quis dictum erat. Nunc ac feugiat sapien. In laoreet nisl in nisl ullamcorper porttitor. Ut vitae tortor leo, nec euismod sapien. Vivamus pellentesque, est in vulputate dictum, lectus diam interdum ipsum, sit amet posuere libero dui et sapien. Curabitur sit amet pulvinar massa.
|
41
|
-
</p>
|
42
|
-
</div>
|
43
|
-
<hr>
|
44
|
-
<p>
|
45
|
-
<a href="#" onclick="document.getElementsByTagName('body')[0].style.color = '#fff';return false;">Hide Page</a> |
|
46
|
-
<a href="/ascender.html">Reload Cached</a>
|
47
|
-
</p>
|
48
|
-
<p>
|
49
|
-
Note: use "localhost" when testing web fonts.
|
50
|
-
</p>
|
51
|
-
<p>
|
52
|
-
The goal of this page is to show how fonts load from Ascender.
|
53
|
-
</p>
|
54
|
-
<h2>JavaScript Event Progress</h2>
|
55
|
-
<ol id="events"></ol>
|
56
|
-
|
57
|
-
<script type="text/javascript">
|
58
|
-
function progress(message) {
|
59
|
-
var output = document.getElementById('events');
|
60
|
-
if (output) {
|
61
|
-
var e = document.createElement('li');
|
62
|
-
e.innerHTML = message;
|
63
|
-
output.appendChild(e);
|
64
|
-
}
|
65
|
-
if (window.console && window.console.log) {
|
66
|
-
window.console.log(message);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
//Families must match families
|
71
|
-
//that are included in provided CSS
|
72
|
-
WebFont.load({
|
73
|
-
ascender: {
|
74
|
-
key:'ec2de397-11ae-4c10-937f-bf94283a70c1',
|
75
|
-
families:['AyitaPro:regular,bold,bolditalic,italic']
|
76
|
-
},
|
77
|
-
loading: function() {
|
78
|
-
progress('loading');
|
79
|
-
},
|
80
|
-
active: function() {
|
81
|
-
progress('active');
|
82
|
-
},
|
83
|
-
inactive: function() {
|
84
|
-
progress('inactive');
|
85
|
-
},
|
86
|
-
fontloading: function(fontFamily, fontDescription) {
|
87
|
-
progress('fontloading: ' + fontFamily + ' (' + fontDescription + ')');
|
88
|
-
},
|
89
|
-
fontactive: function(fontFamily, fontDescription) {
|
90
|
-
progress('fontactive: ' + fontFamily + ' (' + fontDescription + ')');
|
91
|
-
},
|
92
|
-
fontinactive: function(fontFamily, fontDescription) {
|
93
|
-
progress('fontinactive: ' + fontFamily + ' (' + fontDescription + ')');
|
94
|
-
}
|
95
|
-
});
|
96
|
-
</script>
|
97
|
-
|
98
|
-
</body>
|
99
|
-
</html>
|
@@ -1,64 +0,0 @@
|
|
1
|
-
describe('modules.Ascender', function () {
|
2
|
-
var Ascender = webfont.modules.Ascender,
|
3
|
-
Font = webfont.Font;
|
4
|
-
|
5
|
-
var configuration = {
|
6
|
-
key: 'ec2de397-11ae-4c10-937f-bf94283a70c1',
|
7
|
-
families: ['AndyBold', 'Arial:bold,regular']
|
8
|
-
};
|
9
|
-
|
10
|
-
describe('load family and variations', function () {
|
11
|
-
var fakeDomHelper = null,
|
12
|
-
fakeOnReady = null,
|
13
|
-
ascender = null;
|
14
|
-
|
15
|
-
beforeEach(function () {
|
16
|
-
fakeDomHelper = {
|
17
|
-
loadStylesheet: jasmine.createSpy('createCssLink'),
|
18
|
-
getProtocol: jasmine.createSpy('getProtocol').andReturn('http:')
|
19
|
-
};
|
20
|
-
|
21
|
-
fakeOnReady = jasmine.createSpy('onReady');
|
22
|
-
|
23
|
-
ascender = new Ascender(fakeDomHelper, configuration);
|
24
|
-
ascender.load(fakeOnReady);
|
25
|
-
});
|
26
|
-
|
27
|
-
it('should create the link correctly', function () {
|
28
|
-
expect(fakeDomHelper.loadStylesheet).toHaveBeenCalledWith('http://webfonts.fontslive.com/css/ec2de397-11ae-4c10-937f-bf94283a70c1.css');
|
29
|
-
});
|
30
|
-
|
31
|
-
it('should pass the fonts correctly', function () {
|
32
|
-
expect(fakeOnReady).toHaveBeenCalledWith([
|
33
|
-
new Font('AndyBold', 'n4'),
|
34
|
-
new Font('Arial', 'n7'),
|
35
|
-
new Font('Arial', 'n4')
|
36
|
-
]);
|
37
|
-
});
|
38
|
-
|
39
|
-
it('should parse variations correctly', function () {
|
40
|
-
expect(ascender.parseVariations('regular')).toEqual(['n4']);
|
41
|
-
expect(ascender.parseVariations('bold')).toEqual(['n7']);
|
42
|
-
expect(ascender.parseVariations('italic')).toEqual(['i4']);
|
43
|
-
expect(ascender.parseVariations('bolditalic')).toEqual(['i7']);
|
44
|
-
expect(ascender.parseVariations('regular,')).toEqual(['n4']);
|
45
|
-
expect(ascender.parseVariations('regular,bold')).toEqual(['n4', 'n7']);
|
46
|
-
expect(ascender.parseVariations('regular,,bold')).toEqual(['n4', 'n7']);
|
47
|
-
expect(ascender.parseVariations('n4,n7')).toEqual(['n4', 'n7']);
|
48
|
-
});
|
49
|
-
|
50
|
-
it('should parse font families correctly', function () {
|
51
|
-
expect(ascender.parseFamilyAndVariations('Arial')).toEqual([new Font('Arial')]);
|
52
|
-
expect(ascender.parseFamilyAndVariations('Arial:bold,regular')).toEqual([new Font('Arial', 'n7'), new Font('Arial', 'n4')]);
|
53
|
-
expect(ascender.parseFamilyAndVariations('Arial:n4,n7')).toEqual([new Font('Arial', 'n4'), new Font('Arial', 'n7')]);
|
54
|
-
});
|
55
|
-
|
56
|
-
it('should parse multiple font families correctly', function () {
|
57
|
-
expect(ascender.parseFamiliesAndVariations(['Arial', 'Sans:n4,n7'])).toEqual([
|
58
|
-
new Font('Arial', 'n4'),
|
59
|
-
new Font('Sans', 'n4'),
|
60
|
-
new Font('Sans', 'n7')
|
61
|
-
]);
|
62
|
-
});
|
63
|
-
})
|
64
|
-
});
|
data/src/modules/ascender.js
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
goog.provide('webfont.modules.Ascender');
|
2
|
-
|
3
|
-
goog.require('webfont.Font');
|
4
|
-
|
5
|
-
/**
|
6
|
-
*
|
7
|
-
* WebFont.load({
|
8
|
-
* ascender: {
|
9
|
-
* key:'ec2de397-11ae-4c10-937f-bf94283a70c1',
|
10
|
-
* families:['AyitaPro:regular,bold,bolditalic,italic']
|
11
|
-
* }
|
12
|
-
* });
|
13
|
-
*
|
14
|
-
* @constructor
|
15
|
-
* @implements {webfont.FontModule}
|
16
|
-
*/
|
17
|
-
webfont.modules.Ascender = function(domHelper, configuration) {
|
18
|
-
this.domHelper_ = domHelper;
|
19
|
-
this.configuration_ = configuration;
|
20
|
-
};
|
21
|
-
|
22
|
-
webfont.modules.Ascender.NAME = 'ascender';
|
23
|
-
|
24
|
-
webfont.modules.Ascender.VARIATIONS = {
|
25
|
-
'regular': 'n4',
|
26
|
-
'bold': 'n7',
|
27
|
-
'italic': 'i4',
|
28
|
-
'bolditalic': 'i7',
|
29
|
-
'r': 'n4',
|
30
|
-
'b': 'n7',
|
31
|
-
'i': 'i4',
|
32
|
-
'bi': 'i7'
|
33
|
-
};
|
34
|
-
|
35
|
-
goog.scope(function () {
|
36
|
-
var Ascender = webfont.modules.Ascender,
|
37
|
-
Font = webfont.Font;
|
38
|
-
|
39
|
-
Ascender.prototype.supportUserAgent = function(userAgent, support) {
|
40
|
-
return support(userAgent.getBrowserInfo().hasWebFontSupport());
|
41
|
-
};
|
42
|
-
|
43
|
-
Ascender.prototype.load = function(onReady) {
|
44
|
-
var key = this.configuration_['key'];
|
45
|
-
var protocol = this.domHelper_.getProtocol();
|
46
|
-
var url = protocol + '//webfonts.fontslive.com/css/' + key + '.css';
|
47
|
-
this.domHelper_.loadStylesheet(url);
|
48
|
-
var fv = this.parseFamiliesAndVariations(this.configuration_['families']);
|
49
|
-
onReady(fv);
|
50
|
-
};
|
51
|
-
|
52
|
-
/**
|
53
|
-
* @param {Array.<string>} providedFamilies
|
54
|
-
* @return {Array.<webfont.Font>}
|
55
|
-
*/
|
56
|
-
Ascender.prototype.parseFamiliesAndVariations = function (providedFamilies) {
|
57
|
-
var fonts = [];
|
58
|
-
|
59
|
-
for (var i = 0, len = providedFamilies.length; i < len; i++) {
|
60
|
-
fonts.push.apply(fonts, this.parseFamilyAndVariations(providedFamilies[i]));
|
61
|
-
}
|
62
|
-
return fonts;
|
63
|
-
};
|
64
|
-
|
65
|
-
/**
|
66
|
-
* @param {string} providedFamily
|
67
|
-
* @return {Array.<webfont.Font>}
|
68
|
-
*/
|
69
|
-
Ascender.prototype.parseFamilyAndVariations = function (providedFamily){
|
70
|
-
var parts = providedFamily.split(':'),
|
71
|
-
familyName = parts[0];
|
72
|
-
|
73
|
-
if (parts[1]) {
|
74
|
-
var variations = this.parseVariations(parts[1]),
|
75
|
-
result = [];
|
76
|
-
|
77
|
-
for (var i = 0; i < variations.length; i += 1) {
|
78
|
-
result.push(new Font(familyName, variations[i]));
|
79
|
-
}
|
80
|
-
return result;
|
81
|
-
}
|
82
|
-
return [new Font(familyName)];
|
83
|
-
};
|
84
|
-
|
85
|
-
/**
|
86
|
-
* @param {string} source
|
87
|
-
* @return {Array.<string>}
|
88
|
-
*/
|
89
|
-
Ascender.prototype.parseVariations = function (source) {
|
90
|
-
var providedVariations = source.split(','),
|
91
|
-
variations = [];
|
92
|
-
|
93
|
-
for (var i = 0, len = providedVariations.length; i < len; i++){
|
94
|
-
var pv = providedVariations[i];
|
95
|
-
|
96
|
-
if (pv) {
|
97
|
-
var v = Ascender.VARIATIONS[pv];
|
98
|
-
variations.push(v ? v : pv);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
return variations;
|
102
|
-
};
|
103
|
-
});
|
104
|
-
|
105
|
-
globalNamespaceObject.addModule(webfont.modules.Ascender.NAME, function(configuration, domHelper) {
|
106
|
-
return new webfont.modules.Ascender(domHelper, configuration);
|
107
|
-
});
|