webfontloader 1.0.9 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -1
- data/Rakefile +5 -1
- data/lib/webfontloader.rb +2 -2
- data/src-test/core/fontwatchertest.js +58 -11
- data/src-test/core/useragenttest.js +33 -1
- data/src/core/font.js +7 -5
- data/src/core/fontwatcher.js +15 -9
- data/src/core/useragentparser.js +16 -5
- data/src/google/fontapiparser.js +14 -0
- data/src/google/fontapiurlbuilder.js +3 -0
- data/src/google/googlefontapi.js +2 -1
- data/webfontloader.gemspec +2 -2
- metadata +4 -15
data/CHANGELOG
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
master
|
2
2
|
|
3
|
+
v1.0.13 (September 30, 2010)
|
4
|
+
* Added support for detecting Adobe Air.
|
5
|
+
|
6
|
+
v1.0.12 (September 30, 2010)
|
7
|
+
* Bugfix: google module, change the url builder to handle integrations.
|
8
|
+
|
9
|
+
v1.0.10 (September 24, 2010)
|
10
|
+
* Bugfix: extra alert
|
11
|
+
|
12
|
+
v1.0.10 (September 22, 2010)
|
13
|
+
* Add support for customizable FontWatcher test string, for international
|
14
|
+
fonts.
|
15
|
+
|
3
16
|
v1.0.9 (September 10, 2010)
|
4
17
|
* Bugfix: of the bug fix
|
5
18
|
|
@@ -34,4 +47,4 @@ v1.0.1 (May 20, 2010)
|
|
34
47
|
v1.0.0 (May 19, 2010)
|
35
48
|
* Initial release!
|
36
49
|
* Modules: google, typekit, custom
|
37
|
-
* Events: loading, active, inactive, fontloading, fontactive, fontintactive
|
50
|
+
* Events: loading, active, inactive, fontloading, fontactive, fontintactive
|
data/Rakefile
CHANGED
@@ -121,7 +121,8 @@ file "target/webfont.js" => SourceJs + ["target"] do |t|
|
|
121
121
|
source = @modules.all_source_files
|
122
122
|
args.concat source.map { |f| ["--js", f] }
|
123
123
|
|
124
|
-
|
124
|
+
output = `java #{args.flatten.join(' ')} 2>&1`
|
125
|
+
fail output unless output.empty?
|
125
126
|
end
|
126
127
|
|
127
128
|
desc "Creates debug version into target/webfont.js"
|
@@ -140,6 +141,9 @@ end
|
|
140
141
|
# Run
|
141
142
|
#
|
142
143
|
|
144
|
+
desc "Test everything"
|
145
|
+
task :default => [:clean, :gzipbytes, :test]
|
146
|
+
|
143
147
|
namespace :test do
|
144
148
|
task :server do
|
145
149
|
system "java -jar #{JsTestJar} --port #{JsTestPort}"
|
data/lib/webfontloader.rb
CHANGED
@@ -7,12 +7,13 @@ FontWatcherTest.prototype.setUp = function() {
|
|
7
7
|
this.classNamesCount_ = 0;
|
8
8
|
this.fakeDomHelper_ = {
|
9
9
|
removeElement: function() {},
|
10
|
-
createElement: function(name, attrs) {
|
10
|
+
createElement: function(name, attrs, innerHtml) {
|
11
11
|
var element = document.createElement(name);
|
12
12
|
|
13
13
|
for (var attr in attrs) {
|
14
14
|
element.setAttribute(attr, attrs[attr]);
|
15
15
|
}
|
16
|
+
element.innerHTML = innerHtml;
|
16
17
|
return element;
|
17
18
|
},
|
18
19
|
insertInto: function() {},
|
@@ -81,7 +82,7 @@ FontWatcherTest.prototype.testWatchOneFontAlreadyLoaded = function() {
|
|
81
82
|
}, function() {}, function() { return 0; });
|
82
83
|
var fontFamilies = [ 'fontFamily1' ];
|
83
84
|
|
84
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
85
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
85
86
|
assertEquals(1, this.fontLoadingEventCalled_);
|
86
87
|
assertEquals(1, this.fontLoading_.length);
|
87
88
|
assertEquals('fontFamily1 n4', this.fontLoading_[0]);
|
@@ -106,7 +107,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsAlreadyLoaded = function() {
|
|
106
107
|
}, function() {}, function() { return 0; });
|
107
108
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
108
109
|
|
109
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
110
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
110
111
|
assertEquals(3, this.fontLoadingEventCalled_);
|
111
112
|
assertEquals(3, this.fontLoading_.length);
|
112
113
|
assertEquals('fontFamily1 n4', this.fontLoading_[0]);
|
@@ -146,7 +147,7 @@ FontWatcherTest.prototype.testWatchOneFontWaitForLoad = function() {
|
|
146
147
|
}, function() { return 0; });
|
147
148
|
var fontFamilies = [ 'fontFamily1' ];
|
148
149
|
|
149
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
150
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
150
151
|
assertTrue(async);
|
151
152
|
assertEquals(1, this.fontLoadingEventCalled_);
|
152
153
|
assertEquals(1, this.fontLoading_.length);
|
@@ -194,7 +195,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsWaitForLoad = function() {
|
|
194
195
|
}, function() { return 0; });
|
195
196
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
196
197
|
|
197
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
198
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
198
199
|
assertEquals(8, async);
|
199
200
|
assertEquals(3, this.fontLoadingEventCalled_);
|
200
201
|
assertEquals(3, this.fontLoading_.length);
|
@@ -242,7 +243,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsWaitForLoadAndLoaded =
|
|
242
243
|
}, function() { return 0; });
|
243
244
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
244
245
|
|
245
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
246
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
246
247
|
assertEquals(7, async);
|
247
248
|
assertEquals(3, this.fontLoadingEventCalled_);
|
248
249
|
assertEquals(3, this.fontLoading_.length);
|
@@ -274,7 +275,7 @@ FontWatcherTest.prototype.testWatchOneFontWaitForLoadInactive = function() {
|
|
274
275
|
});
|
275
276
|
var fontFamilies = [ 'fontFamily1' ];
|
276
277
|
|
277
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
278
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
278
279
|
assertEquals(1, this.fontLoadingEventCalled_);
|
279
280
|
assertEquals(1, this.fontLoading_.length);
|
280
281
|
assertEquals('fontFamily1 n4', this.fontLoading_[0]);
|
@@ -325,7 +326,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsWaitForLoadAndInactive =
|
|
325
326
|
});
|
326
327
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
327
328
|
|
328
|
-
fontWatcher.watch(fontFamilies, {}, false);
|
329
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
329
330
|
assertEquals(9, async);
|
330
331
|
assertEquals(3, this.fontLoadingEventCalled_);
|
331
332
|
assertEquals(3, this.fontLoading_.length);
|
@@ -357,7 +358,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsAlreadyLoadedAndLastBatchOnDone
|
|
357
358
|
}, function() {}, function() { return 0; });
|
358
359
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
359
360
|
|
360
|
-
fontWatcher.watch(fontFamilies, {}, true);
|
361
|
+
fontWatcher.watch(fontFamilies, {}, {}, true);
|
361
362
|
assertEquals(3, this.fontLoadingEventCalled_);
|
362
363
|
assertEquals(3, this.fontLoading_.length);
|
363
364
|
assertEquals('fontFamily1 n4', this.fontLoading_[0]);
|
@@ -415,7 +416,7 @@ FontWatcherTest.prototype.testWatchMultipleFontsWaitForLoadAndLastBatchOnDone =
|
|
415
416
|
}, function() { return 0; });
|
416
417
|
var fontFamilies = [ 'fontFamily1', 'fontFamily2', 'fontFamily3' ];
|
417
418
|
|
418
|
-
fontWatcher.watch(fontFamilies, {}, true);
|
419
|
+
fontWatcher.watch(fontFamilies, {}, {}, true);
|
419
420
|
assertEquals(8, async);
|
420
421
|
assertEquals(3, this.fontLoadingEventCalled_);
|
421
422
|
assertEquals(3, this.fontLoading_.length);
|
@@ -478,7 +479,7 @@ FontWatcherTest.prototype
|
|
478
479
|
fontWatcher.watch(fontFamilies, {
|
479
480
|
'fontFamily1': ['i7'],
|
480
481
|
'fontFamily2': null,
|
481
|
-
'fontFamily3': ['n4', 'i4', 'n7'] }, true);
|
482
|
+
'fontFamily3': ['n4', 'i4', 'n7'] }, {}, true);
|
482
483
|
|
483
484
|
assertEquals(8, async);
|
484
485
|
assertEquals(5, this.fontLoadingEventCalled_);
|
@@ -508,3 +509,49 @@ FontWatcherTest.prototype
|
|
508
509
|
assertEquals(true, this.classNames_['ns-fontfamily3-n7-active']);
|
509
510
|
assertEquals(true, this.classNames_['ns-active']);
|
510
511
|
};
|
512
|
+
|
513
|
+
FontWatcherTest.prototype.testTestStringIsNotDefault = function() {
|
514
|
+
var testString = '';
|
515
|
+
var fontWatcher = new webfont.FontWatcher(this.fakeDomHelper_,
|
516
|
+
this.eventDispatcher_, {
|
517
|
+
getWidth: function(element) {
|
518
|
+
var fontFamily = element.style.fontFamily;
|
519
|
+
var fonts = fontFamily.split(',');
|
520
|
+
var size = fonts.length;
|
521
|
+
|
522
|
+
testString = element.innerHTML;
|
523
|
+
if (size == 6) {
|
524
|
+
return 1;
|
525
|
+
} else {
|
526
|
+
return 2;
|
527
|
+
}
|
528
|
+
}
|
529
|
+
}, function() {}, function() { return 0; });
|
530
|
+
var fontFamilies = [ 'fontFamily1' ];
|
531
|
+
|
532
|
+
fontWatcher.watch(fontFamilies, {}, { 'fontFamily1': 'testString!' }, false);
|
533
|
+
assertEquals('testString!', testString);
|
534
|
+
};
|
535
|
+
|
536
|
+
FontWatcherTest.prototype.testTestStringIsDefault = function() {
|
537
|
+
var testString = '';
|
538
|
+
var fontWatcher = new webfont.FontWatcher(this.fakeDomHelper_,
|
539
|
+
this.eventDispatcher_, {
|
540
|
+
getWidth: function(element) {
|
541
|
+
var fontFamily = element.style.fontFamily;
|
542
|
+
var fonts = fontFamily.split(',');
|
543
|
+
var size = fonts.length;
|
544
|
+
|
545
|
+
testString = element.innerHTML;
|
546
|
+
if (size == 6) {
|
547
|
+
return 1;
|
548
|
+
} else {
|
549
|
+
return 2;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
}, function() {}, function() { return 0; });
|
553
|
+
var fontFamilies = [ 'fontFamily1' ];
|
554
|
+
|
555
|
+
fontWatcher.watch(fontFamilies, {}, {}, false);
|
556
|
+
assertEquals('Mm', testString);
|
557
|
+
};
|
@@ -4,6 +4,38 @@ UserAgentTest.prototype.setUp = function() {
|
|
4
4
|
this.ie8Document_ = { documentMode: 8 };
|
5
5
|
};
|
6
6
|
|
7
|
+
UserAgentTest.prototype.testBrowserIsAir = function() {
|
8
|
+
var userAgentParser = new webfont.UserAgentParser(
|
9
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/531.9 (KHTML, like Gecko) AdobeAIR/2.5",
|
10
|
+
this.defaultDocument_);
|
11
|
+
var userAgent = userAgentParser.parse();
|
12
|
+
|
13
|
+
assertEquals("AdobeAIR", userAgent.getName());
|
14
|
+
assertEquals("2.5", userAgent.getVersion());
|
15
|
+
assertEquals("Macintosh", userAgent.getPlatform());
|
16
|
+
assertEquals("Unknown", userAgent.getPlatformVersion());
|
17
|
+
assertEquals("AppleWebKit", userAgent.getEngine());
|
18
|
+
assertEquals("531.9", userAgent.getEngineVersion());
|
19
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
20
|
+
assertTrue(userAgent.isSupportingWebFont());
|
21
|
+
};
|
22
|
+
|
23
|
+
UserAgentTest.prototype.testBrowserIsUnsupportedAir = function() {
|
24
|
+
var userAgentParser = new webfont.UserAgentParser(
|
25
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/531.9 (KHTML, like Gecko) AdobeAIR/2.0",
|
26
|
+
this.defaultDocument_);
|
27
|
+
var userAgent = userAgentParser.parse();
|
28
|
+
|
29
|
+
assertEquals("AdobeAIR", userAgent.getName());
|
30
|
+
assertEquals("2.0", userAgent.getVersion());
|
31
|
+
assertEquals("Macintosh", userAgent.getPlatform());
|
32
|
+
assertEquals("Unknown", userAgent.getPlatformVersion());
|
33
|
+
assertEquals("AppleWebKit", userAgent.getEngine());
|
34
|
+
assertEquals("531.9", userAgent.getEngineVersion());
|
35
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
36
|
+
assertFalse(userAgent.isSupportingWebFont());
|
37
|
+
};
|
38
|
+
|
7
39
|
UserAgentTest.prototype.testBrowserIsFirefox = function() {
|
8
40
|
var userAgentParser = new webfont.UserAgentParser(
|
9
41
|
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.1",
|
@@ -31,7 +63,7 @@ UserAgentTest.prototype.testBrowserIsFirefox4beta = function() {
|
|
31
63
|
assertEquals("Macintosh", userAgent.getPlatform());
|
32
64
|
assertEquals("10.6", userAgent.getPlatformVersion());
|
33
65
|
assertEquals("Gecko", userAgent.getEngine());
|
34
|
-
assertEquals("2.0b1", userAgent.getEngineVersion
|
66
|
+
assertEquals("2.0b1", userAgent.getEngineVersion());
|
35
67
|
assertEquals(undefined, userAgent.getDocumentMode());
|
36
68
|
assertTrue(userAgent.isSupportingWebFont());
|
37
69
|
};
|
data/src/core/font.js
CHANGED
@@ -40,7 +40,7 @@ webfont.WebFont.prototype.isModuleSupportingUserAgent_ = function(module, eventD
|
|
40
40
|
eventDispatcher.dispatchLoading();
|
41
41
|
}
|
42
42
|
}
|
43
|
-
fontWatcher.watch([], {}, allModulesLoaded);
|
43
|
+
fontWatcher.watch([], {}, {}, allModulesLoaded);
|
44
44
|
return;
|
45
45
|
}
|
46
46
|
module.load(webfont.bind(this, this.onModuleReady_, eventDispatcher,
|
@@ -48,16 +48,18 @@ webfont.WebFont.prototype.isModuleSupportingUserAgent_ = function(module, eventD
|
|
48
48
|
};
|
49
49
|
|
50
50
|
webfont.WebFont.prototype.onModuleReady_ = function(eventDispatcher, fontWatcher,
|
51
|
-
fontFamilies, opt_fontDescriptions) {
|
51
|
+
fontFamilies, opt_fontDescriptions, opt_fontTestStrings) {
|
52
52
|
var allModulesLoaded = --this.moduleLoading_ == 0;
|
53
53
|
|
54
54
|
if (allModulesLoaded) {
|
55
55
|
eventDispatcher.dispatchLoading();
|
56
56
|
}
|
57
57
|
this.asyncCall_(webfont.bind(this, function(_fontWatcher, _fontFamilies,
|
58
|
-
|
59
|
-
_fontWatcher.watch(_fontFamilies, _fontDescriptions || {},
|
60
|
-
|
58
|
+
_fontDescriptions, _fontTestStrings, _allModulesLoaded) {
|
59
|
+
_fontWatcher.watch(_fontFamilies, _fontDescriptions || {},
|
60
|
+
_fontTestStrings || {}, _allModulesLoaded);
|
61
|
+
}, fontWatcher, fontFamilies, opt_fontDescriptions, opt_fontTestStrings,
|
62
|
+
allModulesLoaded));
|
61
63
|
};
|
62
64
|
|
63
65
|
webfont.WebFont.prototype.load_ = function(eventDispatcher, configuration) {
|
data/src/core/fontwatcher.js
CHANGED
@@ -34,7 +34,8 @@ webfont.FontWatcher.DEFAULT_VARIATION = 'n4';
|
|
34
34
|
* of each family to watch. Described with FVD.
|
35
35
|
* @param {boolean} last True if this is the last set of families to watch.
|
36
36
|
*/
|
37
|
-
webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
|
37
|
+
webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
|
38
|
+
fontTestStrings, last) {
|
38
39
|
var length = fontFamilies.length;
|
39
40
|
|
40
41
|
for (var i = 0; i < length; i++) {
|
@@ -52,12 +53,14 @@ webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions, l
|
|
52
53
|
for (var i = 0; i < length; i++) {
|
53
54
|
var fontFamily = fontFamilies[i];
|
54
55
|
var descriptions = fontDescriptions[fontFamily];
|
56
|
+
var fontTestString = fontTestStrings[fontFamily] || 'Mm';
|
55
57
|
|
56
58
|
for (var j = 0, len = descriptions.length; j < len; j++) {
|
57
59
|
var fontDescription = descriptions[j];
|
58
|
-
var originalSize = this.getDefaultFontSize_(fontDescription
|
60
|
+
var originalSize = this.getDefaultFontSize_(fontDescription,
|
61
|
+
fontTestString);
|
59
62
|
|
60
|
-
this.watch_(fontFamily, fontDescription, originalSize);
|
63
|
+
this.watch_(fontFamily, fontDescription, fontTestString, originalSize);
|
61
64
|
}
|
62
65
|
}
|
63
66
|
};
|
@@ -65,10 +68,11 @@ webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions, l
|
|
65
68
|
/**
|
66
69
|
* @private
|
67
70
|
*/
|
68
|
-
webfont.FontWatcher.prototype.watch_ = function(fontFamily, fontDescription,
|
71
|
+
webfont.FontWatcher.prototype.watch_ = function(fontFamily, fontDescription,
|
72
|
+
fontTestString, originalSize) {
|
69
73
|
this.eventDispatcher_.dispatchFontLoading(fontFamily, fontDescription);
|
70
74
|
var requestedFont = this.createHiddenElementWithFont_(this.nameHelper_.quote(fontFamily),
|
71
|
-
fontDescription);
|
75
|
+
fontDescription, fontTestString);
|
72
76
|
var size = this.fontSizer_.getWidth(requestedFont);
|
73
77
|
|
74
78
|
if (originalSize != size) {
|
@@ -131,9 +135,10 @@ webfont.FontWatcher.prototype.asyncCheck_ = function(started, originalSize,
|
|
131
135
|
/**
|
132
136
|
* @private
|
133
137
|
*/
|
134
|
-
webfont.FontWatcher.prototype.getDefaultFontSize_ = function(fontDescription
|
138
|
+
webfont.FontWatcher.prototype.getDefaultFontSize_ = function(fontDescription,
|
139
|
+
fontTestString) {
|
135
140
|
var defaultFont = this.createHiddenElementWithFont_(
|
136
|
-
webfont.FontWatcher.DEFAULT_FONT, fontDescription);
|
141
|
+
webfont.FontWatcher.DEFAULT_FONT, fontDescription, fontTestString);
|
137
142
|
var size = this.fontSizer_.getWidth(defaultFont);
|
138
143
|
|
139
144
|
this.domHelper_.removeElement(defaultFont);
|
@@ -144,11 +149,12 @@ webfont.FontWatcher.prototype.getDefaultFontSize_ = function(fontDescription) {
|
|
144
149
|
* @private
|
145
150
|
*/
|
146
151
|
webfont.FontWatcher.prototype.createHiddenElementWithFont_ = function(
|
147
|
-
fontFamily, fontDescription) {
|
152
|
+
fontFamily, fontDescription, fontTestString) {
|
148
153
|
var variationCss = this.fvd_.expand(fontDescription);
|
149
154
|
var styleString = "position:absolute;top:-999px;font-size:300px;font-family:" +
|
150
155
|
fontFamily + "," + webfont.FontWatcher.DEFAULT_FONT + ";" + variationCss;
|
151
|
-
var span = this.domHelper_.createElement('span', { 'style': styleString },
|
156
|
+
var span = this.domHelper_.createElement('span', { 'style': styleString },
|
157
|
+
fontTestString);
|
152
158
|
|
153
159
|
this.domHelper_.insertInto('body', span);
|
154
160
|
return span;
|
data/src/core/useragentparser.js
CHANGED
@@ -199,6 +199,8 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
|
|
199
199
|
name = "Chrome";
|
200
200
|
} else if (this.userAgent_.indexOf("Safari") != -1) {
|
201
201
|
name = "Safari";
|
202
|
+
} else if (this.userAgent_.indexOf("AdobeAIR") != -1) {
|
203
|
+
name = "AdobeAIR";
|
202
204
|
}
|
203
205
|
var version = webfont.UserAgentParser.UNKNOWN;
|
204
206
|
|
@@ -208,13 +210,23 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
|
|
208
210
|
} else if (name == "Chrome") {
|
209
211
|
version = this.getMatchingGroup_(this.userAgent_,
|
210
212
|
/Chrome\/([\d\.]+)/, 1);
|
213
|
+
} else if (name == "AdobeAIR") {
|
214
|
+
version = this.getMatchingGroup_(this.userAgent_,
|
215
|
+
/AdobeAIR\/([\d\.]+)/, 1);
|
216
|
+
}
|
217
|
+
var supportWebFont = false;
|
218
|
+
if (name == "AdobeAIR") {
|
219
|
+
var minor = this.getMatchingGroup_(version, /\d+\.(\d+)/, 1);
|
220
|
+
supportWebFont = this.getMajorVersion_(version) > 2 ||
|
221
|
+
this.getMajorVersion_(version) == 2 && parseInt(minor, 10) >= 5;
|
222
|
+
} else {
|
223
|
+
var minor = this.getMatchingGroup_(webKitVersion, /\d+\.(\d+)/, 1);
|
224
|
+
supportWebFont = this.getMajorVersion_(webKitVersion) >= 526 ||
|
225
|
+
this.getMajorVersion_(webKitVersion) >= 525 && parseInt(minor, 10) >= 13;
|
211
226
|
}
|
212
|
-
var minor = this.getMatchingGroup_(webKitVersion, /\d+\.(\d+)/, 1);
|
213
227
|
|
214
228
|
return new webfont.UserAgent(name, version, "AppleWebKit", webKitVersion,
|
215
|
-
platform, platformVersion, this.getDocumentMode_(this.doc_),
|
216
|
-
this.getMajorVersion_(webKitVersion) >= 526 ||
|
217
|
-
this.getMajorVersion_(webKitVersion) >= 525 && parseInt(minor, 10) >= 13);
|
229
|
+
platform, platformVersion, this.getDocumentMode_(this.doc_), supportWebFont);
|
218
230
|
};
|
219
231
|
|
220
232
|
/**
|
@@ -301,4 +313,3 @@ webfont.UserAgentParser.prototype.getDocumentMode_ = function(doc) {
|
|
301
313
|
if (doc.documentMode) return doc.documentMode;
|
302
314
|
return undefined;
|
303
315
|
};
|
304
|
-
|
data/src/google/fontapiparser.js
CHANGED
@@ -5,6 +5,7 @@ webfont.FontApiParser = function(fontFamilies) {
|
|
5
5
|
this.fontFamilies_ = fontFamilies;
|
6
6
|
this.parsedFontFamilies_ = [];
|
7
7
|
this.variations_ = {};
|
8
|
+
this.fontTestStrings_ = {};
|
8
9
|
this.fvd_ = new webfont.FontVariationDescription();
|
9
10
|
};
|
10
11
|
|
@@ -23,6 +24,10 @@ webfont.FontApiParser.VARIATIONS = {
|
|
23
24
|
'bi': 'i7'
|
24
25
|
};
|
25
26
|
|
27
|
+
webfont.FontApiParser.INT_FONTS = {
|
28
|
+
'Hanuman': 'កខគ'
|
29
|
+
};
|
30
|
+
|
26
31
|
webfont.FontApiParser.prototype.parse = function() {
|
27
32
|
var length = this.fontFamilies_.length;
|
28
33
|
|
@@ -41,6 +46,11 @@ webfont.FontApiParser.prototype.parse = function() {
|
|
41
46
|
variations = ['n4'];
|
42
47
|
}
|
43
48
|
this.parsedFontFamilies_.push(fontFamily);
|
49
|
+
var fontTestString = webfont.FontApiParser.INT_FONTS[fontFamily];
|
50
|
+
|
51
|
+
if (fontTestString) {
|
52
|
+
this.fontTestStrings_[fontFamily] = fontTestString;
|
53
|
+
}
|
44
54
|
this.variations_[fontFamily] = variations;
|
45
55
|
}
|
46
56
|
};
|
@@ -92,3 +102,7 @@ webfont.FontApiParser.prototype.getFontFamilies = function() {
|
|
92
102
|
webfont.FontApiParser.prototype.getVariations = function() {
|
93
103
|
return this.variations_;
|
94
104
|
};
|
105
|
+
|
106
|
+
webfont.FontApiParser.prototype.getFontTestStrings = function() {
|
107
|
+
return this.fontTestStrings_;
|
108
|
+
};
|
@@ -27,6 +27,9 @@ webfont.FontApiUrlBuilder.prototype.build = function() {
|
|
27
27
|
if (!this.fontFamilies_) {
|
28
28
|
throw new Error('No fonts to load !');
|
29
29
|
}
|
30
|
+
if (this.apiUrl_.indexOf("kit=") != -1) {
|
31
|
+
return this.apiUrl_;
|
32
|
+
}
|
30
33
|
var length = this.fontFamilies_.length;
|
31
34
|
var sb = [];
|
32
35
|
|
data/src/google/googlefontapi.js
CHANGED
@@ -38,7 +38,8 @@ webfont.GoogleFontApi.prototype.load = function(onReady) {
|
|
38
38
|
var fontApiParser = new webfont.FontApiParser(fontFamilies);
|
39
39
|
|
40
40
|
fontApiParser.parse();
|
41
|
-
onReady(fontApiParser.getFontFamilies(), fontApiParser.getVariations()
|
41
|
+
onReady(fontApiParser.getFontFamilies(), fontApiParser.getVariations(),
|
42
|
+
fontApiParser.getFontTestStrings());
|
42
43
|
};
|
43
44
|
|
44
45
|
window['WebFont'].addModule(webfont.GoogleFontApi.NAME, function(configuration) {
|
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.0.
|
17
|
-
s.date = '2010-09-
|
16
|
+
s.version = '1.0.13'
|
17
|
+
s.date = '2010-09-30'
|
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,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webfontloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 5
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
8
|
+
- 13
|
9
|
+
version: 1.0.13
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Ryan Carver
|
@@ -16,18 +15,16 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-30 00:00:00 -07:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: rack
|
24
23
|
prerelease: false
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
25
|
requirements:
|
28
26
|
- - ~>
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 29
|
31
28
|
segments:
|
32
29
|
- 1
|
33
30
|
- 2
|
@@ -39,11 +36,9 @@ dependencies:
|
|
39
36
|
name: sinatra
|
40
37
|
prerelease: false
|
41
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
39
|
requirements:
|
44
40
|
- - ~>
|
45
41
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 15
|
47
42
|
segments:
|
48
43
|
- 1
|
49
44
|
- 0
|
@@ -54,11 +49,9 @@ dependencies:
|
|
54
49
|
name: vegas
|
55
50
|
prerelease: false
|
56
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
53
|
- - ~>
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 23
|
62
55
|
segments:
|
63
56
|
- 0
|
64
57
|
- 1
|
@@ -164,27 +157,23 @@ rdoc_options:
|
|
164
157
|
require_paths:
|
165
158
|
- lib
|
166
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
-
none: false
|
168
160
|
requirements:
|
169
161
|
- - ">="
|
170
162
|
- !ruby/object:Gem::Version
|
171
|
-
hash: 3
|
172
163
|
segments:
|
173
164
|
- 0
|
174
165
|
version: "0"
|
175
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
167
|
requirements:
|
178
168
|
- - ">="
|
179
169
|
- !ruby/object:Gem::Version
|
180
|
-
hash: 3
|
181
170
|
segments:
|
182
171
|
- 0
|
183
172
|
version: "0"
|
184
173
|
requirements: []
|
185
174
|
|
186
175
|
rubyforge_project:
|
187
|
-
rubygems_version: 1.3.
|
176
|
+
rubygems_version: 1.3.6
|
188
177
|
signing_key:
|
189
178
|
specification_version: 2
|
190
179
|
summary: WebFont Loader gives you added control when using linked fonts via @font-face.
|