-
Notifications
You must be signed in to change notification settings - Fork 0
/
typekit.js
175 lines (142 loc) · 4.5 KB
/
typekit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* MyFonts Webfont Build ID 683579, 2011-02-17T09:40:34-0500
*
* The fonts listed in this notice are subject to the End User License
* Agreement(s) entered into by the website owner. All other parties are
* explicitly restricted from using the Licensed Webfonts(s).
*
* You may obtain a valid license at the urls below.
*
* Webfont: Cocktail Shaker
* Url: http://new.myfonts.com/fonts/sideshow/cocktail-shaker/regular/
* Foundry: Sideshow
* Copyright: Copyright (c) Font Diner, 2002. All rights reserved.
* License: http://www.myfonts.com/viewlicense?1056
* Licensed pageviews: 10,000/month
* CSS font-family: CocktailShaker
* CSS font-weight: normal
*
* (c) 2011 Bitstream, Inc
*/
// safari 3.1: data-css
// firefox 3.6+: woff
// firefox 3.5+: data-css
// chrome 4+: data-css
// chrome 6+: woff
// IE 5+: eot
// IE 9: woff
// opera 10.1+: data-css
// mobile safari: svg/data-css
// android: data-css
var browserName, browserVersion, webfontType, webfontTypeOverride;
if (typeof(customPath) == 'undefined')
var customPath = false;
if (typeof(woffEnabled) == 'undefined')
var woffEnabled = true;
if (/myfonts_test=on/.test(window.location.search))
var myfonts_webfont_test = true;
else if (typeof(myfonts_webfont_test) == 'undefined')
var myfonts_webfont_test = false;
if (customPath)
var path = customPath;
else {
var scripts = document.getElementsByTagName("SCRIPT");
var script = scripts[scripts.length-1].src;
if (!script.match("://") && script.charAt(0) != '/')
script = "./"+script;
var path = script.replace(/\\/g,'/').replace(/\/[^\/]*\/?$/, '');
}
if (myfonts_webfont_test)
document.write('<script type="text/javascript" src="' +path+ '/MyFonts Webfonts Order M2739703_test.js"></script>');
if (/webfont=(woff|ttf|eot)/.test(window.location.search))
{
webfontTypeOverride = RegExp.$1;
if (webfontTypeOverride == 'ttf')
webfontTypeOverride = 'data-css';
}
if (/MSIE (\d+\.\d+)/.test(navigator.userAgent))
{
browserName = 'MSIE';
browserVersion = new Number(RegExp.$1);
if (browserVersion >= 9.0 && woffEnabled)
webfontType = 'woff';
else if (browserVersion >= 5.0)
webfontType = 'eot';
}
else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
browserName = 'Firefox';
browserVersion = new Number(RegExp.$1);
if (browserVersion >= 3.6 && woffEnabled)
webfontType = 'woff';
else if (browserVersion >= 3.5)
webfontType = 'data-css';
}
else if (/Chrome\/(\d+\.\d+)/.test(navigator.userAgent)) // must check before safari
{
browserName = 'Chrome';
browserVersion = new Number(RegExp.$1);
if (browserVersion >= 6.0 && woffEnabled)
webfontType = 'woff';
else if (browserVersion >= 4.0)
webfontType = 'data-css';
}
else if (/Mozilla.*(iPhone|iPad).* OS (\d+)_(\d+).* AppleWebKit.*Safari/.test(navigator.userAgent))
{
browserName = 'MobileSafari';
browserVersion = new Number(RegExp.$2) + (new Number(RegExp.$3) / 10)
if(browserVersion >= 4.2)
webfontType = 'data-css';
else
webfontType = 'svg';
}
else if (/Mozilla.*(iPhone|iPad).*AppleWebKit.*Safari/.test(navigator.userAgent))
{
browserName = 'MobileSafari';
webfontType = 'svg';
}
else if (/Safari\/(\d+\.\d+)/.test(navigator.userAgent))
{
browserName = 'Safari';
if (/Version\/(\d+\.\d+)/.test(navigator.userAgent))
{
browserVersion = new Number(RegExp.$1);
if (browserVersion >= 3.1)
webfontType = 'data-css';
}
}
else if (/Opera\/(\d+\.\d+)/.test(navigator.userAgent))
{
browserName = 'Opera';
if (/Version\/(\d+\.\d+)/.test(navigator.userAgent))
{
browserVersion = new Number(RegExp.$1);
if (browserVersion >= 10.1)
webfontType = 'data-css';
}
}
if (webfontTypeOverride)
webfontType = webfontTypeOverride;
switch (webfontType)
{
case 'eot':
document.write("<style>\n");
document.write("@font-face {font-family:\"CocktailShaker\";src:url(\"" + path + "/webfonts/eot/style_155789.eot\");}\n");
document.write("</style>");
break;
case 'woff':
document.write("<style>\n");
document.write("@font-face {font-family:\"CocktailShaker\";src:url(\"" + path + "/webfonts/woff/style_155789.woff\") format(\"woff\");}\n");
document.write("</style>");
break;
case 'data-css':
document.write("<link rel='stylesheet' type='text/css' href='" + path + "/webfonts/datacss/MyFonts Webfonts Order M2739703.css'>");
break;
case 'svg':
document.write("<style>\n");
document.write("@font-face {font-family:\"CocktailShaker\";src:url(\"" + path + "/webfonts/svg/style_155789.svg#CocktailShaker\") format(\"svg\");}\n");
document.write("</style>");
break;
default:
break;
}