webfontloader 1.3.0 → 1.3.1
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 +5 -0
- data/Rakefile +2 -1
- data/lib/webfontloader.rb +1 -1
- data/spec/core/font_spec.js +9 -4
- data/spec/core/fontruler_spec.js +3 -10
- data/spec/core/fontwatcher_spec.js +22 -23
- data/spec/core/fontwatchrunner_spec.js +206 -231
- data/spec/deps.js +27 -0
- data/spec/google/lastresortwebkitfontwatchrunner_spec.js +47 -58
- data/spec/index.html +14 -25
- data/src/ascender/ascender_script.js +52 -45
- data/src/core/browserinfo.js +54 -47
- data/src/core/cssclassname.js +27 -22
- data/src/core/cssfontfamilyname.js +23 -17
- data/src/core/domhelper.js +209 -203
- data/src/core/eventdispatcher.js +111 -103
- data/src/core/font.js +110 -68
- data/src/core/fontmoduleloader.js +56 -13
- data/src/core/fontruler.js +52 -43
- data/src/core/fontvariationdescription.js +82 -76
- data/src/core/fontwatcher.js +93 -88
- data/src/core/fontwatchrunner.js +161 -161
- data/src/core/initialize.js +22 -15
- data/src/core/namespace.js +0 -29
- data/src/core/size.js +31 -25
- data/src/core/useragent.js +63 -48
- data/src/core/useragentparser.js +317 -306
- data/src/custom/customcss.js +31 -24
- data/src/fontdeck/fontdeck_script.js +46 -37
- data/src/google/fontapiparser.js +105 -97
- data/src/google/fontapiurlbuilder.js +46 -41
- data/src/google/googlefontapi.js +48 -32
- data/src/google/lastresortwebkitfontwatchrunner.js +80 -67
- data/src/modules.yml +6 -6
- data/src/monotype/monotype_script.js +47 -40
- data/src/typekit/typekit_script.js +41 -35
- data/tools/compiler/base.js +1548 -0
- data/tools/compiler/compiler.jar +0 -0
- data/webfontloader.gemspec +4 -2
- metadata +18 -16
data/src/google/googlefontapi.js
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
goog.provide('webfont.GoogleFontApi');
|
2
|
+
|
3
|
+
goog.require('webfont.FontApiUrlBuilder');
|
4
|
+
goog.require('webfont.FontApiParser');
|
5
|
+
goog.require('webfont.FontWatchRunner');
|
6
|
+
goog.require('webfont.LastResortWebKitFontWatchRunner');
|
7
|
+
|
1
8
|
/**
|
2
9
|
* @constructor
|
10
|
+
* @implements {webfont.FontModule}
|
3
11
|
*/
|
4
12
|
webfont.GoogleFontApi = function(userAgent, domHelper, configuration) {
|
5
13
|
this.userAgent_ = userAgent;
|
@@ -9,44 +17,52 @@ webfont.GoogleFontApi = function(userAgent, domHelper, configuration) {
|
|
9
17
|
|
10
18
|
webfont.GoogleFontApi.NAME = 'google';
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
goog.scope(function () {
|
21
|
+
var GoogleFontApi = webfont.GoogleFontApi,
|
22
|
+
FontWatchRunner = webfont.FontWatchRunner,
|
23
|
+
LastResortWebKitFontWatchRunner = webfont.LastResortWebKitFontWatchRunner,
|
24
|
+
FontApiUrlBuilder = webfont.FontApiUrlBuilder,
|
25
|
+
FontApiParser = webfont.FontApiParser;
|
15
26
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
20
|
-
return webfont.FontWatchRunner;
|
21
|
-
};
|
27
|
+
GoogleFontApi.prototype.supportUserAgent = function(userAgent, support) {
|
28
|
+
support(userAgent.getBrowserInfo().hasWebFontSupport());
|
29
|
+
};
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
31
|
+
GoogleFontApi.prototype.getFontWatchRunnerCtor = function() {
|
32
|
+
if (this.userAgent_.getEngine() == "AppleWebKit") {
|
33
|
+
return LastResortWebKitFontWatchRunner;
|
34
|
+
}
|
35
|
+
return FontWatchRunner;
|
36
|
+
};
|
27
37
|
|
28
|
-
|
29
|
-
domHelper
|
30
|
-
|
31
|
-
|
32
|
-
}
|
33
|
-
};
|
38
|
+
GoogleFontApi.prototype.load = function(onReady) {
|
39
|
+
var domHelper = this.domHelper_;
|
40
|
+
var nonBlockingIe = this.userAgent_.getName() == 'MSIE' &&
|
41
|
+
this.configuration_['blocking'] != true;
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
this.
|
39
|
-
|
40
|
-
|
43
|
+
if (nonBlockingIe) {
|
44
|
+
domHelper.whenBodyExists(goog.bind(this.insertLink_, this, onReady));
|
45
|
+
} else {
|
46
|
+
this.insertLink_(onReady);
|
47
|
+
}
|
48
|
+
};
|
41
49
|
|
42
|
-
|
43
|
-
|
50
|
+
GoogleFontApi.prototype.insertLink_ = function(onReady) {
|
51
|
+
var domHelper = this.domHelper_;
|
52
|
+
var fontApiUrlBuilder = new FontApiUrlBuilder(
|
53
|
+
this.configuration_['api'], domHelper.getProtocol(), this.configuration_['text']);
|
54
|
+
var fontFamilies = this.configuration_['families'];
|
55
|
+
fontApiUrlBuilder.setFontFamilies(fontFamilies);
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
var fontApiParser = new FontApiParser(fontFamilies);
|
58
|
+
fontApiParser.parse();
|
59
|
+
|
60
|
+
domHelper.insertInto('head', domHelper.createCssLink(
|
61
|
+
fontApiUrlBuilder.build()));
|
62
|
+
onReady(fontApiParser.getFontFamilies(), fontApiParser.getVariations(),
|
63
|
+
fontApiParser.getFontTestStrings());
|
64
|
+
};
|
65
|
+
});
|
50
66
|
|
51
67
|
globalNamespaceObject.addModule(webfont.GoogleFontApi.NAME, function(configuration, domHelper) {
|
52
68
|
var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
|
@@ -1,29 +1,34 @@
|
|
1
|
+
goog.provide('webfont.LastResortWebKitFontWatchRunner');
|
2
|
+
|
3
|
+
goog.require('webfont.FontRuler');
|
4
|
+
|
1
5
|
/**
|
2
6
|
* @constructor
|
3
7
|
* @param {function(string, string)} activeCallback
|
4
8
|
* @param {function(string, string)} inactiveCallback
|
5
9
|
* @param {webfont.DomHelper} domHelper
|
6
|
-
* @param {Object.<string, function(Object): webfont.Size>} fontSizer
|
7
|
-
* @param {function(function(), number=)} asyncCall
|
8
|
-
* @param {function(): number} getTime
|
9
10
|
* @param {string} fontFamily
|
10
11
|
* @param {string} fontDescription
|
11
|
-
* @param {
|
12
|
+
* @param {webfont.BrowserInfo} browserInfo
|
13
|
+
* @param {number=} opt_timeout
|
14
|
+
* @param {Object.<string, boolean>=} opt_metricCompatibleFonts
|
12
15
|
* @param {string=} opt_fontTestString
|
13
16
|
* @extends webfont.FontWatchRunner
|
14
17
|
*/
|
15
18
|
webfont.LastResortWebKitFontWatchRunner = function(activeCallback,
|
16
|
-
inactiveCallback, domHelper,
|
17
|
-
fontDescription,
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
inactiveCallback, domHelper, fontFamily,
|
20
|
+
fontDescription, browserInfo, opt_timeout, opt_metricCompatibleFonts, opt_fontTestString) {
|
21
|
+
|
22
|
+
goog.base(this, activeCallback, inactiveCallback, domHelper,
|
23
|
+
fontFamily, fontDescription, browserInfo, opt_timeout, opt_metricCompatibleFonts, opt_fontTestString);
|
24
|
+
|
21
25
|
this.webKitLastResortFontSizes_ = this.setUpWebKitLastResortFontSizes_();
|
22
26
|
this.webKitLastResortSizeChange_ = false;
|
23
27
|
this.lastObservedSizeA_ = this.lastResortSizes_[webfont.FontWatchRunner.LastResortFonts.SERIF];
|
24
28
|
this.lastObservedSizeB_ = this.lastResortSizes_[webfont.FontWatchRunner.LastResortFonts.SANS_SERIF];;
|
25
29
|
};
|
26
|
-
|
30
|
+
|
31
|
+
goog.inherits(webfont.LastResortWebKitFontWatchRunner, webfont.FontWatchRunner)
|
27
32
|
|
28
33
|
webfont.LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS = {
|
29
34
|
"Arimo": true,
|
@@ -31,70 +36,78 @@ webfont.LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS = {
|
|
31
36
|
"Tinos": true
|
32
37
|
};
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
* See file: WebKit/Source/WebCore/css/CSSFontFaceSource.cpp.
|
38
|
-
* Looking at the different implementation for the different platforms,
|
39
|
-
* the last resort fallback font is different. This code uses the default
|
40
|
-
* OS/browsers values.
|
41
|
-
*/
|
42
|
-
webfont.LastResortWebKitFontWatchRunner.prototype
|
43
|
-
.setUpWebKitLastResortFontSizes_ = function() {
|
44
|
-
var lastResortFonts = ['Times New Roman', 'Arial', 'Times', 'Sans', 'Serif'];
|
45
|
-
var lastResortFontSizes = lastResortFonts.length;
|
46
|
-
var webKitLastResortFontSizes = {};
|
47
|
-
var fontRuler = new webfont.FontRuler(this.domHelper_, this.fontSizer_, this.fontTestString_);
|
39
|
+
goog.scope(function () {
|
40
|
+
var LastResortWebKitFontWatchRunner = webfont.LastResortWebKitFontWatchRunner,
|
41
|
+
FontRuler = webfont.FontRuler;
|
48
42
|
|
49
|
-
|
50
|
-
|
43
|
+
/**
|
44
|
+
* While loading a web font webkit applies a last resort fallback font to the
|
45
|
+
* element on which the web font is applied.
|
46
|
+
* See file: WebKit/Source/WebCore/css/CSSFontFaceSource.cpp.
|
47
|
+
* Looking at the different implementation for the different platforms,
|
48
|
+
* the last resort fallback font is different. This code uses the default
|
49
|
+
* OS/browsers values.
|
50
|
+
*/
|
51
|
+
LastResortWebKitFontWatchRunner.prototype
|
52
|
+
.setUpWebKitLastResortFontSizes_ = function() {
|
53
|
+
var lastResortFonts = ['Times New Roman', 'Arial', 'Times', 'Sans', 'Serif'];
|
54
|
+
var lastResortFontSizes = lastResortFonts.length;
|
55
|
+
var webKitLastResortFontSizes = {};
|
56
|
+
var fontRuler = new FontRuler(this.domHelper_, this.fontTestString_);
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
var font = lastResortFonts[i];
|
55
|
-
fontRuler.setFont(font, this.fontDescription_);
|
56
|
-
webKitLastResortFontSizes[fontRuler.getSize().width] = true;
|
58
|
+
fontRuler.insert();
|
59
|
+
fontRuler.setFont(lastResortFonts[0], this.fontDescription_);
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
fontRuler.setFont(font, this.fontDescription_
|
61
|
+
webKitLastResortFontSizes[fontRuler.getSize().width] = true;
|
62
|
+
for (var i = 1; i < lastResortFontSizes; i++) {
|
63
|
+
var font = lastResortFonts[i];
|
64
|
+
fontRuler.setFont(font, this.fontDescription_);
|
62
65
|
webKitLastResortFontSizes[fontRuler.getSize().width] = true;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
fontRuler.remove();
|
66
|
-
return webKitLastResortFontSizes;
|
67
|
-
};
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
// Another WebKit quirk if the normal weight/style is loaded first,
|
68
|
+
// the size of the normal weight is returned when loading another weight.
|
69
|
+
if (this.fontDescription_[1] != '4') {
|
70
|
+
fontRuler.setFont(font, this.fontDescription_[0] + '4');
|
71
|
+
webKitLastResortFontSizes[fontRuler.getSize().width] = true;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
fontRuler.remove();
|
75
|
+
return webKitLastResortFontSizes;
|
76
|
+
};
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
if ((this.lastObservedSizeA_.width != sizeA.width || this.lastObservedSizeB_.width != sizeB.width) &&
|
80
|
-
(!this.webKitLastResortFontSizes_[sizeA.width] &&
|
81
|
-
!this.webKitLastResortFontSizes_[sizeB.width])) {
|
82
|
-
this.finish_(this.activeCallback_);
|
83
|
-
} else if (this.getTime_() - this.started_ >= 5000) {
|
78
|
+
/**
|
79
|
+
* @override
|
80
|
+
*/
|
81
|
+
LastResortWebKitFontWatchRunner.prototype.check_ = function() {
|
82
|
+
var sizeA = this.fontRulerA_.getSize();
|
83
|
+
var sizeB = this.fontRulerB_.getSize();
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
if (!this.webKitLastResortSizeChange_ && sizeA.width == sizeB.width &&
|
86
|
+
this.webKitLastResortFontSizes_[sizeA.width]) {
|
87
|
+
this.webKitLastResortFontSizes_ = {};
|
88
|
+
this.webKitLastResortFontSizes_[sizeA.width] = true;
|
89
|
+
this.webKitLastResortSizeChange_ = true;
|
90
|
+
}
|
91
|
+
if ((this.lastObservedSizeA_.width != sizeA.width || this.lastObservedSizeB_.width != sizeB.width) &&
|
92
|
+
(!this.webKitLastResortFontSizes_[sizeA.width] &&
|
93
|
+
!this.webKitLastResortFontSizes_[sizeB.width])) {
|
93
94
|
this.finish_(this.activeCallback_);
|
95
|
+
} else if (goog.now() - this.started_ >= 5000) {
|
96
|
+
|
97
|
+
// In order to handle the fact that a font could be the same size as the
|
98
|
+
// default browser font on a webkit browser, mark the font as active
|
99
|
+
// after 5 seconds if the latest 2 sizes are in webKitLastResortFontSizes_
|
100
|
+
// and the font name is known to be metrics compatible.
|
101
|
+
if (this.webKitLastResortFontSizes_[sizeA.width]
|
102
|
+
&& this.webKitLastResortFontSizes_[sizeB.width] &&
|
103
|
+
LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS[
|
104
|
+
this.fontFamily_]) {
|
105
|
+
this.finish_(this.activeCallback_);
|
106
|
+
} else {
|
107
|
+
this.finish_(this.inactiveCallback_);
|
108
|
+
}
|
94
109
|
} else {
|
95
|
-
this.
|
110
|
+
this.asyncCheck_();
|
96
111
|
}
|
97
|
-
}
|
98
|
-
|
99
|
-
}
|
100
|
-
};
|
112
|
+
};
|
113
|
+
});
|
data/src/modules.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
core:
|
2
|
-
-
|
2
|
+
- ../tools/compiler/base.js
|
3
3
|
- core/domhelper.js
|
4
4
|
- core/browserinfo.js
|
5
5
|
- core/useragent.js
|
6
6
|
- core/useragentparser.js
|
7
|
+
- core/cssclassname.js
|
8
|
+
- core/cssfontfamilyname.js
|
9
|
+
- core/fontvariationdescription.js
|
7
10
|
- core/eventdispatcher.js
|
8
11
|
- core/fontmoduleloader.js
|
9
12
|
- core/size.js
|
10
|
-
- core/fontwatcher.js
|
11
|
-
- core/fontwatchrunner.js
|
12
13
|
- core/fontruler.js
|
14
|
+
- core/fontwatchrunner.js
|
15
|
+
- core/fontwatcher.js
|
13
16
|
- core/font.js
|
14
|
-
- core/cssclassname.js
|
15
|
-
- core/cssfontfamilyname.js
|
16
|
-
- core/fontvariationdescription.js
|
17
17
|
- core/initialize.js
|
18
18
|
|
19
19
|
ascender:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
goog.provide('webfont.MonotypeScript');
|
2
|
+
|
1
3
|
/**
|
2
4
|
webfont.load({
|
3
5
|
monotype: {
|
@@ -8,6 +10,7 @@ projectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'//this is your Fonts.com Web fo
|
|
8
10
|
|
9
11
|
/**
|
10
12
|
* @constructor
|
13
|
+
* @implements {webfont.FontModule}
|
11
14
|
*/
|
12
15
|
webfont.MonotypeScript = function (userAgent, domHelper, configuration) {
|
13
16
|
this.userAgent_ = userAgent;
|
@@ -36,56 +39,60 @@ webfont.MonotypeScript.HOOK = '__mti_fntLst';
|
|
36
39
|
*/
|
37
40
|
webfont.MonotypeScript.SCRIPTID = '__MonotypeAPIScript__';
|
38
41
|
|
39
|
-
|
40
|
-
var
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
var
|
45
|
-
|
42
|
+
goog.scope(function () {
|
43
|
+
var MonotypeScript = webfont.MonotypeScript;
|
44
|
+
|
45
|
+
MonotypeScript.prototype.supportUserAgent = function (userAgent, support) {
|
46
|
+
var self = this;
|
47
|
+
var projectId = self.configuration_['projectId'];
|
48
|
+
var version = self.configuration_['version'];
|
49
|
+
if (projectId) {
|
50
|
+
var sc = self.domHelper_.createElement("script");
|
51
|
+
sc["id"] = MonotypeScript.SCRIPTID + projectId;
|
46
52
|
|
47
|
-
|
53
|
+
var loadWindow = this.domHelper_.getLoadWindow();
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
function onload() {
|
56
|
+
if (loadWindow[MonotypeScript.HOOK + projectId]) {
|
57
|
+
var mti_fnts = loadWindow[webfont.MonotypeScript.HOOK + projectId]();
|
58
|
+
if (mti_fnts && mti_fnts.length) {
|
59
|
+
var i;
|
60
|
+
for (i = 0; i < mti_fnts.length; i++) {
|
61
|
+
self.fontFamilies_.push(mti_fnts[i]["fontfamily"]);
|
62
|
+
}
|
56
63
|
}
|
57
64
|
}
|
65
|
+
support(userAgent.getBrowserInfo().hasWebFontSupport());
|
58
66
|
}
|
59
|
-
support(userAgent.getBrowserInfo().hasWebFontSupport());
|
60
|
-
}
|
61
67
|
|
62
|
-
|
68
|
+
var done = false;
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
sc["onload"] = sc["onreadystatechange"] = function () {
|
71
|
+
if (!done && (!this["readyState"] || this["readyState"] === "loaded" || this["readyState"] === "complete")) {
|
72
|
+
done = true;
|
73
|
+
onload();
|
74
|
+
sc["onload"] = sc["onreadystatechange"] = null;
|
75
|
+
}
|
76
|
+
};
|
71
77
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
};
|
78
|
+
sc["src"] = self.getScriptSrc(projectId, version);
|
79
|
+
this.domHelper_.insertInto('head', sc);
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
support(true);
|
83
|
+
}
|
84
|
+
};
|
79
85
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
};
|
86
|
+
MonotypeScript.prototype.getScriptSrc = function (projectId, version) {
|
87
|
+
var p = this.domHelper_.getProtocol();
|
88
|
+
var api = (this.configuration_['api'] || 'fast.fonts.com/jsapi').replace(/^.*http(s?):(\/\/)?/, "");
|
89
|
+
return p + "//" + api + '/' + projectId + '.js' + ( version ? '?v='+ version : '' );
|
90
|
+
};
|
85
91
|
|
86
|
-
|
87
|
-
|
88
|
-
};
|
92
|
+
MonotypeScript.prototype.load = function (onReady) {
|
93
|
+
onReady(this.fontFamilies_, this.fontVariations_);
|
94
|
+
};
|
95
|
+
});
|
89
96
|
|
90
97
|
globalNamespaceObject.addModule(webfont.MonotypeScript.NAME, function (configuration, domHelper) {
|
91
98
|
var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
|
@@ -1,5 +1,8 @@
|
|
1
|
+
goog.provide('webfont.TypekitScript');
|
2
|
+
|
1
3
|
/**
|
2
4
|
* @constructor
|
5
|
+
* @implements {webfont.FontModule}
|
3
6
|
*/
|
4
7
|
webfont.TypekitScript = function(domHelper, configuration) {
|
5
8
|
this.domHelper_ = domHelper;
|
@@ -11,49 +14,52 @@ webfont.TypekitScript = function(domHelper, configuration) {
|
|
11
14
|
webfont.TypekitScript.NAME = 'typekit';
|
12
15
|
webfont.TypekitScript.HOOK = '__webfonttypekitmodule__';
|
13
16
|
|
14
|
-
|
15
|
-
var
|
16
|
-
var api = this.configuration_['api'] || protocol + '//use.typekit.net';
|
17
|
-
return api + '/' + kitId + '.js';
|
18
|
-
};
|
17
|
+
goog.scope(function () {
|
18
|
+
var TypekitScript = webfont.TypekitScript;
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
TypekitScript.prototype.getScriptSrc = function(kitId) {
|
21
|
+
var protocol = this.domHelper_.getProtocol();
|
22
|
+
var api = this.configuration_['api'] || protocol + '//use.typekit.net';
|
23
|
+
return api + '/' + kitId + '.js';
|
24
|
+
};
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
TypekitScript.prototype.supportUserAgent = function(userAgent, support) {
|
27
|
+
var kitId = this.configuration_['id'];
|
28
|
+
var configuration = this.configuration_;
|
29
|
+
var loadWindow = this.domHelper_.getLoadWindow();
|
30
|
+
var self = this;
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
if (kitId) {
|
33
|
+
// Provide data to Typekit for processing.main
|
34
|
+
if (!loadWindow[webfont.TypekitScript.HOOK]) {
|
35
|
+
loadWindow[webfont.TypekitScript.HOOK] = {};
|
36
|
+
}
|
37
|
+
|
38
|
+
// Typekit will call 'init' to indicate whether it supports fonts
|
39
|
+
// and what fonts will be provided.
|
40
|
+
loadWindow[webfont.TypekitScript.HOOK][kitId] = function(callback) {
|
41
|
+
var init = function(typekitSupports, fontFamilies, fontVariations) {
|
42
|
+
self.fontFamilies_ = fontFamilies;
|
43
|
+
self.fontVariations_ = fontVariations;
|
44
|
+
support(typekitSupports);
|
45
|
+
};
|
46
|
+
callback(userAgent, configuration, init);
|
39
47
|
};
|
40
|
-
callback(userAgent, configuration, init);
|
41
|
-
};
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
// Load the Typekit script.
|
50
|
+
var script = this.domHelper_.createScriptSrc(this.getScriptSrc(kitId))
|
51
|
+
this.domHelper_.insertInto('head', script);
|
46
52
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
};
|
53
|
+
} else {
|
54
|
+
support(true);
|
55
|
+
}
|
56
|
+
};
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
};
|
58
|
+
TypekitScript.prototype.load = function(onReady) {
|
59
|
+
onReady(this.fontFamilies_, this.fontVariations_);
|
60
|
+
};
|
61
|
+
});
|
55
62
|
|
56
63
|
globalNamespaceObject.addModule(webfont.TypekitScript.NAME, function(configuration, domHelper) {
|
57
64
|
return new webfont.TypekitScript(domHelper, configuration);
|
58
65
|
});
|
59
|
-
|