@qooxdoo/framework 7.5.1 → 7.6.0
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.
- package/Manifest.json +169 -44
- package/lib/compiler/compile-info.json +76 -68
- package/lib/compiler/index.js +3683 -2588
- package/lib/resource/qx/tool/schema/Manifest-1-0-0.json +79 -26
- package/lib/resource/qx/tool/schema/Manifest-2-0-0.json +17 -26
- package/lib/resource/qx/tool/schema/compile-1-0-0.json +40 -53
- package/package.json +2 -2
- package/source/class/qx/bom/Font.js +36 -0
- package/source/class/qx/bom/webfonts/Validator.js +31 -6
- package/source/class/qx/bom/webfonts/WebFont.js +60 -64
- package/source/class/qx/bom/webfonts/WebFontLoader.js +461 -0
- package/source/class/qx/core/Object.js +1 -1
- package/source/class/qx/data/Array.js +27 -0
- package/source/class/qx/dev/FakeServer.js +1 -1
- package/source/class/qx/event/handler/Focus.js +2 -1
- package/source/class/qx/event/handler/GestureCore.js +1 -1
- package/source/class/qx/test/bom/webfonts/Validator.js +0 -6
- package/source/class/qx/test/core/Environment.js +8 -8
- package/source/class/qx/test/core/Validation.js +2 -2
- package/source/class/qx/test/dev/unit/Requirements.js +6 -6
- package/source/class/qx/test/ui/basic/Image.js +3 -3
- package/source/class/qx/test/ui/basic/Label.js +0 -65
- package/source/class/qx/test/ui/form/Field.js +56 -52
- package/source/class/qx/theme/classic/Font.js +7 -23
- package/source/class/qx/theme/iconfont/LoadMaterialIcons.js +2 -4
- package/source/class/qx/theme/iconfont/LoadMaterialIconsOutlined.js +2 -4
- package/source/class/qx/theme/iconfont/LoadMaterialIconsRound.js +2 -4
- package/source/class/qx/theme/iconfont/LoadMaterialIconsSharp.js +2 -4
- package/source/class/qx/theme/iconfont/LoadMaterialIconsTwoTone.js +2 -4
- package/source/class/qx/theme/indigo/Font.js +8 -15
- package/source/class/qx/theme/manager/Font.js +151 -38
- package/source/class/qx/theme/modern/Font.js +1 -0
- package/source/class/qx/theme/simple/Font.js +3 -1
- package/source/class/qx/theme/tangible/Appearance.js +1 -0
- package/source/class/qx/theme/tangible/Font.js +9 -62
- package/source/class/qx/theme/tangible/Image.js +1 -4
- package/source/class/qx/tool/cli/Cli.js +12 -0
- package/source/class/qx/tool/cli/Watch.js +3 -0
- package/source/class/qx/tool/cli/api/CompilerApi.js +8 -0
- package/source/class/qx/tool/cli/commands/Add.js +1 -1
- package/source/class/qx/tool/cli/commands/Compile.js +22 -0
- package/source/class/qx/tool/cli/commands/Config.js +16 -141
- package/source/class/qx/tool/cli/commands/ExportGlyphs.js +134 -0
- package/source/class/qx/tool/cli/commands/Package.js +3 -0
- package/source/class/qx/tool/cli/commands/Pkg.js +1 -1
- package/source/class/qx/tool/cli/commands/config/Delete.js +47 -0
- package/source/class/qx/tool/cli/commands/config/Get.js +52 -0
- package/source/class/qx/tool/cli/commands/config/List.js +81 -0
- package/source/class/qx/tool/cli/commands/config/Set.js +61 -0
- package/source/class/qx/tool/cli/commands/package/Update.js +3 -3
- package/source/class/qx/tool/compiler/Analyser.js +45 -0
- package/source/class/qx/tool/compiler/ClassFile.js +41 -0
- package/source/class/qx/tool/compiler/Console.js +6 -1
- package/source/class/qx/tool/compiler/app/Application.js +19 -0
- package/source/class/qx/tool/compiler/app/Library.js +51 -2
- package/source/class/qx/tool/compiler/app/ManifestFont.js +181 -0
- package/source/class/qx/tool/compiler/app/WebFont.js +144 -234
- package/source/class/qx/tool/compiler/makers/AppMaker.js +13 -0
- package/source/class/qx/tool/compiler/resources/ImageLoader.js +22 -12
- package/source/class/qx/tool/compiler/resources/Manager.js +2 -2
- package/source/class/qx/tool/compiler/resources/MetaLoader.js +7 -2
- package/source/class/qx/tool/compiler/resources/ResourceLoader.js +21 -0
- package/source/class/qx/tool/compiler/targets/Target.js +186 -67
- package/source/class/qx/tool/migration/M7_5_6.js +75 -0
- package/source/class/qx/tool/utils/Http.js +69 -0
- package/source/class/qx/ui/basic/Label.js +20 -38
- package/source/class/qx/ui/form/AbstractField.js +8 -2
- package/source/class/qx/ui/form/FileSelectorButton.js +5 -0
- package/source/class/qx/ui/table/pane/FocusIndicator.js +5 -4
- package/source/class/qx/ui/table/pane/Pane.js +14 -0
- package/source/class/qx/ui/table/pane/Scroller.js +3 -3
- package/source/class/qx/ui/virtual/core/Scroller.js +8 -2
- package/source/class/qx/ui/window/Window.js +9 -8
- package/source/resource/qx/iconfont/MaterialIcons/materialicons.json +10912 -0
- package/source/resource/qx/iconfont/MaterialIcons/materialiconsoutlined.json +10967 -0
- package/source/resource/qx/iconfont/MaterialIcons/materialiconsround.json +10992 -0
- package/source/resource/qx/iconfont/MaterialIcons/materialiconssharp.json +10992 -0
- package/source/resource/qx/iconfont/MaterialIcons/materialiconstwotone.json +9947 -0
- package/source/resource/qx/iconfont/MaterialIcons/x.json +10967 -0
- package/source/resource/qx/iconfont/export-glyphs.sh +22 -0
- package/source/resource/qx/tool/schema/Manifest-1-0-0.json +79 -26
- package/source/resource/qx/tool/schema/Manifest-2-0-0.json +17 -26
- package/source/resource/qx/tool/schema/compile-1-0-0.json +40 -53
- package/source/class/qx/bom/webfonts/Manager.js +0 -652
- package/source/class/qx/test/bom/webfonts/Manager.js +0 -238
|
@@ -1,652 +0,0 @@
|
|
|
1
|
-
/* ************************************************************************
|
|
2
|
-
|
|
3
|
-
qooxdoo - the new era of web development
|
|
4
|
-
|
|
5
|
-
http://qooxdoo.org
|
|
6
|
-
|
|
7
|
-
Copyright:
|
|
8
|
-
2004-2011 1&1 Internet AG, Germany, http://www.1und1.de
|
|
9
|
-
|
|
10
|
-
License:
|
|
11
|
-
MIT: https://opensource.org/licenses/MIT
|
|
12
|
-
See the LICENSE file in the project's top-level directory for details.
|
|
13
|
-
|
|
14
|
-
************************************************************************ */
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Manages font-face definitions, making sure that each rule is only applied
|
|
18
|
-
* once. It supports adding fonts of the same family but with different style
|
|
19
|
-
* and weight. For instance, the following declaration uses 4 different source
|
|
20
|
-
* files and combine them in a single font family.
|
|
21
|
-
*
|
|
22
|
-
* <pre class='javascript'>
|
|
23
|
-
* sources: [
|
|
24
|
-
* {
|
|
25
|
-
* family: "Sansation",
|
|
26
|
-
* source: [
|
|
27
|
-
* "fonts/Sansation-Regular.ttf"
|
|
28
|
-
* ]
|
|
29
|
-
* },
|
|
30
|
-
* {
|
|
31
|
-
* family: "Sansation",
|
|
32
|
-
* fontWeight: "bold",
|
|
33
|
-
* source: [
|
|
34
|
-
* "fonts/Sansation-Bold.ttf",
|
|
35
|
-
* ]
|
|
36
|
-
* },
|
|
37
|
-
* {
|
|
38
|
-
* family: "Sansation",
|
|
39
|
-
* fontStyle: "italic",
|
|
40
|
-
* source: [
|
|
41
|
-
* "fonts/Sansation-Italic.ttf",
|
|
42
|
-
* ]
|
|
43
|
-
* },
|
|
44
|
-
* {
|
|
45
|
-
* family: "Sansation",
|
|
46
|
-
* fontWeight: "bold",
|
|
47
|
-
* fontStyle: "italic",
|
|
48
|
-
* source: [
|
|
49
|
-
* "fonts/Sansation-BoldItalic.ttf",
|
|
50
|
-
* ]
|
|
51
|
-
* }
|
|
52
|
-
* ]
|
|
53
|
-
* </pre>
|
|
54
|
-
*
|
|
55
|
-
* This class does not need to be disposed, except when you want to abort the loading
|
|
56
|
-
* and validation process.
|
|
57
|
-
*/
|
|
58
|
-
qx.Class.define("qx.bom.webfonts.Manager", {
|
|
59
|
-
extend: qx.core.Object,
|
|
60
|
-
|
|
61
|
-
type: "singleton",
|
|
62
|
-
|
|
63
|
-
/*
|
|
64
|
-
*****************************************************************************
|
|
65
|
-
CONSTRUCTOR
|
|
66
|
-
*****************************************************************************
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
construct() {
|
|
70
|
-
super();
|
|
71
|
-
this.__createdStyles = [];
|
|
72
|
-
this.__validators = {};
|
|
73
|
-
this.__queue = [];
|
|
74
|
-
this.__preferredFormats = this.getPreferredFormats();
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
*****************************************************************************
|
|
79
|
-
STATICS
|
|
80
|
-
*****************************************************************************
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
statics: {
|
|
84
|
-
/**
|
|
85
|
-
* List of known font definition formats (i.e. file extensions). Used to
|
|
86
|
-
* identify the type of each font file configured for a web font.
|
|
87
|
-
*/
|
|
88
|
-
FONT_FORMATS: ["eot", "woff2", "woff", "ttf", "svg"],
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Timeout (in ms) to wait before deciding that a web font was not loaded.
|
|
92
|
-
*/
|
|
93
|
-
VALIDATION_TIMEOUT: 5000
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
*****************************************************************************
|
|
98
|
-
MEMBERS
|
|
99
|
-
*****************************************************************************
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
members: {
|
|
103
|
-
__createdStyles: null,
|
|
104
|
-
__styleSheet: null,
|
|
105
|
-
__validators: null,
|
|
106
|
-
__preferredFormats: null,
|
|
107
|
-
__queue: null,
|
|
108
|
-
__queueInterval: null,
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
---------------------------------------------------------------------------
|
|
112
|
-
PUBLIC API
|
|
113
|
-
---------------------------------------------------------------------------
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Adds the necessary font-face rule for a web font to the document. Also
|
|
118
|
-
* creates a web font Validator ({@link qx.bom.webfonts.Validator}) that
|
|
119
|
-
* checks if the webFont was applied correctly.
|
|
120
|
-
*
|
|
121
|
-
* @param familyName {String} Name of the web font
|
|
122
|
-
* @param sourcesList {Object} List of source URLs along with their style
|
|
123
|
-
* (e.g. fontStyle: "italic") and weight (e.g. fontWeight: "bold").
|
|
124
|
-
* For maximum compatibility, this should include EOT, WOFF and TTF versions
|
|
125
|
-
* of the font.
|
|
126
|
-
* @param callback {Function?} Optional event listener callback that will be
|
|
127
|
-
* executed once the validator has determined whether the webFont was
|
|
128
|
-
* applied correctly.
|
|
129
|
-
* See {@link qx.bom.webfonts.Validator#changeStatus}
|
|
130
|
-
* @param context {Object?} Optional context for the callback function
|
|
131
|
-
*/
|
|
132
|
-
require(familyName, sourcesList, callback, context) {
|
|
133
|
-
var sourceUrls = sourcesList.source;
|
|
134
|
-
var comparisonString = sourcesList.comparisonString;
|
|
135
|
-
var version = sourcesList.version;
|
|
136
|
-
var fontWeight = sourcesList.fontWeight;
|
|
137
|
-
var fontStyle = sourcesList.fontStyle;
|
|
138
|
-
var sources = [];
|
|
139
|
-
for (var i = 0, l = sourceUrls.length; i < l; i++) {
|
|
140
|
-
var split = sourceUrls[i].split("#");
|
|
141
|
-
var src = qx.util.ResourceManager.getInstance().toUri(split[0]);
|
|
142
|
-
if (split.length > 1) {
|
|
143
|
-
src = src + "#" + split[1];
|
|
144
|
-
}
|
|
145
|
-
sources.push(src);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// old IEs need a break in between adding @font-face rules
|
|
149
|
-
if (
|
|
150
|
-
qx.core.Environment.get("engine.name") == "mshtml" &&
|
|
151
|
-
(parseInt(qx.core.Environment.get("engine.version")) < 9 ||
|
|
152
|
-
qx.core.Environment.get("browser.documentmode") < 9)
|
|
153
|
-
) {
|
|
154
|
-
if (!this.__queueInterval) {
|
|
155
|
-
this.__queueInterval = new qx.event.Timer(100);
|
|
156
|
-
this.__queueInterval.addListener("interval", this.__flushQueue, this);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!this.__queueInterval.isEnabled()) {
|
|
160
|
-
this.__queueInterval.start();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
this.__queue.push([
|
|
164
|
-
familyName,
|
|
165
|
-
sources,
|
|
166
|
-
fontWeight,
|
|
167
|
-
fontStyle,
|
|
168
|
-
comparisonString,
|
|
169
|
-
version,
|
|
170
|
-
callback,
|
|
171
|
-
context
|
|
172
|
-
]);
|
|
173
|
-
} else {
|
|
174
|
-
this.__require(
|
|
175
|
-
familyName,
|
|
176
|
-
sources,
|
|
177
|
-
fontWeight,
|
|
178
|
-
fontStyle,
|
|
179
|
-
comparisonString,
|
|
180
|
-
version,
|
|
181
|
-
callback,
|
|
182
|
-
context
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Removes a font's font-face definition from the style sheet. This means
|
|
189
|
-
* the font will no longer be available and any elements using it will
|
|
190
|
-
* fall back to the their regular font-families.
|
|
191
|
-
*
|
|
192
|
-
* @param familyName {String} font-family name
|
|
193
|
-
* @param fontWeight {String} the font-weight.
|
|
194
|
-
* @param fontStyle {String} the font-style.
|
|
195
|
-
*/
|
|
196
|
-
remove(familyName, fontWeight, fontStyle) {
|
|
197
|
-
var fontLookupKey = this.__createFontLookupKey(
|
|
198
|
-
familyName,
|
|
199
|
-
fontWeight,
|
|
200
|
-
fontStyle
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
var index = null;
|
|
204
|
-
for (var i = 0, l = this.__createdStyles.length; i < l; i++) {
|
|
205
|
-
if (this.__createdStyles[i] == fontLookupKey) {
|
|
206
|
-
index = i;
|
|
207
|
-
this.__removeRule(familyName, fontWeight, fontStyle);
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
if (index !== null) {
|
|
212
|
-
qx.lang.Array.removeAt(this.__createdStyles, index);
|
|
213
|
-
}
|
|
214
|
-
if (fontLookupKey in this.__validators) {
|
|
215
|
-
this.__validators[fontLookupKey].dispose();
|
|
216
|
-
delete this.__validators[fontLookupKey];
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Returns the preferred font format(s) for the currently used browser. Some
|
|
222
|
-
* browsers support multiple formats, e.g. WOFF and TTF or WOFF and EOT. In
|
|
223
|
-
* those cases, WOFF is considered the preferred format.
|
|
224
|
-
*
|
|
225
|
-
* @return {String[]} List of supported font formats ordered by preference
|
|
226
|
-
* or empty Array if none could be determined
|
|
227
|
-
*/
|
|
228
|
-
getPreferredFormats() {
|
|
229
|
-
var preferredFormats = [];
|
|
230
|
-
var browser = qx.core.Environment.get("browser.name");
|
|
231
|
-
var browserVersion = qx.core.Environment.get("browser.version");
|
|
232
|
-
var os = qx.core.Environment.get("os.name");
|
|
233
|
-
var osVersion = qx.core.Environment.get("os.version");
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
(browser == "edge" && browserVersion >= 14) ||
|
|
237
|
-
(browser == "firefox" && browserVersion >= 69) ||
|
|
238
|
-
(browser == "chrome" && browserVersion >= 36)
|
|
239
|
-
) {
|
|
240
|
-
preferredFormats.push("woff2");
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
(browser == "ie" &&
|
|
245
|
-
qx.core.Environment.get("browser.documentmode") >= 9) ||
|
|
246
|
-
(browser == "edge" && browserVersion >= 12) ||
|
|
247
|
-
(browser == "firefox" && browserVersion >= 3.6) ||
|
|
248
|
-
(browser == "chrome" && browserVersion >= 6)
|
|
249
|
-
) {
|
|
250
|
-
preferredFormats.push("woff");
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
(browser == "edge" && browserVersion >= 12) ||
|
|
255
|
-
(browser == "opera" && browserVersion >= 10) ||
|
|
256
|
-
(browser == "safari" && browserVersion >= 3.1) ||
|
|
257
|
-
(browser == "firefox" && browserVersion >= 3.5) ||
|
|
258
|
-
(browser == "chrome" && browserVersion >= 4) ||
|
|
259
|
-
(browser == "mobile safari" && os == "ios" && osVersion >= 4.2)
|
|
260
|
-
) {
|
|
261
|
-
preferredFormats.push("ttf");
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (browser == "ie" && browserVersion >= 4) {
|
|
265
|
-
preferredFormats.push("eot");
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (browser == "mobileSafari" && os == "ios" && osVersion >= 4.1) {
|
|
269
|
-
preferredFormats.push("svg");
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return preferredFormats;
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Removes the styleSheet element used for all web font definitions from the
|
|
277
|
-
* document. This means all web fonts declared by the manager will no longer
|
|
278
|
-
* be available and elements using them will fall back to their regular
|
|
279
|
-
* font-families
|
|
280
|
-
*/
|
|
281
|
-
removeStyleSheet() {
|
|
282
|
-
this.__createdStyles = [];
|
|
283
|
-
if (this.__styleSheet) {
|
|
284
|
-
qx.bom.Stylesheet.removeSheet(this.__styleSheet);
|
|
285
|
-
}
|
|
286
|
-
this.__styleSheet = null;
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
/*
|
|
290
|
-
---------------------------------------------------------------------------
|
|
291
|
-
PRIVATE API
|
|
292
|
-
---------------------------------------------------------------------------
|
|
293
|
-
*/
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Creates a lookup key to index the created fonts.
|
|
297
|
-
* @param familyName {String} font-family name
|
|
298
|
-
* @param fontWeight {String} the font-weight.
|
|
299
|
-
* @param fontStyle {String} the font-style.
|
|
300
|
-
* @return {string} the font lookup key
|
|
301
|
-
*/
|
|
302
|
-
__createFontLookupKey(familyName, fontWeight, fontStyle) {
|
|
303
|
-
var lookupKey =
|
|
304
|
-
familyName +
|
|
305
|
-
"_" +
|
|
306
|
-
(fontWeight ? fontWeight : "normal") +
|
|
307
|
-
"_" +
|
|
308
|
-
(fontStyle ? fontStyle : "normal");
|
|
309
|
-
return lookupKey;
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Does the actual work of adding stylesheet rules and triggering font
|
|
314
|
-
* validation
|
|
315
|
-
*
|
|
316
|
-
* @param familyName {String} Name of the web font
|
|
317
|
-
* @param sources {String[]} List of source URLs. For maximum compatibility,
|
|
318
|
-
* this should include EOT, WOFF and TTF versions of the font.
|
|
319
|
-
* @param fontWeight {String} the web font should be registered using a
|
|
320
|
-
* fontWeight font weight.
|
|
321
|
-
* @param fontStyle {String} the web font should be registered using an
|
|
322
|
-
* fontStyle font style.
|
|
323
|
-
* @param comparisonString {String} String to check whether the font has loaded or not
|
|
324
|
-
* @param version {String?} Optional version that is appended to the font URL to be able to override caching
|
|
325
|
-
* @param callback {Function?} Optional event listener callback that will be
|
|
326
|
-
* executed once the validator has determined whether the webFont was
|
|
327
|
-
* applied correctly.
|
|
328
|
-
* @param context {Object?} Optional context for the callback function
|
|
329
|
-
*/
|
|
330
|
-
__require(
|
|
331
|
-
familyName,
|
|
332
|
-
sources,
|
|
333
|
-
fontWeight,
|
|
334
|
-
fontStyle,
|
|
335
|
-
comparisonString,
|
|
336
|
-
version,
|
|
337
|
-
callback,
|
|
338
|
-
context
|
|
339
|
-
) {
|
|
340
|
-
var fontLookupKey = this.__createFontLookupKey(
|
|
341
|
-
familyName,
|
|
342
|
-
fontWeight,
|
|
343
|
-
fontStyle
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
if (!this.__createdStyles.includes(fontLookupKey)) {
|
|
347
|
-
var sourcesMap = this.__getSourcesMap(sources);
|
|
348
|
-
var rule = this.__getRule(
|
|
349
|
-
familyName,
|
|
350
|
-
fontWeight,
|
|
351
|
-
fontStyle,
|
|
352
|
-
sourcesMap,
|
|
353
|
-
version
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
if (!rule) {
|
|
357
|
-
throw new Error(
|
|
358
|
-
"Couldn't create @font-face rule for WebFont " + familyName + "!"
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (!this.__styleSheet) {
|
|
363
|
-
this.__styleSheet = qx.bom.Stylesheet.createElement();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
try {
|
|
367
|
-
this.__addRule(rule);
|
|
368
|
-
} catch (ex) {
|
|
369
|
-
if (qx.core.Environment.get("qx.debug")) {
|
|
370
|
-
this.warn("Error while adding @font-face rule:", ex.message);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
this.__createdStyles.push(fontLookupKey);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (!this.__validators[fontLookupKey]) {
|
|
378
|
-
this.__validators[fontLookupKey] = new qx.bom.webfonts.Validator(
|
|
379
|
-
familyName,
|
|
380
|
-
comparisonString,
|
|
381
|
-
fontWeight,
|
|
382
|
-
fontStyle
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
this.__validators[fontLookupKey].setTimeout(
|
|
386
|
-
qx.bom.webfonts.Manager.VALIDATION_TIMEOUT
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
this.__validators[fontLookupKey].addListenerOnce(
|
|
390
|
-
"changeStatus",
|
|
391
|
-
this.__onFontChangeStatus,
|
|
392
|
-
this
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (callback) {
|
|
397
|
-
var cbContext = context || window;
|
|
398
|
-
this.__validators[fontLookupKey].addListenerOnce(
|
|
399
|
-
"changeStatus",
|
|
400
|
-
callback,
|
|
401
|
-
cbContext
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
this.__validators[fontLookupKey].validate();
|
|
406
|
-
},
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Processes the next item in the queue
|
|
410
|
-
*/
|
|
411
|
-
__flushQueue() {
|
|
412
|
-
if (this.__queue.length == 0) {
|
|
413
|
-
this.__queueInterval.stop();
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
var next = this.__queue.shift();
|
|
417
|
-
this.__require.apply(this, next);
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Removes the font-face declaration if a font could not be validated
|
|
422
|
-
*
|
|
423
|
-
* @param ev {qx.event.type.Data} qx.bom.webfonts.Validator#changeStatus
|
|
424
|
-
*/
|
|
425
|
-
__onFontChangeStatus(ev) {
|
|
426
|
-
var result = ev.getData();
|
|
427
|
-
if (result.valid === false) {
|
|
428
|
-
qx.event.Timer.once(
|
|
429
|
-
function () {
|
|
430
|
-
this.remove(result.family);
|
|
431
|
-
},
|
|
432
|
-
this,
|
|
433
|
-
250
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Uses a naive regExp match to determine the format of each defined source
|
|
440
|
-
* file for a webFont. Returns a map with the format names as keys and the
|
|
441
|
-
* corresponding source URLs as values.
|
|
442
|
-
*
|
|
443
|
-
* @param sources {String[]} Array of source URLs
|
|
444
|
-
* @return {Map} Map of formats and URLs
|
|
445
|
-
*/
|
|
446
|
-
__getSourcesMap(sources) {
|
|
447
|
-
var formats = qx.bom.webfonts.Manager.FONT_FORMATS;
|
|
448
|
-
var sourcesMap = {};
|
|
449
|
-
var reg = new RegExp(".(" + formats.join("|") + ")");
|
|
450
|
-
for (var i = 0, l = sources.length; i < l; i++) {
|
|
451
|
-
var match = reg.exec(sources[i]);
|
|
452
|
-
if (match) {
|
|
453
|
-
var type = match[1];
|
|
454
|
-
sourcesMap[type] = sources[i];
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return sourcesMap;
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Assembles the body of a font-face rule for a single webFont.
|
|
462
|
-
*
|
|
463
|
-
* @param familyName {String} Font-family name
|
|
464
|
-
* @param fontWeight {String} the web font should be registered using a
|
|
465
|
-
* fontWeight font weight.
|
|
466
|
-
* @param fontStyle {String} the web font should be registered using an
|
|
467
|
-
* fontStyle font style.
|
|
468
|
-
* @param sourcesMap {Map} Map of font formats and sources
|
|
469
|
-
* @param version {String?} Optional version to be appended to the URL
|
|
470
|
-
* @return {String} The computed CSS rule
|
|
471
|
-
*/
|
|
472
|
-
__getRule(familyName, fontWeight, fontStyle, sourcesMap, version) {
|
|
473
|
-
var rules = [];
|
|
474
|
-
|
|
475
|
-
var formatList =
|
|
476
|
-
this.__preferredFormats.length > 0
|
|
477
|
-
? this.__preferredFormats
|
|
478
|
-
: qx.bom.webfonts.Manager.FONT_FORMATS;
|
|
479
|
-
|
|
480
|
-
for (var i = 0, l = formatList.length; i < l; i++) {
|
|
481
|
-
var format = formatList[i];
|
|
482
|
-
if (sourcesMap[format]) {
|
|
483
|
-
rules.push(
|
|
484
|
-
this.__getSourceForFormat(format, sourcesMap[format], version)
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
var rule = "src: " + rules.join(",\n") + ";";
|
|
490
|
-
|
|
491
|
-
rule = "font-family: " + familyName + ";\n" + rule;
|
|
492
|
-
rule = rule + "\nfont-style: " + (fontStyle ? fontStyle : "normal") + ";";
|
|
493
|
-
rule =
|
|
494
|
-
rule + "\nfont-weight: " + (fontWeight ? fontWeight : "normal") + ";";
|
|
495
|
-
|
|
496
|
-
return rule;
|
|
497
|
-
},
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Returns the full src value for a given font URL depending on the type
|
|
501
|
-
* @param format {String} The font format, one of eot, woff2, woff, ttf, svg
|
|
502
|
-
* @param url {String} The font file's URL
|
|
503
|
-
* @param version {String?} Optional version to be appended to the URL
|
|
504
|
-
* @return {String} The src directive
|
|
505
|
-
*/
|
|
506
|
-
|
|
507
|
-
__getSourceForFormat(format, url, version) {
|
|
508
|
-
if (version) {
|
|
509
|
-
url += "?" + version;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
switch (format) {
|
|
513
|
-
case "eot":
|
|
514
|
-
return (
|
|
515
|
-
"url('" +
|
|
516
|
-
url +
|
|
517
|
-
"');" +
|
|
518
|
-
"src: url('" +
|
|
519
|
-
url +
|
|
520
|
-
"?#iefix') format('embedded-opentype')"
|
|
521
|
-
);
|
|
522
|
-
|
|
523
|
-
case "woff2":
|
|
524
|
-
return "url('" + url + "') format('woff2')";
|
|
525
|
-
case "woff":
|
|
526
|
-
return "url('" + url + "') format('woff')";
|
|
527
|
-
case "ttf":
|
|
528
|
-
return "url('" + url + "') format('truetype')";
|
|
529
|
-
case "svg":
|
|
530
|
-
return "url('" + url + "') format('svg')";
|
|
531
|
-
default:
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* Adds a font-face rule to the document
|
|
538
|
-
*
|
|
539
|
-
* @param rule {String} The body of the CSS rule
|
|
540
|
-
*/
|
|
541
|
-
__addRule(rule) {
|
|
542
|
-
var completeRule = "@font-face {" + rule + "}\n";
|
|
543
|
-
|
|
544
|
-
if (
|
|
545
|
-
qx.core.Environment.get("browser.name") == "ie" &&
|
|
546
|
-
qx.core.Environment.get("browser.documentmode") < 9
|
|
547
|
-
) {
|
|
548
|
-
var cssText = this.__fixCssText(this.__styleSheet.cssText);
|
|
549
|
-
cssText += completeRule;
|
|
550
|
-
this.__styleSheet.cssText = cssText;
|
|
551
|
-
} else {
|
|
552
|
-
this.__styleSheet.insertRule(
|
|
553
|
-
completeRule,
|
|
554
|
-
this.__styleSheet.cssRules.length
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Removes the font-face declaration for the given font-family from the
|
|
561
|
-
* stylesheet
|
|
562
|
-
*
|
|
563
|
-
* @param familyName {String} The font-family name
|
|
564
|
-
* @param fontWeight {String} fontWeight font-weight.
|
|
565
|
-
* @param fontStyle {String} fontStyle font-style.
|
|
566
|
-
*/
|
|
567
|
-
__removeRule(familyName, fontWeight, fontStyle) {
|
|
568
|
-
// In IE and edge even if the rule was added with font-style first
|
|
569
|
-
// and font-weight second, it is not guaranteed that the attributes
|
|
570
|
-
// remain in that order. Therefore we check for both version,
|
|
571
|
-
// style first, weight second and weight first, style second.
|
|
572
|
-
// Without this fix the rule isn't found and removed reliable.
|
|
573
|
-
var regtext =
|
|
574
|
-
"@font-face.*?" +
|
|
575
|
-
familyName +
|
|
576
|
-
"(.*font-style: *" +
|
|
577
|
-
(fontStyle ? fontStyle : "normal") +
|
|
578
|
-
".*font-weight: *" +
|
|
579
|
-
(fontWeight ? fontWeight : "normal") +
|
|
580
|
-
")|" +
|
|
581
|
-
"(.*font-weight: *" +
|
|
582
|
-
(fontWeight ? fontWeight : "normal") +
|
|
583
|
-
".*font-style: *" +
|
|
584
|
-
(fontStyle ? fontStyle : "normal") +
|
|
585
|
-
")";
|
|
586
|
-
|
|
587
|
-
var reg = new RegExp(regtext, "m");
|
|
588
|
-
for (var i = 0, l = document.styleSheets.length; i < l; i++) {
|
|
589
|
-
var sheet = document.styleSheets[i];
|
|
590
|
-
if (sheet.cssText) {
|
|
591
|
-
var cssText = sheet.cssText.replace(/\n/g, "").replace(/\r/g, "");
|
|
592
|
-
cssText = this.__fixCssText(cssText);
|
|
593
|
-
if (reg.exec(cssText)) {
|
|
594
|
-
cssText = cssText.replace(reg, "");
|
|
595
|
-
}
|
|
596
|
-
sheet.cssText = cssText;
|
|
597
|
-
} else {
|
|
598
|
-
let cssRules = null;
|
|
599
|
-
try {
|
|
600
|
-
cssRules = sheet.cssRules;
|
|
601
|
-
} catch (ex) {
|
|
602
|
-
// Exception is thrown if there are no rules (eg a `<link>` tag inserted by the user)
|
|
603
|
-
}
|
|
604
|
-
if (cssRules) {
|
|
605
|
-
for (var j = 0, m = cssRules.length; j < m; j++) {
|
|
606
|
-
var cssText = cssRules[j].cssText
|
|
607
|
-
.replace(/\n/g, "")
|
|
608
|
-
.replace(/\r/g, "");
|
|
609
|
-
if (reg.exec(cssText)) {
|
|
610
|
-
this.__styleSheet.deleteRule(j);
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* IE 6 and 7 omit the trailing quote after the format name when
|
|
621
|
-
* querying cssText. This needs to be fixed before cssText is replaced
|
|
622
|
-
* or all rules will be invalid and no web fonts will work any more.
|
|
623
|
-
*
|
|
624
|
-
* @param cssText {String} CSS text
|
|
625
|
-
* @return {String} Fixed CSS text
|
|
626
|
-
*/
|
|
627
|
-
__fixCssText(cssText) {
|
|
628
|
-
return cssText
|
|
629
|
-
.replace("'eot)", "'eot')")
|
|
630
|
-
.replace("('embedded-opentype)", "('embedded-opentype')");
|
|
631
|
-
}
|
|
632
|
-
},
|
|
633
|
-
|
|
634
|
-
/*
|
|
635
|
-
*****************************************************************************
|
|
636
|
-
DESTRUCTOR
|
|
637
|
-
*****************************************************************************
|
|
638
|
-
*/
|
|
639
|
-
|
|
640
|
-
destruct() {
|
|
641
|
-
if (this.__queueInterval) {
|
|
642
|
-
this.__queueInterval.stop();
|
|
643
|
-
this.__queueInterval.dispose();
|
|
644
|
-
}
|
|
645
|
-
delete this.__createdStyles;
|
|
646
|
-
this.removeStyleSheet();
|
|
647
|
-
for (var prop in this.__validators) {
|
|
648
|
-
this.__validators[prop].dispose();
|
|
649
|
-
}
|
|
650
|
-
qx.bom.webfonts.Validator.removeDefaultHelperElements();
|
|
651
|
-
}
|
|
652
|
-
});
|