webfontloader 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/webfontloader.rb +1 -1
- data/spec/ascender/ascenderscript_spec.js +24 -1
- data/spec/core/eventdispatcher_spec.js +15 -11
- data/spec/core/font_spec.js +83 -192
- data/spec/core/fontruler_spec.js +7 -4
- data/spec/core/fontwatcher_spec.js +78 -61
- data/spec/core/fontwatchrunner_spec.js +85 -33
- data/spec/core/webfont_spec.js +224 -0
- data/spec/custom/customcss_spec.js +5 -2
- data/spec/deps.js +13 -13
- data/spec/fontdeck/fontdeckscript_spec.js +4 -6
- data/spec/fonts/sourcesansc.css +1 -0
- data/spec/fonts/sourcesanscbold.css +1 -0
- data/spec/fonts/sourcesanscbold.otf +0 -0
- data/spec/google/fontapiparser_spec.js +58 -178
- data/spec/google/googlefontapi_spec.js +14 -42
- data/spec/google/lastresortwebkitfontwatchrunner_spec.js +12 -10
- data/spec/index.html +5 -3
- data/spec/monotype/monotypescript_spec.js +3 -2
- data/spec/typekit/typekitscript_spec.js +9 -4
- data/src/ascender/ascender_script.js +43 -26
- data/src/core/eventdispatcher.js +23 -23
- data/src/core/font.js +80 -99
- data/src/core/fontmoduleloader.js +1 -1
- data/src/core/fontruler.js +10 -20
- data/src/core/fontwatcher.js +24 -46
- data/src/core/fontwatchrunner.js +13 -13
- data/src/core/initialize.js +0 -10
- data/src/core/webfont.js +134 -0
- data/src/custom/customcss.js +14 -10
- data/src/fontdeck/fontdeck_script.js +7 -9
- data/src/google/fontapiparser.js +11 -15
- data/src/google/googlefontapi.js +1 -2
- data/src/google/lastresortwebkitfontwatchrunner.js +15 -13
- data/src/modules.yml +2 -3
- data/src/monotype/monotype_script.js +9 -8
- data/src/typekit/typekit_script.js +17 -7
- data/webfontloader.gemspec +7 -6
- metadata +9 -8
- data/spec/core/cssfontfamilyname_spec.js +0 -38
- data/spec/core/fontvariationdescription_spec.js +0 -67
- data/src/core/cssfontfamilyname.js +0 -33
- data/src/core/fontvariationdescription.js +0 -140
@@ -0,0 +1,224 @@
|
|
1
|
+
describe('WebFont', function () {
|
2
|
+
var WebFont = webfont.WebFont,
|
3
|
+
UserAgent = webfont.UserAgent,
|
4
|
+
BrowserInfo = webfont.BrowserInfo,
|
5
|
+
Font = webfont.Font,
|
6
|
+
FontModuleLoader = webfont.FontModuleLoader,
|
7
|
+
fontModuleLoader = null,
|
8
|
+
userAgent = null;
|
9
|
+
|
10
|
+
beforeEach(function () {
|
11
|
+
userAgent = new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false));
|
12
|
+
fontModuleLoader = new FontModuleLoader();
|
13
|
+
});
|
14
|
+
|
15
|
+
describe('font load', function () {
|
16
|
+
var font = null,
|
17
|
+
testModule = null;
|
18
|
+
|
19
|
+
beforeEach(function () {
|
20
|
+
font = new WebFont(window, fontModuleLoader, userAgent);
|
21
|
+
font.addModule('test', function (conf, domHelper) {
|
22
|
+
testModule = new function () {
|
23
|
+
this.conf = conf;
|
24
|
+
this.domHelper = domHelper;
|
25
|
+
this.loadCalled = true;
|
26
|
+
this.supportUserAgentCalled = false;
|
27
|
+
};
|
28
|
+
|
29
|
+
testModule.load = function (onReady) {
|
30
|
+
this.loadCalled = true;
|
31
|
+
onReady([]);
|
32
|
+
};
|
33
|
+
|
34
|
+
testModule.supportUserAgent = function (ua, support) {
|
35
|
+
this.supportUserAgentCalled = true;
|
36
|
+
support(true);
|
37
|
+
};
|
38
|
+
|
39
|
+
return testModule;
|
40
|
+
});
|
41
|
+
});
|
42
|
+
|
43
|
+
it('should not start loading', function () {
|
44
|
+
expect(font.moduleFailedLoading_).toEqual(0);
|
45
|
+
expect(font.moduleLoading_).toEqual(0);
|
46
|
+
});
|
47
|
+
|
48
|
+
it('should fail to load a module', function () {
|
49
|
+
var loading = jasmine.createSpy('loading');
|
50
|
+
|
51
|
+
font.load({
|
52
|
+
test: {
|
53
|
+
somedata: 'in french a cow says meuh'
|
54
|
+
},
|
55
|
+
loading: loading
|
56
|
+
});
|
57
|
+
|
58
|
+
expect(font.moduleFailedLoading_).toEqual(1);
|
59
|
+
expect(font.moduleLoading_).toEqual(0);
|
60
|
+
expect(testModule).not.toBeNull();
|
61
|
+
|
62
|
+
expect(testModule.conf).not.toBeUndefined();
|
63
|
+
expect(testModule.conf).not.toBeNull();
|
64
|
+
|
65
|
+
expect(testModule.domHelper).not.toBeNull();
|
66
|
+
expect(testModule.domHelper).not.toBeUndefined();
|
67
|
+
|
68
|
+
expect(testModule.domHelper.getMainWindow()).toEqual(window);
|
69
|
+
expect(testModule.domHelper.getLoadWindow()).toEqual(window);
|
70
|
+
|
71
|
+
expect(testModule.conf.somedata).toEqual('in french a cow says meuh');
|
72
|
+
expect(testModule.loadCalled).toBe(true);
|
73
|
+
expect(testModule.supportUserAgentCalled).toBe(true);
|
74
|
+
expect(loading).toHaveBeenCalled();
|
75
|
+
});
|
76
|
+
});
|
77
|
+
|
78
|
+
describe('font load with context', function () {
|
79
|
+
var font = null,
|
80
|
+
testModule = null,
|
81
|
+
fakeMainWindow = {};
|
82
|
+
|
83
|
+
beforeEach(function () {
|
84
|
+
font = new WebFont(fakeMainWindow, fontModuleLoader, userAgent);
|
85
|
+
font.addModule('test', function (conf, domHelper) {
|
86
|
+
testModule = new function () {
|
87
|
+
this.domHelper = domHelper;
|
88
|
+
};
|
89
|
+
testModule.load = function () {};
|
90
|
+
testModule.supportUserAgent = function (ua, support) {
|
91
|
+
support(true);
|
92
|
+
};
|
93
|
+
|
94
|
+
return testModule;
|
95
|
+
});
|
96
|
+
});
|
97
|
+
|
98
|
+
it('should load with the correct context', function () {
|
99
|
+
font.load({
|
100
|
+
test: {
|
101
|
+
somedata: 'in french a cow says meuh'
|
102
|
+
},
|
103
|
+
context: window
|
104
|
+
});
|
105
|
+
|
106
|
+
expect(testModule.domHelper).not.toBeNull();
|
107
|
+
expect(testModule.domHelper).not.toBeUndefined();
|
108
|
+
|
109
|
+
expect(testModule.domHelper.getMainWindow()).toEqual(fakeMainWindow);
|
110
|
+
expect(testModule.domHelper.getLoadWindow()).toEqual(window);
|
111
|
+
});
|
112
|
+
});
|
113
|
+
|
114
|
+
describe('module failed to provide families and descriptions because it did not initialize properly', function () {
|
115
|
+
var webfont = null,
|
116
|
+
testModule = null,
|
117
|
+
font = null,
|
118
|
+
inactive = jasmine.createSpy('inactive'),
|
119
|
+
active = jasmine.createSpy('active');
|
120
|
+
|
121
|
+
beforeEach(function () {
|
122
|
+
font = new Font('Font1');
|
123
|
+
jasmine.Clock.useMock();
|
124
|
+
webfont = new WebFont(window, fontModuleLoader, new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false)));
|
125
|
+
webfont.addModule('test', function (conf, domHelper) {
|
126
|
+
testModule = new function () {
|
127
|
+
this.conf = conf;
|
128
|
+
this.fonts = [];
|
129
|
+
};
|
130
|
+
|
131
|
+
testModule.getFontWatchRunnerCtor = function () {
|
132
|
+
function FakeFontWatchRunner(activeCallback, inactiveCallback) {
|
133
|
+
this.inactive = inactiveCallback;
|
134
|
+
this.active = activeCallback;
|
135
|
+
};
|
136
|
+
|
137
|
+
FakeFontWatchRunner.prototype.start = function () {
|
138
|
+
if (conf.id) {
|
139
|
+
this.active(font);
|
140
|
+
} else {
|
141
|
+
this.inactive(font);
|
142
|
+
}
|
143
|
+
};
|
144
|
+
|
145
|
+
return FakeFontWatchRunner;
|
146
|
+
};
|
147
|
+
|
148
|
+
testModule.supportUserAgent = function (userAgent, support) {
|
149
|
+
if (conf.id) {
|
150
|
+
// The monotype module only initializes font
|
151
|
+
// and description if there is a kit id.
|
152
|
+
this.fonts = [font];
|
153
|
+
}
|
154
|
+
support(true);
|
155
|
+
};
|
156
|
+
testModule.load = function (onReady) {
|
157
|
+
onReady(this.fonts);
|
158
|
+
};
|
159
|
+
|
160
|
+
return testModule;
|
161
|
+
});
|
162
|
+
});
|
163
|
+
|
164
|
+
it('should load with a project id', function () {
|
165
|
+
webfont.load({
|
166
|
+
test: {
|
167
|
+
id: 'hello world'
|
168
|
+
},
|
169
|
+
inactive: inactive,
|
170
|
+
active: active
|
171
|
+
});
|
172
|
+
|
173
|
+
jasmine.Clock.tick(1);
|
174
|
+
|
175
|
+
expect(testModule).not.toBeNull();
|
176
|
+
expect(active).toHaveBeenCalled();
|
177
|
+
});
|
178
|
+
|
179
|
+
it('should not load without a project id', function () {
|
180
|
+
webfont.load({
|
181
|
+
test: {
|
182
|
+
},
|
183
|
+
inactive: inactive,
|
184
|
+
active: active
|
185
|
+
});
|
186
|
+
|
187
|
+
jasmine.Clock.tick(1);
|
188
|
+
|
189
|
+
expect(testModule).not.toBeNull();
|
190
|
+
expect(inactive).toHaveBeenCalled();
|
191
|
+
});
|
192
|
+
});
|
193
|
+
|
194
|
+
describe('font inactive', function () {
|
195
|
+
var font = null,
|
196
|
+
testModule = null;
|
197
|
+
|
198
|
+
beforeEach(function () {
|
199
|
+
font = new WebFont(window, fontModuleLoader, new UserAgent('Firefox', '3.6', 'Gecko', '1.9.2', 'Macintosh', '10.6', undefined, new BrowserInfo(false, false, false)));
|
200
|
+
font.addModule('test', function (conf, domHelper) {
|
201
|
+
testModule = new function () {
|
202
|
+
this.conf = conf;
|
203
|
+
this.loadCalled = false;
|
204
|
+
};
|
205
|
+
testModule.load = function () {};
|
206
|
+
return testModule;
|
207
|
+
});
|
208
|
+
});
|
209
|
+
|
210
|
+
it('should load with the correct context', function () {
|
211
|
+
var inactive = jasmine.createSpy('inactive');
|
212
|
+
|
213
|
+
font.load({
|
214
|
+
test: {
|
215
|
+
somedata: 'in french a cow says meuh'
|
216
|
+
},
|
217
|
+
inactive: inactive
|
218
|
+
});
|
219
|
+
|
220
|
+
expect(testModule).toBeNull()
|
221
|
+
expect(inactive).toHaveBeenCalled();
|
222
|
+
});
|
223
|
+
});
|
224
|
+
});
|
@@ -1,5 +1,6 @@
|
|
1
1
|
describe('CustomCss', function () {
|
2
|
-
var CustomCss = webfont.CustomCss
|
2
|
+
var CustomCss = webfont.CustomCss,
|
3
|
+
FontFamily = webfont.FontFamily;
|
3
4
|
|
4
5
|
describe('insert links correctly', function () {
|
5
6
|
var fakeDomHelper = null,
|
@@ -30,7 +31,9 @@ describe('CustomCss', function () {
|
|
30
31
|
it('should have loaded the families correctly', function () {
|
31
32
|
expect(load.callCount).toEqual(1);
|
32
33
|
expect(load.calls[0].args[0].length).toEqual(3);
|
33
|
-
expect(load.calls[0].args[0]).toEqual(
|
34
|
+
expect(load.calls[0].args[0][0].getName()).toEqual('Font1');
|
35
|
+
expect(load.calls[0].args[0][1].getName()).toEqual('Font2');
|
36
|
+
expect(load.calls[0].args[0][2].getName()).toEqual('Font3');
|
34
37
|
});
|
35
38
|
});
|
36
39
|
});
|
data/spec/deps.js
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
// This file was autogenerated by calcdeps.js
|
2
|
-
goog.addDependency("../../src/ascender/ascender_script.js", ["webfont.AscenderScript"], []);
|
2
|
+
goog.addDependency("../../src/ascender/ascender_script.js", ["webfont.AscenderScript"], ["webfont.Font"]);
|
3
3
|
goog.addDependency("../../src/async_load.js", [], []);
|
4
4
|
goog.addDependency("../../src/closure.js", [], []);
|
5
5
|
goog.addDependency("../../src/core/browserinfo.js", ["webfont.BrowserInfo"], []);
|
6
6
|
goog.addDependency("../../src/core/cssclassname.js", ["webfont.CssClassName"], []);
|
7
|
-
goog.addDependency("../../src/core/cssfontfamilyname.js", ["webfont.CssFontFamilyName"], []);
|
8
7
|
goog.addDependency("../../src/core/domhelper.js", ["webfont.DomHelper"], []);
|
9
8
|
goog.addDependency("../../src/core/eventdispatcher.js", ["webfont.EventDispatcher"], ["webfont.CssClassName"]);
|
10
|
-
goog.addDependency("../../src/core/font.js", ["webfont.
|
11
|
-
goog.addDependency("../../src/core/fontmoduleloader.js", ["webfont.FontModuleLoader"], []);
|
12
|
-
goog.addDependency("../../src/core/fontruler.js", ["webfont.FontRuler"], [
|
13
|
-
goog.addDependency("../../src/core/fontvariationdescription.js", ["webfont.FontVariationDescription"], []);
|
9
|
+
goog.addDependency("../../src/core/font.js", ["webfont.Font"], []);
|
10
|
+
goog.addDependency("../../src/core/fontmoduleloader.js", ["webfont.FontModuleLoader","webfont.FontModule","webfont.FontModuleFactory"], []);
|
11
|
+
goog.addDependency("../../src/core/fontruler.js", ["webfont.FontRuler"], []);
|
14
12
|
goog.addDependency("../../src/core/fontwatcher.js", ["webfont.FontWatcher"], ["webfont.FontWatchRunner"]);
|
15
|
-
goog.addDependency("../../src/core/fontwatchrunner.js", ["webfont.FontWatchRunner"], ["webfont.FontRuler"]);
|
13
|
+
goog.addDependency("../../src/core/fontwatchrunner.js", ["webfont.FontWatchRunner"], ["webfont.Font","webfont.FontRuler"]);
|
16
14
|
goog.addDependency("../../src/core/initialize.js", ["webfont"], ["webfont.UserAgentParser","webfont.FontModuleLoader","webfont.WebFont"]);
|
15
|
+
goog.addDependency("../../src/core/namespace.js", [], []);
|
17
16
|
goog.addDependency("../../src/core/useragent.js", ["webfont.UserAgent"], []);
|
18
17
|
goog.addDependency("../../src/core/useragentparser.js", ["webfont.UserAgentParser"], ["webfont.BrowserInfo","webfont.UserAgent"]);
|
19
|
-
goog.addDependency("../../src/
|
20
|
-
goog.addDependency("../../src/
|
21
|
-
goog.addDependency("../../src/
|
18
|
+
goog.addDependency("../../src/core/webfont.js", ["webfont.WebFont"], ["webfont.DomHelper","webfont.EventDispatcher","webfont.FontWatcher"]);
|
19
|
+
goog.addDependency("../../src/custom/customcss.js", ["webfont.CustomCss"], ["webfont.Font"]);
|
20
|
+
goog.addDependency("../../src/fontdeck/fontdeck_script.js", ["webfont.FontdeckScript"], ["webfont.Font"]);
|
21
|
+
goog.addDependency("../../src/google/fontapiparser.js", ["webfont.FontApiParser"], ["webfont.Font"]);
|
22
22
|
goog.addDependency("../../src/google/fontapiurlbuilder.js", ["webfont.FontApiUrlBuilder"], []);
|
23
23
|
goog.addDependency("../../src/google/googlefontapi.js", ["webfont.GoogleFontApi"], ["webfont.FontApiUrlBuilder","webfont.FontApiParser","webfont.FontWatchRunner","webfont.LastResortWebKitFontWatchRunner"]);
|
24
|
-
goog.addDependency("../../src/google/lastresortwebkitfontwatchrunner.js", ["webfont.LastResortWebKitFontWatchRunner"], ["webfont.FontRuler"]);
|
25
|
-
goog.addDependency("../../src/monotype/monotype_script.js", ["webfont.MonotypeScript"], []);
|
26
|
-
goog.addDependency("../../src/typekit/typekit_script.js", ["webfont.TypekitScript"], []);
|
24
|
+
goog.addDependency("../../src/google/lastresortwebkitfontwatchrunner.js", ["webfont.LastResortWebKitFontWatchRunner"], ["webfont.Font","webfont.FontRuler"]);
|
25
|
+
goog.addDependency("../../src/monotype/monotype_script.js", ["webfont.MonotypeScript"], ["webfont.Font"]);
|
26
|
+
goog.addDependency("../../src/typekit/typekit_script.js", ["webfont.TypekitScript"], ["webfont.Font"]);
|
@@ -1,5 +1,6 @@
|
|
1
1
|
describe('FontdeckScript', function () {
|
2
|
-
var FontdeckScript = webfont.FontdeckScript
|
2
|
+
var FontdeckScript = webfont.FontdeckScript,
|
3
|
+
Font = webfont.Font;
|
3
4
|
|
4
5
|
var configuration = {
|
5
6
|
id: '2282'
|
@@ -83,9 +84,7 @@ describe('FontdeckScript', function () {
|
|
83
84
|
it('should load correctly after calling the callback', function () {
|
84
85
|
global.__webfontfontdeckmodule__['2282'](true, apiResponse);
|
85
86
|
|
86
|
-
expect(fontdeck.
|
87
|
-
expect(fontdeck.fontVariations_[apiResponse.fonts[0].name]).toEqual(['n4']);
|
88
|
-
expect(fontdeck.fontVariations_[apiResponse.fonts[1].name]).toEqual(['i7']);
|
87
|
+
expect(fontdeck.fonts_).toEqual([new Font(apiResponse.fonts[0].name), new Font(apiResponse.fonts[1].name, 'i7')]);
|
89
88
|
|
90
89
|
expect(support).toHaveBeenCalled();
|
91
90
|
});
|
@@ -103,8 +102,7 @@ describe('FontdeckScript', function () {
|
|
103
102
|
});
|
104
103
|
|
105
104
|
it('should not have loaded any fonts', function () {
|
106
|
-
expect(fontdeck.
|
107
|
-
expect(fontdeck.fontVariations_).toEqual([]);
|
105
|
+
expect(fontdeck.fonts_).toEqual([]);
|
108
106
|
expect(support).toHaveBeenCalled();
|
109
107
|
});
|
110
108
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
@font-face{font-family:SourceSansC;src:url(sourcesans.eot?#iefix) format('embedded-opentype'),url(sourcesans.woff) format('woff'),url(sourcesans.otf) format('opentype'),url(sourcesans.ttf) format('truetype'),url(sourcesans.svg#source_sans_proregular) format('svg');font-weight:normal;font-style:normal;}
|
@@ -0,0 +1 @@
|
|
1
|
+
@font-face{font-family:SourceSansC;src:url(sourcesanscbold.otf) format('opentype');font-weight:bold;font-style:normal;}
|
Binary file
|
@@ -1,5 +1,6 @@
|
|
1
1
|
describe('FontApiParser', function () {
|
2
|
-
var FontApiParser = webfont.FontApiParser
|
2
|
+
var FontApiParser = webfont.FontApiParser,
|
3
|
+
Font = webfont.Font;
|
3
4
|
|
4
5
|
describe('parsed values are coherent', function () {
|
5
6
|
var parser = null;
|
@@ -9,57 +10,23 @@ describe('FontApiParser', function () {
|
|
9
10
|
parser.parse();
|
10
11
|
});
|
11
12
|
|
12
|
-
it('should parse
|
13
|
-
var
|
14
|
-
|
15
|
-
expect(
|
16
|
-
expect(
|
17
|
-
'Tangerine',
|
18
|
-
'Droid Serif',
|
19
|
-
'Yanone Kaffeesatz',
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
13
|
+
it('should parse fonts correctly', function () {
|
14
|
+
var fonts = parser.getFonts();
|
15
|
+
|
16
|
+
expect(fonts.length).toEqual(10);
|
17
|
+
expect(fonts).toEqual([
|
18
|
+
new Font('Tangerine', 'n4'),
|
19
|
+
new Font('Droid Serif', 'i7'),
|
20
|
+
new Font('Yanone Kaffeesatz', 'n2'),
|
21
|
+
new Font('Yanone Kaffeesatz', 'n3'),
|
22
|
+
new Font('Yanone Kaffeesatz', 'n4'),
|
23
|
+
new Font('Yanone Kaffeesatz', 'n7'),
|
24
|
+
new Font('Cantarell', 'i4'),
|
25
|
+
new Font('Cantarell', 'n7'),
|
26
|
+
new Font('Exo', 'i1'),
|
27
|
+
new Font('Lobster', 'n2')
|
23
28
|
]);
|
24
29
|
});
|
25
|
-
|
26
|
-
it('should parse variations correctly', function () {
|
27
|
-
var variations = parser.getVariations();
|
28
|
-
|
29
|
-
var tangerine = variations['Tangerine'];
|
30
|
-
expect(tangerine).not.toBeNull();
|
31
|
-
expect(tangerine.length).toEqual(1);
|
32
|
-
expect(tangerine[0]).toEqual('n4');
|
33
|
-
|
34
|
-
var droidSerif = variations['Droid Serif'];
|
35
|
-
expect(droidSerif).not.toBeNull();
|
36
|
-
expect(droidSerif.length).toEqual(1);
|
37
|
-
expect(droidSerif[0]).toEqual('i7');
|
38
|
-
|
39
|
-
var yanoneKaffeesatz = variations['Yanone Kaffeesatz'];
|
40
|
-
expect(yanoneKaffeesatz).not.toBeNull();
|
41
|
-
expect(yanoneKaffeesatz.length).toEqual(4);
|
42
|
-
expect(yanoneKaffeesatz[0]).toEqual('n2');
|
43
|
-
expect(yanoneKaffeesatz[1]).toEqual('n3');
|
44
|
-
expect(yanoneKaffeesatz[2]).toEqual('n4');
|
45
|
-
expect(yanoneKaffeesatz[3]).toEqual('n7');
|
46
|
-
|
47
|
-
var cantarell = variations['Cantarell'];
|
48
|
-
expect(cantarell).not.toBeNull();
|
49
|
-
expect(cantarell.length).toEqual(2);
|
50
|
-
expect(cantarell[0]).toEqual('i4');
|
51
|
-
expect(cantarell[1]).toEqual('n7');
|
52
|
-
|
53
|
-
var exo = variations['Exo'];
|
54
|
-
expect(exo).not.toBeNull();
|
55
|
-
expect(exo.length).toEqual(1);
|
56
|
-
expect(exo[0]).toEqual('i1');
|
57
|
-
|
58
|
-
var lobster = variations['Lobster'];
|
59
|
-
expect(lobster).not.toBeNull();
|
60
|
-
expect(lobster.length).toEqual(1);
|
61
|
-
expect(lobster[0]).toEqual('n2');
|
62
|
-
});
|
63
30
|
});
|
64
31
|
|
65
32
|
describe('mix of numeric weight and style', function () {
|
@@ -70,23 +37,16 @@ describe('FontApiParser', function () {
|
|
70
37
|
parser.parse();
|
71
38
|
});
|
72
39
|
|
73
|
-
it('should parse
|
74
|
-
var
|
75
|
-
|
76
|
-
expect(families.length).toEqual(1);
|
77
|
-
expect(families[0]).toEqual('Nobile');
|
78
|
-
});
|
79
|
-
|
80
|
-
it('should parse variations correctly', function () {
|
81
|
-
var variations = parser.getVariations(),
|
82
|
-
nobile = variations['Nobile'];
|
40
|
+
it('should parse fonts correctly', function () {
|
41
|
+
var fonts = parser.getFonts();
|
83
42
|
|
84
|
-
expect(
|
85
|
-
expect(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
43
|
+
expect(fonts.length).toEqual(4);
|
44
|
+
expect(fonts).toEqual([
|
45
|
+
new Font('Nobile', 'i7'),
|
46
|
+
new Font('Nobile', 'n7'),
|
47
|
+
new Font('Nobile', 'i2'),
|
48
|
+
new Font('Nobile', 'n4')
|
49
|
+
]);
|
90
50
|
});
|
91
51
|
});
|
92
52
|
|
@@ -99,19 +59,10 @@ describe('FontApiParser', function () {
|
|
99
59
|
});
|
100
60
|
|
101
61
|
it('should parse families correctly', function () {
|
102
|
-
var
|
103
|
-
|
104
|
-
expect(families.length).toEqual(1);
|
105
|
-
expect(families[0]).toEqual('Nobile');
|
106
|
-
});
|
62
|
+
var fonts = parser.getFonts();
|
107
63
|
|
108
|
-
|
109
|
-
|
110
|
-
nobile = variations['Nobile'];
|
111
|
-
|
112
|
-
expect(nobile).not.toBeNull();
|
113
|
-
expect(nobile.length).toEqual(1);
|
114
|
-
expect(nobile[0]).toEqual('n4');
|
64
|
+
expect(fonts.length).toEqual(1);
|
65
|
+
expect(fonts[0]).toEqual(new Font('Nobile', 'n4'));
|
115
66
|
});
|
116
67
|
});
|
117
68
|
|
@@ -124,19 +75,10 @@ describe('FontApiParser', function () {
|
|
124
75
|
});
|
125
76
|
|
126
77
|
it('should parse families correctly', function () {
|
127
|
-
var
|
78
|
+
var fonts = parser.getFonts();
|
128
79
|
|
129
|
-
expect(
|
130
|
-
expect(
|
131
|
-
});
|
132
|
-
|
133
|
-
it('should parse variations correctly', function () {
|
134
|
-
var variations = parser.getVariations(),
|
135
|
-
nobile = variations['Nobile'];
|
136
|
-
|
137
|
-
expect(nobile).not.toBeNull();
|
138
|
-
expect(nobile.length).toEqual(1);
|
139
|
-
expect(nobile[0]).toEqual('n4');
|
80
|
+
expect(fonts.length).toEqual(1);
|
81
|
+
expect(fonts[0]).toEqual(new Font('Nobile', 'n4'));
|
140
82
|
});
|
141
83
|
});
|
142
84
|
|
@@ -149,19 +91,10 @@ describe('FontApiParser', function () {
|
|
149
91
|
});
|
150
92
|
|
151
93
|
it('should parse families correctly', function () {
|
152
|
-
var
|
153
|
-
|
154
|
-
expect(families.length).toEqual(1);
|
155
|
-
expect(families[0]).toEqual('Cantarell');
|
156
|
-
});
|
94
|
+
var fonts = parser.getFonts();
|
157
95
|
|
158
|
-
|
159
|
-
|
160
|
-
cantarell = variations['Cantarell'];
|
161
|
-
|
162
|
-
expect(cantarell).not.toBeNull();
|
163
|
-
expect(cantarell.length).toEqual(1);
|
164
|
-
expect(cantarell[0]).toEqual('n4');
|
96
|
+
expect(fonts.length).toEqual(1);
|
97
|
+
expect(fonts[0]).toEqual(new Font('Cantarell', 'n4'));
|
165
98
|
});
|
166
99
|
|
167
100
|
it('should parse pick test strings correctly', function () {
|
@@ -182,19 +115,10 @@ describe('FontApiParser', function () {
|
|
182
115
|
});
|
183
116
|
|
184
117
|
it('should parse families correctly', function () {
|
185
|
-
var
|
118
|
+
var fonts = parser.getFonts();
|
186
119
|
|
187
|
-
expect(
|
188
|
-
expect(
|
189
|
-
});
|
190
|
-
|
191
|
-
it('should parse variations correctly', function () {
|
192
|
-
var variations = parser.getVariations(),
|
193
|
-
cantarell = variations['Cantarell'];
|
194
|
-
|
195
|
-
expect(cantarell).not.toBeNull();
|
196
|
-
expect(cantarell.length).toEqual(1);
|
197
|
-
expect(cantarell[0]).toEqual('n4');
|
120
|
+
expect(fonts.length).toEqual(1);
|
121
|
+
expect(fonts[0]).toEqual(new Font('Cantarell', 'n4'));
|
198
122
|
});
|
199
123
|
|
200
124
|
it('should parse pick test strings correctly', function () {
|
@@ -215,20 +139,13 @@ describe('FontApiParser', function () {
|
|
215
139
|
});
|
216
140
|
|
217
141
|
it('should parse families correctly', function () {
|
218
|
-
var
|
219
|
-
|
220
|
-
expect(families.length).toEqual(1);
|
221
|
-
expect(families[0]).toEqual('Cantarell');
|
222
|
-
});
|
142
|
+
var fonts = parser.getFonts();
|
223
143
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
expect(cantarell.length).toEqual(2);
|
230
|
-
expect(cantarell[0]).toEqual('n4');
|
231
|
-
expect(cantarell[1]).toEqual('n7');
|
144
|
+
expect(fonts.length).toEqual(2);
|
145
|
+
expect(fonts).toEqual([
|
146
|
+
new Font('Cantarell', 'n4'),
|
147
|
+
new Font('Cantarell', 'n7')
|
148
|
+
]);
|
232
149
|
});
|
233
150
|
|
234
151
|
it('should parse pick test strings correctly', function () {
|
@@ -249,19 +166,10 @@ describe('FontApiParser', function () {
|
|
249
166
|
});
|
250
167
|
|
251
168
|
it('should parse families correctly', function () {
|
252
|
-
var
|
169
|
+
var fonts = parser.getFonts();
|
253
170
|
|
254
|
-
expect(
|
255
|
-
expect(
|
256
|
-
});
|
257
|
-
|
258
|
-
it('should parse variations correctly', function () {
|
259
|
-
var variations = parser.getVariations(),
|
260
|
-
hanuman = variations['Hanuman'];
|
261
|
-
|
262
|
-
expect(hanuman).not.toBeNull();
|
263
|
-
expect(hanuman.length).toEqual(1);
|
264
|
-
expect(hanuman[0]).toEqual('n4');
|
171
|
+
expect(fonts.length).toEqual(1);
|
172
|
+
expect(fonts[0]).toEqual(new Font('Hanuman', 'n4'));
|
265
173
|
});
|
266
174
|
|
267
175
|
it('should parse pick test strings correctly', function () {
|
@@ -282,19 +190,10 @@ describe('FontApiParser', function () {
|
|
282
190
|
});
|
283
191
|
|
284
192
|
it('should parse families correctly', function () {
|
285
|
-
var
|
286
|
-
|
287
|
-
expect(families.length).toEqual(1);
|
288
|
-
expect(families[0]).toEqual('Hanuman');
|
289
|
-
});
|
193
|
+
var fonts = parser.getFonts();
|
290
194
|
|
291
|
-
|
292
|
-
|
293
|
-
hanuman = variations['Hanuman'];
|
294
|
-
|
295
|
-
expect(hanuman).not.toBeNull();
|
296
|
-
expect(hanuman.length).toEqual(1);
|
297
|
-
expect(hanuman[0]).toEqual('n4');
|
195
|
+
expect(fonts.length).toEqual(1);
|
196
|
+
expect(fonts[0]).toEqual(new Font('Hanuman', 'n4'));
|
298
197
|
});
|
299
198
|
|
300
199
|
it('should parse pick test strings correctly', function () {
|
@@ -315,34 +214,15 @@ describe('FontApiParser', function () {
|
|
315
214
|
});
|
316
215
|
|
317
216
|
it('should parse families correctly', function () {
|
318
|
-
var
|
319
|
-
|
320
|
-
expect(
|
321
|
-
expect(
|
322
|
-
'Erica One',
|
323
|
-
'Droid Serif',
|
324
|
-
'Yanone Kaffeesatz'
|
217
|
+
var fonts = parser.getFonts();
|
218
|
+
|
219
|
+
expect(fonts.length).toEqual(4);
|
220
|
+
expect(fonts).toEqual([
|
221
|
+
new Font('Erica One', 'n4'),
|
222
|
+
new Font('Droid Serif', 'n4'),
|
223
|
+
new Font('Yanone Kaffeesatz', 'n4'),
|
224
|
+
new Font('Yanone Kaffeesatz', 'n7')
|
325
225
|
]);
|
326
226
|
});
|
327
|
-
|
328
|
-
it('should parse variations correctly', function () {
|
329
|
-
var variations = parser.getVariations();
|
330
|
-
|
331
|
-
var ericaOne = variations['Erica One'];
|
332
|
-
expect(ericaOne).not.toBeNull();
|
333
|
-
expect(ericaOne.length).toEqual(1);
|
334
|
-
expect(ericaOne[0]).toEqual('n4');
|
335
|
-
|
336
|
-
var droidSerif = variations['Droid Serif'];
|
337
|
-
expect(droidSerif).not.toBeNull();
|
338
|
-
expect(droidSerif.length).toEqual(1);
|
339
|
-
expect(droidSerif[0]).toEqual('n4');
|
340
|
-
|
341
|
-
var yanoneKaffeesatz = variations['Yanone Kaffeesatz'];
|
342
|
-
expect(yanoneKaffeesatz).not.toBeNull();
|
343
|
-
expect(yanoneKaffeesatz.length).toEqual(2);
|
344
|
-
expect(yanoneKaffeesatz[0]).toEqual('n4');
|
345
|
-
expect(yanoneKaffeesatz[1]).toEqual('n7');
|
346
|
-
});
|
347
227
|
});
|
348
228
|
});
|