@xlfont/load 1.0.10 → 1.0.11

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/CHANGELOG.md ADDED
@@ -0,0 +1,72 @@
1
+ # Change Logs
2
+
3
+ ## v1.0.11
4
+
5
+ - remove dependency to proxise by inlining `once` function
6
+ - rename `xfl.js` while keeping `index.js`, which will be removed in future minor update
7
+ - rename `xfont` to `xlfont` to reflect package name.
8
+
9
+
10
+ ## v1.0.10
11
+
12
+ - escape space in class name
13
+ - quote name in font family name that didn't quote in the last version
14
+
15
+
16
+ ## v1.0.9
17
+
18
+ - escape space in font name
19
+ - quote name and url in font family styles
20
+ - call update for non-xl fonts
21
+ - fix incorrectly assignment in xfl.update
22
+
23
+
24
+ ## v1.0.8
25
+
26
+ - fix bug: `-a` option doesn't work in `xfl-meta`
27
+
28
+
29
+ ## v1.0.7
30
+
31
+ - fix incorrect versioning issue
32
+
33
+
34
+ ## v1.0.5 / v1.0.6
35
+
36
+ - skip notdef by reference instead of by name. This fixed `Taipei Sans TC Beta` generation issue.
37
+
38
+
39
+ ## v1.0.4
40
+
41
+ - handle newlines in metadata
42
+
43
+
44
+ ## v1.0.3
45
+
46
+ - support subsetting only single font in xfl command
47
+ - better formatting of xfl-meta output
48
+
49
+
50
+ ## v1.0.2
51
+
52
+ - add `xfl-meta` command
53
+ - add missing dependency in `build.js`
54
+ - update `package.json` for some dependencies that should be for production
55
+
56
+
57
+ ## v1.0.1
58
+
59
+ - remove npm-shrinkwrap.json
60
+
61
+
62
+ ## v1.0.0
63
+
64
+ - completely rewrite xfl.ls
65
+ - support font merging based on opentype.js
66
+ - non-xl-font aware
67
+ - better support for concurrent fetching
68
+ - support promise in all api
69
+ - use SIL-Open Licensed fonts only for demonstration
70
+ - remove fontmin / gulp-rename dependency
71
+ - add `woff` format output
72
+ - use `@plotdb/opentype.js` for bug fixing
package/README.md CHANGED
@@ -115,6 +115,24 @@ While this is a tool for composing and using xl-font, we also prepare a set of x
115
115
  - parsed from content of `https://www.ling.upenn.edu/courses/Spring_2003/ling538/UnicodeRanges.html`
116
116
  - content of the above link is from `http://www.unicode.org/charts/`
117
117
 
118
+ ## Font Subsetting Consideration
119
+
120
+ According to *[SIL's OFL FAQ](https://scripts.sil.org/cms/scripts/page.php?item_id=OFL-FAQ_web#b4b7db21)* and *[Web Fonts and Reserved Font Names](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL_web_fonts_and_RFNs#33301a9c)*, Subsetting a font is considered *modification* of that font. This is permitted by *Open Font License (OFL)*, but OFL requires that modified versions must not use RFNs (Reserved Font Names) without separate permission.
121
+
122
+ However, once FE (Functional Equivalence) is preserved, then it's very likely that the original author would feel that the optimized font is a good and reasonable equivalent, and that the main purposes of the RFN mechanism - avoids collisions, protects authors. minimizes support, encourages derivatives - continue to be met.
123
+
124
+ An optimized font is considered FE if:
125
+
126
+ - Supports the same full character inventory
127
+ - Provides the same smart font behavior
128
+ - Presents text with no obvious degradation in visual quality
129
+ - Preserves original author, project and license metadata
130
+
131
+ Subsetting is [discussed separated](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL_web_fonts_and_RFNs#b4599c52) and only `Dynamic Subsetting` and `Dynamic Subsetting with Progressive Client Storage` is considered as possibly FE preserved.
132
+
133
+ With `@xlfont/load` serving the subsetted font it can possibly be considered `Dynamic Subsetting`, however the subsetted font alone definitely will be in the `pre-subsetting` category.
134
+
135
+
118
136
  ## LICENSE
119
137
 
120
138
  MIT License.
package/dist/index.js ADDED
@@ -0,0 +1,433 @@
1
+ (function(){
2
+ var err, once, xlfont, xfl;
3
+ err = function(e){
4
+ e == null && (e = {});
5
+ return import$(new Error(), import$({
6
+ name: 'lderror'
7
+ }, e));
8
+ };
9
+ once = function(f, q){
10
+ q == null && (q = []);
11
+ return function(){
12
+ if (q.s === 2) {
13
+ return Promise.resolve();
14
+ } else if (q.s === 1) {
15
+ return new Promise(function(res, rej){
16
+ return q.push({
17
+ res: res,
18
+ rej: rej
19
+ });
20
+ });
21
+ }
22
+ return Promise.resolve(q.s = 1).then(function(){
23
+ return f();
24
+ }).then(function(){
25
+ q.s = 2;
26
+ return q.splice(0).map(function(it){
27
+ return it.res();
28
+ });
29
+ })['catch'](function(e){
30
+ q.s = 0;
31
+ q.splice(0).map(function(it){
32
+ return it.rej(e);
33
+ });
34
+ return Promise.reject(e);
35
+ });
36
+ };
37
+ };
38
+ xlfont = function(opt){
39
+ var ref$, that, this$ = this;
40
+ opt == null && (opt = {});
41
+ this.opt = opt;
42
+ this.sub = {
43
+ set: {},
44
+ font: {}
45
+ };
46
+ this.cjkOnly = opt.cjkOnly || false;
47
+ this.codemap = {};
48
+ this.otf = {
49
+ font: null,
50
+ dirty: true
51
+ };
52
+ this.path = opt.path;
53
+ this.name = opt.name || (ref$ = this.path.replace(/\.[a-zA-Z0-9]+$/, '').split("/").filter(function(it){
54
+ return it;
55
+ }))[ref$.length - 1];
56
+ this.style = 'normal';
57
+ this.ext = opt.ext || (/\.(ttf|otf|woff2|woff)$/.exec(this.path) || [])[1] || '';
58
+ this.format = (that = this.ext.toLowerCase()) ? that === 'ttf'
59
+ ? 'truetype'
60
+ : that === 'otf' ? 'truetype' : that : '';
61
+ if (this.format) {
62
+ this.format = "format('" + this.format + "')";
63
+ }
64
+ this.className = "xfl-" + (this.name || '').replace(/\s+/g, '_') + "-" + Math.random().toString(36).substring(2);
65
+ this.isXl = !this.ext;
66
+ this.css = [];
67
+ this.init = once(function(){
68
+ return this$._init();
69
+ });
70
+ this.init();
71
+ return this;
72
+ };
73
+ xlfont.prototype = import$(Object.create(Object.prototype), {
74
+ _init: function(){
75
+ var this$ = this;
76
+ return Promise.resolve().then(function(){
77
+ if (!this$.isXl) {
78
+ this$.css = [{
79
+ content: "@font-face {\n font-family: \"" + this$.name + "\";\n src: url(\"" + this$.path + "\") " + this$.format + ";\n}\n." + this$.className + " { font-family: \"" + this$.name + "\"; }"
80
+ }];
81
+ return xfl.update();
82
+ } else {
83
+ return new Promise(function(res, rej){
84
+ var xhr;
85
+ xhr = new XMLHttpRequest();
86
+ xhr.addEventListener('readystatechange', function(){
87
+ if (xhr.readyState !== XMLHttpRequest.DONE) {
88
+ return;
89
+ }
90
+ if (xhr.status !== 200) {
91
+ return rej(err({
92
+ code: xhr.status,
93
+ message: xhr.responseText
94
+ }));
95
+ }
96
+ (xhr.responseText || '').split('\n').map(function(d, i){
97
+ return d.split(' ').map(function(e, j){
98
+ return this$.codemap[e] = i + 1;
99
+ });
100
+ });
101
+ return res();
102
+ });
103
+ xhr.open('GET', this$.path + "/charmap.txt");
104
+ return xhr.send();
105
+ });
106
+ }
107
+ });
108
+ },
109
+ _fetch: function(f, dofetch){
110
+ var this$ = this;
111
+ f == null && (f = {});
112
+ dofetch == null && (dofetch = false);
113
+ if (!dofetch) {
114
+ if (!f.url) {
115
+ if (this.isXl) {
116
+ f.url = this.path + "/" + f.key + ".woff2";
117
+ f.type = 'woff2';
118
+ } else {
119
+ f.url = this.path;
120
+ f.type = this.ext.toLowerCase();
121
+ }
122
+ }
123
+ return Promise.resolve(f);
124
+ }
125
+ if (f.blob) {
126
+ return Promise.resolve(f);
127
+ }
128
+ if (!f.proxy) {
129
+ f.proxy = proxise(function(f){
130
+ var p;
131
+ if (f.running) {
132
+ return;
133
+ }
134
+ f.running = true;
135
+ p = new Promise(function(res, rej){
136
+ var xhr;
137
+ if (f.blob) {
138
+ return res(f);
139
+ }
140
+ xhr = new XMLHttpRequest();
141
+ xhr.addEventListener('readystatechange', function(){
142
+ if (xhr.readyState !== XMLHttpRequest.DONE) {
143
+ return;
144
+ }
145
+ if (xhr.status !== 200) {
146
+ return rej(err({
147
+ code: xhr.status,
148
+ message: xhr.responseText
149
+ }));
150
+ }
151
+ this$.otf.dirty = true;
152
+ f.url = URL.createObjectURL(xhr.response);
153
+ f.blob = xhr.response;
154
+ f.type = this$.ext.toLowerCase() || 'ttf';
155
+ return res(f);
156
+ });
157
+ if (this$.isXl) {
158
+ xhr.open('GET', this$.path + "/" + f.key + ".ttf");
159
+ } else {
160
+ xhr.open('GET', this$.path);
161
+ }
162
+ xhr.responseType = 'blob';
163
+ return xhr.send();
164
+ });
165
+ return p['finally'](function(){
166
+ return f.running = false;
167
+ });
168
+ });
169
+ }
170
+ return f.proxy(f);
171
+ },
172
+ fetchAll: function(){
173
+ var k, f, this$ = this;
174
+ if (this.isXl) {
175
+ return Promise.all((function(){
176
+ var ref$, results$ = [];
177
+ for (k in ref$ = this.sub.font) {
178
+ f = ref$[k];
179
+ results$.push(f);
180
+ }
181
+ return results$;
182
+ }.call(this)).map(function(it){
183
+ return this$._fetch(it, true);
184
+ }));
185
+ } else {
186
+ return this._fetch(this.sub.font[0], true);
187
+ }
188
+ },
189
+ fetch: function(list, dofetch){
190
+ var ps, this$ = this;
191
+ list == null && (list = []);
192
+ dofetch == null && (dofetch = false);
193
+ if (!this.isXl) {
194
+ if (this.sub.font[0].blob) {
195
+ return Promise.resolve();
196
+ }
197
+ list = [0];
198
+ }
199
+ ps = Array.from(new Set(list.map(function(it){
200
+ return it;
201
+ }))).filter(function(it){
202
+ return !this$.sub.font[it];
203
+ }).map(function(it){
204
+ var f;
205
+ this$.sub.font[it] = f = {
206
+ key: it
207
+ };
208
+ return this$._fetch(f, dofetch);
209
+ });
210
+ return Promise.all(ps).then(function(subfonts){
211
+ var css, k, ref$, f, i$, len$;
212
+ if (!subfonts.length) {
213
+ return;
214
+ }
215
+ css = "." + this$.className + " { font-family: \"" + this$.name + "\"; }";
216
+ for (k in ref$ = this$.sub.font) {
217
+ f = ref$[k];
218
+ }
219
+ for (i$ = 0, len$ = subfonts.length; i$ < len$; ++i$) {
220
+ f = subfonts[i$];
221
+ css += "@font-face {\n font-family: \"" + this$.name + "\";\n src: url(\"" + f.url + "\") format('" + f.type + "');\n}";
222
+ }
223
+ return this$.css.push({
224
+ content: css
225
+ });
226
+ });
227
+ },
228
+ getotf: function(){
229
+ var this$ = this;
230
+ if (!(typeof opentype != 'undefined' && opentype !== null)) {
231
+ return Promise.reject(err({
232
+ id: 1022,
233
+ message: "[@plotdb/xfl] need opentype.js to merge subfonts"
234
+ }));
235
+ }
236
+ if (!this.otf.dirty) {
237
+ return Promise.resolve(this.otf.font);
238
+ }
239
+ return Promise.resolve().then(function(){
240
+ if (!this$.isXl) {
241
+ return this$.fetch();
242
+ } else {
243
+ return this$.fetchAll();
244
+ }
245
+ }).then(function(){
246
+ var ps, k, f;
247
+ ps = (function(){
248
+ var ref$, results$ = [];
249
+ for (k in ref$ = this.sub.font) {
250
+ f = ref$[k];
251
+ results$.push(f);
252
+ }
253
+ return results$;
254
+ }.call(this$)).map(function(f){
255
+ if (f.otf) {
256
+ return Promise.resolve(f);
257
+ } else {
258
+ return opentype.load(f.url).then(function(it){
259
+ f.otf = it;
260
+ return f;
261
+ });
262
+ }
263
+ });
264
+ return Promise.all(ps);
265
+ }).then(function(list){
266
+ var glyphs, ref$, ref1$;
267
+ list == null && (list = []);
268
+ if (list.length === 1) {
269
+ return list[0].otf;
270
+ }
271
+ glyphs = list.map(function(f){
272
+ var glyphs, i$, to$, i, results$ = [];
273
+ glyphs = f.otf.glyphs;
274
+ for (i$ = 1, to$ = glyphs.length; i$ <= to$; ++i$) {
275
+ i = i$;
276
+ results$.push(glyphs.glyphs[i]);
277
+ }
278
+ return results$;
279
+ }).reduce(function(a, b){
280
+ return a.concat(b);
281
+ }, []).filter(function(it){
282
+ return it;
283
+ });
284
+ this$.otf.font = new opentype.Font((ref1$ = {
285
+ familyName: this$.name,
286
+ styleName: this$.style || 'normal',
287
+ glyphs: glyphs
288
+ }, ref1$.unitsPerEm = (ref$ = list[0].otf).unitsPerEm, ref1$.ascender = ref$.ascender, ref1$.descender = ref$.descender, ref1$));
289
+ this$.otf.font.kerningPairs = {};
290
+ return this$.otf.font;
291
+ });
292
+ },
293
+ sync: function(txt){
294
+ var ref$, misschar, missset, this$ = this;
295
+ txt == null && (txt = "");
296
+ if (!this.isXl) {
297
+ xfl.update();
298
+ return Promise.resolve();
299
+ }
300
+ ref$ = [{}, {}], misschar = ref$[0], missset = ref$[1];
301
+ return Promise.resolve().then(function(){
302
+ var i$, to$, i, code, setIdx, k, list, res$;
303
+ for (i$ = 0, to$ = txt.length; i$ < to$; ++i$) {
304
+ i = i$;
305
+ code = txt.charCodeAt(i);
306
+ if (this$.cjkOnly && !xfl.isCJK(code)) {
307
+ continue;
308
+ }
309
+ setIdx = this$.codemap[code.toString(16)];
310
+ if (!setIdx) {
311
+ misschar[txt[i]] = true;
312
+ } else if (!this$.sub.set[setIdx]) {
313
+ this$.sub.set[setIdx] = missset[setIdx] = true;
314
+ }
315
+ }
316
+ misschar = (function(){
317
+ var results$ = [];
318
+ for (k in misschar) {
319
+ results$.push(k);
320
+ }
321
+ return results$;
322
+ }()).filter(function(it){
323
+ return it.trim();
324
+ });
325
+ if (misschar.length) {
326
+ console.log("[@plotdb/xfl] sync xl-font with following chars unsupported: " + misschar.join(''));
327
+ }
328
+ res$ = [];
329
+ for (k in missset) {
330
+ res$.push(k);
331
+ }
332
+ list = res$;
333
+ if (list.length) {
334
+ return this$.fetch(list);
335
+ }
336
+ }).then(function(){
337
+ return xfl.update();
338
+ });
339
+ }
340
+ });
341
+ xfl = {
342
+ range: {
343
+ CJK: [[0x3040, 0x30ff], [0x3400, 0x4dbf], [0x4e00, 0x9fff], [0xf900, 0xfaff], [0xff66, 0xff9f], [0x3131, 0xD79D]]
344
+ },
345
+ fonts: {},
346
+ running: {},
347
+ isCJK: function(code){
348
+ return this.range.CJK.filter(function(it){
349
+ return code >= it[0] && code <= it[1];
350
+ }).length;
351
+ },
352
+ proxy: {},
353
+ update: function(){
354
+ var css, k, ref$, v, node;
355
+ css = "";
356
+ for (k in ref$ = this.fonts) {
357
+ v = ref$[k];
358
+ (v.css || []).filter(fn$).map(fn1$);
359
+ }
360
+ if (css) {
361
+ node = document.createElement("style");
362
+ node.textContent = css;
363
+ node.setAttribute('type', 'text/css');
364
+ return document.body.appendChild(node);
365
+ }
366
+ function fn$(it){
367
+ return !it.rendered;
368
+ }
369
+ function fn1$(it){
370
+ it.rendered = true;
371
+ return css = css + it.content;
372
+ }
373
+ },
374
+ _load: function(opt){
375
+ var path, this$ = this;
376
+ opt == null && (opt = {});
377
+ path = opt.path;
378
+ if (this.running[path]) {
379
+ return;
380
+ }
381
+ this.running[path] = true;
382
+ return Promise.resolve().then(function(){
383
+ var fobj;
384
+ this$.fonts[path] = fobj = new xlfont(opt);
385
+ return fobj.init();
386
+ })['finally'](function(){
387
+ return this$.running[path] = false;
388
+ }).then(function(){
389
+ this$.proxy[path].resolve(this$.fonts[path]);
390
+ return this$.fonts[path];
391
+ })['catch'](function(it){
392
+ this$.proxy[path].reject(it);
393
+ return Promise.reject(it);
394
+ });
395
+ },
396
+ load: function(opt){
397
+ var this$ = this;
398
+ opt == null && (opt = {});
399
+ return new Promise(function(res, rej){
400
+ var path, that, ref$;
401
+ if (!(path = opt.path)) {
402
+ return rej(err({
403
+ id: 400
404
+ }));
405
+ }
406
+ path = path.replace(/\/$/, '');
407
+ if (that = this$.fonts[path]) {
408
+ return res(that);
409
+ }
410
+ if (!this$.proxy[path]) {
411
+ this$.proxy[path] = proxise(function(it){
412
+ return this$._load(it);
413
+ });
414
+ }
415
+ return this$.proxy[path]((ref$ = import$({}, opt), ref$.path = path, ref$)).then(function(it){
416
+ return res(it);
417
+ })['catch'](function(it){
418
+ return rej(it);
419
+ });
420
+ });
421
+ }
422
+ };
423
+ if (typeof module != 'undefined' && module !== null) {
424
+ module.exports = xfl;
425
+ } else if (typeof window != 'undefined' && window !== null) {
426
+ window.xfl = xfl;
427
+ }
428
+ function import$(obj, src){
429
+ var own = {}.hasOwnProperty;
430
+ for (var key in src) if (own.call(src, key)) obj[key] = src[key];
431
+ return obj;
432
+ }
433
+ }).call(this);
@@ -0,0 +1 @@
1
+ (function(){var err,once,xlfont,xfl;err=function(e){e==null&&(e={});return import$(new Error,import$({name:"lderror"},e))};once=function(f,q){q==null&&(q=[]);return function(){if(q.s===2){return Promise.resolve()}else if(q.s===1){return new Promise(function(res,rej){return q.push({res:res,rej:rej})})}return Promise.resolve(q.s=1).then(function(){return f()}).then(function(){q.s=2;return q.splice(0).map(function(it){return it.res()})})["catch"](function(e){q.s=0;q.splice(0).map(function(it){return it.rej(e)});return Promise.reject(e)})}};xlfont=function(opt){var ref$,that,this$=this;opt==null&&(opt={});this.opt=opt;this.sub={set:{},font:{}};this.cjkOnly=opt.cjkOnly||false;this.codemap={};this.otf={font:null,dirty:true};this.path=opt.path;this.name=opt.name||(ref$=this.path.replace(/\.[a-zA-Z0-9]+$/,"").split("/").filter(function(it){return it}))[ref$.length-1];this.style="normal";this.ext=opt.ext||(/\.(ttf|otf|woff2|woff)$/.exec(this.path)||[])[1]||"";this.format=(that=this.ext.toLowerCase())?that==="ttf"?"truetype":that==="otf"?"truetype":that:"";if(this.format){this.format="format('"+this.format+"')"}this.className="xfl-"+(this.name||"").replace(/\s+/g,"_")+"-"+Math.random().toString(36).substring(2);this.isXl=!this.ext;this.css=[];this.init=once(function(){return this$._init()});this.init();return this};xlfont.prototype=import$(Object.create(Object.prototype),{_init:function(){var this$=this;return Promise.resolve().then(function(){if(!this$.isXl){this$.css=[{content:'@font-face {\n font-family: "'+this$.name+'";\n src: url("'+this$.path+'") '+this$.format+";\n}\n."+this$.className+' { font-family: "'+this$.name+'"; }'}];return xfl.update()}else{return new Promise(function(res,rej){var xhr;xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}(xhr.responseText||"").split("\n").map(function(d,i){return d.split(" ").map(function(e,j){return this$.codemap[e]=i+1})});return res()});xhr.open("GET",this$.path+"/charmap.txt");return xhr.send()})}})},_fetch:function(f,dofetch){var this$=this;f==null&&(f={});dofetch==null&&(dofetch=false);if(!dofetch){if(!f.url){if(this.isXl){f.url=this.path+"/"+f.key+".woff2";f.type="woff2"}else{f.url=this.path;f.type=this.ext.toLowerCase()}}return Promise.resolve(f)}if(f.blob){return Promise.resolve(f)}if(!f.proxy){f.proxy=proxise(function(f){var p;if(f.running){return}f.running=true;p=new Promise(function(res,rej){var xhr;if(f.blob){return res(f)}xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}this$.otf.dirty=true;f.url=URL.createObjectURL(xhr.response);f.blob=xhr.response;f.type=this$.ext.toLowerCase()||"ttf";return res(f)});if(this$.isXl){xhr.open("GET",this$.path+"/"+f.key+".ttf")}else{xhr.open("GET",this$.path)}xhr.responseType="blob";return xhr.send()});return p["finally"](function(){return f.running=false})})}return f.proxy(f)},fetchAll:function(){var k,f,this$=this;if(this.isXl){return Promise.all(function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this).map(function(it){return this$._fetch(it,true)}))}else{return this._fetch(this.sub.font[0],true)}},fetch:function(list,dofetch){var ps,this$=this;list==null&&(list=[]);dofetch==null&&(dofetch=false);if(!this.isXl){if(this.sub.font[0].blob){return Promise.resolve()}list=[0]}ps=Array.from(new Set(list.map(function(it){return it}))).filter(function(it){return!this$.sub.font[it]}).map(function(it){var f;this$.sub.font[it]=f={key:it};return this$._fetch(f,dofetch)});return Promise.all(ps).then(function(subfonts){var css,k,ref$,f,i$,len$;if(!subfonts.length){return}css="."+this$.className+' { font-family: "'+this$.name+'"; }';for(k in ref$=this$.sub.font){f=ref$[k]}for(i$=0,len$=subfonts.length;i$<len$;++i$){f=subfonts[i$];css+='@font-face {\n font-family: "'+this$.name+'";\n src: url("'+f.url+"\") format('"+f.type+"');\n}"}return this$.css.push({content:css})})},getotf:function(){var this$=this;if(!(typeof opentype!="undefined"&&opentype!==null)){return Promise.reject(err({id:1022,message:"[@plotdb/xfl] need opentype.js to merge subfonts"}))}if(!this.otf.dirty){return Promise.resolve(this.otf.font)}return Promise.resolve().then(function(){if(!this$.isXl){return this$.fetch()}else{return this$.fetchAll()}}).then(function(){var ps,k,f;ps=function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this$).map(function(f){if(f.otf){return Promise.resolve(f)}else{return opentype.load(f.url).then(function(it){f.otf=it;return f})}});return Promise.all(ps)}).then(function(list){var glyphs,ref$,ref1$;list==null&&(list=[]);if(list.length===1){return list[0].otf}glyphs=list.map(function(f){var glyphs,i$,to$,i,results$=[];glyphs=f.otf.glyphs;for(i$=1,to$=glyphs.length;i$<=to$;++i$){i=i$;results$.push(glyphs.glyphs[i])}return results$}).reduce(function(a,b){return a.concat(b)},[]).filter(function(it){return it});this$.otf.font=new opentype.Font((ref1$={familyName:this$.name,styleName:this$.style||"normal",glyphs:glyphs},ref1$.unitsPerEm=(ref$=list[0].otf).unitsPerEm,ref1$.ascender=ref$.ascender,ref1$.descender=ref$.descender,ref1$));this$.otf.font.kerningPairs={};return this$.otf.font})},sync:function(txt){var ref$,misschar,missset,this$=this;txt==null&&(txt="");if(!this.isXl){xfl.update();return Promise.resolve()}ref$=[{},{}],misschar=ref$[0],missset=ref$[1];return Promise.resolve().then(function(){var i$,to$,i,code,setIdx,k,list,res$;for(i$=0,to$=txt.length;i$<to$;++i$){i=i$;code=txt.charCodeAt(i);if(this$.cjkOnly&&!xfl.isCJK(code)){continue}setIdx=this$.codemap[code.toString(16)];if(!setIdx){misschar[txt[i]]=true}else if(!this$.sub.set[setIdx]){this$.sub.set[setIdx]=missset[setIdx]=true}}misschar=function(){var results$=[];for(k in misschar){results$.push(k)}return results$}().filter(function(it){return it.trim()});if(misschar.length){console.log("[@plotdb/xfl] sync xl-font with following chars unsupported: "+misschar.join(""))}res$=[];for(k in missset){res$.push(k)}list=res$;if(list.length){return this$.fetch(list)}}).then(function(){return xfl.update()})}});xfl={range:{CJK:[[12352,12543],[13312,19903],[19968,40959],[63744,64255],[65382,65439],[12593,55197]]},fonts:{},running:{},isCJK:function(code){return this.range.CJK.filter(function(it){return code>=it[0]&&code<=it[1]}).length},proxy:{},update:function(){var css,k,ref$,v,node;css="";for(k in ref$=this.fonts){v=ref$[k];(v.css||[]).filter(fn$).map(fn1$)}if(css){node=document.createElement("style");node.textContent=css;node.setAttribute("type","text/css");return document.body.appendChild(node)}function fn$(it){return!it.rendered}function fn1$(it){it.rendered=true;return css=css+it.content}},_load:function(opt){var path,this$=this;opt==null&&(opt={});path=opt.path;if(this.running[path]){return}this.running[path]=true;return Promise.resolve().then(function(){var fobj;this$.fonts[path]=fobj=new xlfont(opt);return fobj.init()})["finally"](function(){return this$.running[path]=false}).then(function(){this$.proxy[path].resolve(this$.fonts[path]);return this$.fonts[path]})["catch"](function(it){this$.proxy[path].reject(it);return Promise.reject(it)})},load:function(opt){var this$=this;opt==null&&(opt={});return new Promise(function(res,rej){var path,that,ref$;if(!(path=opt.path)){return rej(err({id:400}))}path=path.replace(/\/$/,"");if(that=this$.fonts[path]){return res(that)}if(!this$.proxy[path]){this$.proxy[path]=proxise(function(it){return this$._load(it)})}return this$.proxy[path]((ref$=import$({},opt),ref$.path=path,ref$)).then(function(it){return res(it)})["catch"](function(it){return rej(it)})})}};if(typeof module!="undefined"&&module!==null){module.exports=xfl}else if(typeof window!="undefined"&&window!==null){window.xfl=xfl}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
package/dist/xfl.js CHANGED
@@ -1,12 +1,41 @@
1
1
  (function(){
2
- var err, xfont, xfl;
2
+ var err, once, xlfont, xfl;
3
3
  err = function(e){
4
4
  e == null && (e = {});
5
5
  return import$(new Error(), import$({
6
6
  name: 'lderror'
7
7
  }, e));
8
8
  };
9
- xfont = function(opt){
9
+ once = function(f, q){
10
+ q == null && (q = []);
11
+ return function(){
12
+ if (q.s === 2) {
13
+ return Promise.resolve();
14
+ } else if (q.s === 1) {
15
+ return new Promise(function(res, rej){
16
+ return q.push({
17
+ res: res,
18
+ rej: rej
19
+ });
20
+ });
21
+ }
22
+ return Promise.resolve(q.s = 1).then(function(){
23
+ return f();
24
+ }).then(function(){
25
+ q.s = 2;
26
+ return q.splice(0).map(function(it){
27
+ return it.res();
28
+ });
29
+ })['catch'](function(e){
30
+ q.s = 0;
31
+ q.splice(0).map(function(it){
32
+ return it.rej(e);
33
+ });
34
+ return Promise.reject(e);
35
+ });
36
+ };
37
+ };
38
+ xlfont = function(opt){
10
39
  var ref$, that, this$ = this;
11
40
  opt == null && (opt = {});
12
41
  this.opt = opt;
@@ -35,13 +64,13 @@
35
64
  this.className = "xfl-" + (this.name || '').replace(/\s+/g, '_') + "-" + Math.random().toString(36).substring(2);
36
65
  this.isXl = !this.ext;
37
66
  this.css = [];
38
- this.init = proxise.once(function(){
67
+ this.init = once(function(){
39
68
  return this$._init();
40
69
  });
41
70
  this.init();
42
71
  return this;
43
72
  };
44
- xfont.prototype = import$(Object.create(Object.prototype), {
73
+ xlfont.prototype = import$(Object.create(Object.prototype), {
45
74
  _init: function(){
46
75
  var this$ = this;
47
76
  return Promise.resolve().then(function(){
@@ -352,7 +381,7 @@
352
381
  this.running[path] = true;
353
382
  return Promise.resolve().then(function(){
354
383
  var fobj;
355
- this$.fonts[path] = fobj = new xfont(opt);
384
+ this$.fonts[path] = fobj = new xlfont(opt);
356
385
  return fobj.init();
357
386
  })['finally'](function(){
358
387
  return this$.running[path] = false;
package/dist/xfl.min.js CHANGED
@@ -1 +1 @@
1
- (function(){var err,xfont,xfl;err=function(e){e==null&&(e={});return import$(new Error,import$({name:"lderror"},e))};xfont=function(opt){var ref$,that,this$=this;opt==null&&(opt={});this.opt=opt;this.sub={set:{},font:{}};this.cjkOnly=opt.cjkOnly||false;this.codemap={};this.otf={font:null,dirty:true};this.path=opt.path;this.name=opt.name||(ref$=this.path.replace(/\.[a-zA-Z0-9]+$/,"").split("/").filter(function(it){return it}))[ref$.length-1];this.style="normal";this.ext=opt.ext||(/\.(ttf|otf|woff2|woff)$/.exec(this.path)||[])[1]||"";this.format=(that=this.ext.toLowerCase())?that==="ttf"?"truetype":that==="otf"?"truetype":that:"";if(this.format){this.format="format('"+this.format+"')"}this.className="xfl-"+(this.name||"").replace(/\s+/g,"_")+"-"+Math.random().toString(36).substring(2);this.isXl=!this.ext;this.css=[];this.init=proxise.once(function(){return this$._init()});this.init();return this};xfont.prototype=import$(Object.create(Object.prototype),{_init:function(){var this$=this;return Promise.resolve().then(function(){if(!this$.isXl){this$.css=[{content:'@font-face {\n font-family: "'+this$.name+'";\n src: url("'+this$.path+'") '+this$.format+";\n}\n."+this$.className+' { font-family: "'+this$.name+'"; }'}];return xfl.update()}else{return new Promise(function(res,rej){var xhr;xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}(xhr.responseText||"").split("\n").map(function(d,i){return d.split(" ").map(function(e,j){return this$.codemap[e]=i+1})});return res()});xhr.open("GET",this$.path+"/charmap.txt");return xhr.send()})}})},_fetch:function(f,dofetch){var this$=this;f==null&&(f={});dofetch==null&&(dofetch=false);if(!dofetch){if(!f.url){if(this.isXl){f.url=this.path+"/"+f.key+".woff2";f.type="woff2"}else{f.url=this.path;f.type=this.ext.toLowerCase()}}return Promise.resolve(f)}if(f.blob){return Promise.resolve(f)}if(!f.proxy){f.proxy=proxise(function(f){var p;if(f.running){return}f.running=true;p=new Promise(function(res,rej){var xhr;if(f.blob){return res(f)}xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}this$.otf.dirty=true;f.url=URL.createObjectURL(xhr.response);f.blob=xhr.response;f.type=this$.ext.toLowerCase()||"ttf";return res(f)});if(this$.isXl){xhr.open("GET",this$.path+"/"+f.key+".ttf")}else{xhr.open("GET",this$.path)}xhr.responseType="blob";return xhr.send()});return p["finally"](function(){return f.running=false})})}return f.proxy(f)},fetchAll:function(){var k,f,this$=this;if(this.isXl){return Promise.all(function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this).map(function(it){return this$._fetch(it,true)}))}else{return this._fetch(this.sub.font[0],true)}},fetch:function(list,dofetch){var ps,this$=this;list==null&&(list=[]);dofetch==null&&(dofetch=false);if(!this.isXl){if(this.sub.font[0].blob){return Promise.resolve()}list=[0]}ps=Array.from(new Set(list.map(function(it){return it}))).filter(function(it){return!this$.sub.font[it]}).map(function(it){var f;this$.sub.font[it]=f={key:it};return this$._fetch(f,dofetch)});return Promise.all(ps).then(function(subfonts){var css,k,ref$,f,i$,len$;if(!subfonts.length){return}css="."+this$.className+' { font-family: "'+this$.name+'"; }';for(k in ref$=this$.sub.font){f=ref$[k]}for(i$=0,len$=subfonts.length;i$<len$;++i$){f=subfonts[i$];css+='@font-face {\n font-family: "'+this$.name+'";\n src: url("'+f.url+"\") format('"+f.type+"');\n}"}return this$.css.push({content:css})})},getotf:function(){var this$=this;if(!(typeof opentype!="undefined"&&opentype!==null)){return Promise.reject(err({id:1022,message:"[@plotdb/xfl] need opentype.js to merge subfonts"}))}if(!this.otf.dirty){return Promise.resolve(this.otf.font)}return Promise.resolve().then(function(){if(!this$.isXl){return this$.fetch()}else{return this$.fetchAll()}}).then(function(){var ps,k,f;ps=function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this$).map(function(f){if(f.otf){return Promise.resolve(f)}else{return opentype.load(f.url).then(function(it){f.otf=it;return f})}});return Promise.all(ps)}).then(function(list){var glyphs,ref$,ref1$;list==null&&(list=[]);if(list.length===1){return list[0].otf}glyphs=list.map(function(f){var glyphs,i$,to$,i,results$=[];glyphs=f.otf.glyphs;for(i$=1,to$=glyphs.length;i$<=to$;++i$){i=i$;results$.push(glyphs.glyphs[i])}return results$}).reduce(function(a,b){return a.concat(b)},[]).filter(function(it){return it});this$.otf.font=new opentype.Font((ref1$={familyName:this$.name,styleName:this$.style||"normal",glyphs:glyphs},ref1$.unitsPerEm=(ref$=list[0].otf).unitsPerEm,ref1$.ascender=ref$.ascender,ref1$.descender=ref$.descender,ref1$));this$.otf.font.kerningPairs={};return this$.otf.font})},sync:function(txt){var ref$,misschar,missset,this$=this;txt==null&&(txt="");if(!this.isXl){xfl.update();return Promise.resolve()}ref$=[{},{}],misschar=ref$[0],missset=ref$[1];return Promise.resolve().then(function(){var i$,to$,i,code,setIdx,k,list,res$;for(i$=0,to$=txt.length;i$<to$;++i$){i=i$;code=txt.charCodeAt(i);if(this$.cjkOnly&&!xfl.isCJK(code)){continue}setIdx=this$.codemap[code.toString(16)];if(!setIdx){misschar[txt[i]]=true}else if(!this$.sub.set[setIdx]){this$.sub.set[setIdx]=missset[setIdx]=true}}misschar=function(){var results$=[];for(k in misschar){results$.push(k)}return results$}().filter(function(it){return it.trim()});if(misschar.length){console.log("[@plotdb/xfl] sync xl-font with following chars unsupported: "+misschar.join(""))}res$=[];for(k in missset){res$.push(k)}list=res$;if(list.length){return this$.fetch(list)}}).then(function(){return xfl.update()})}});xfl={range:{CJK:[[12352,12543],[13312,19903],[19968,40959],[63744,64255],[65382,65439],[12593,55197]]},fonts:{},running:{},isCJK:function(code){return this.range.CJK.filter(function(it){return code>=it[0]&&code<=it[1]}).length},proxy:{},update:function(){var css,k,ref$,v,node;css="";for(k in ref$=this.fonts){v=ref$[k];(v.css||[]).filter(fn$).map(fn1$)}if(css){node=document.createElement("style");node.textContent=css;node.setAttribute("type","text/css");return document.body.appendChild(node)}function fn$(it){return!it.rendered}function fn1$(it){it.rendered=true;return css=css+it.content}},_load:function(opt){var path,this$=this;opt==null&&(opt={});path=opt.path;if(this.running[path]){return}this.running[path]=true;return Promise.resolve().then(function(){var fobj;this$.fonts[path]=fobj=new xfont(opt);return fobj.init()})["finally"](function(){return this$.running[path]=false}).then(function(){this$.proxy[path].resolve(this$.fonts[path]);return this$.fonts[path]})["catch"](function(it){this$.proxy[path].reject(it);return Promise.reject(it)})},load:function(opt){var this$=this;opt==null&&(opt={});return new Promise(function(res,rej){var path,that,ref$;if(!(path=opt.path)){return rej(err({id:400}))}path=path.replace(/\/$/,"");if(that=this$.fonts[path]){return res(that)}if(!this$.proxy[path]){this$.proxy[path]=proxise(function(it){return this$._load(it)})}return this$.proxy[path]((ref$=import$({},opt),ref$.path=path,ref$)).then(function(it){return res(it)})["catch"](function(it){return rej(it)})})}};if(typeof module!="undefined"&&module!==null){module.exports=xfl}else if(typeof window!="undefined"&&window!==null){window.xfl=xfl}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
1
+ (function(){var err,once,xlfont,xfl;err=function(e){e==null&&(e={});return import$(new Error,import$({name:"lderror"},e))};once=function(f,q){q==null&&(q=[]);return function(){if(q.s===2){return Promise.resolve()}else if(q.s===1){return new Promise(function(res,rej){return q.push({res:res,rej:rej})})}return Promise.resolve(q.s=1).then(function(){return f()}).then(function(){q.s=2;return q.splice(0).map(function(it){return it.res()})})["catch"](function(e){q.s=0;q.splice(0).map(function(it){return it.rej(e)});return Promise.reject(e)})}};xlfont=function(opt){var ref$,that,this$=this;opt==null&&(opt={});this.opt=opt;this.sub={set:{},font:{}};this.cjkOnly=opt.cjkOnly||false;this.codemap={};this.otf={font:null,dirty:true};this.path=opt.path;this.name=opt.name||(ref$=this.path.replace(/\.[a-zA-Z0-9]+$/,"").split("/").filter(function(it){return it}))[ref$.length-1];this.style="normal";this.ext=opt.ext||(/\.(ttf|otf|woff2|woff)$/.exec(this.path)||[])[1]||"";this.format=(that=this.ext.toLowerCase())?that==="ttf"?"truetype":that==="otf"?"truetype":that:"";if(this.format){this.format="format('"+this.format+"')"}this.className="xfl-"+(this.name||"").replace(/\s+/g,"_")+"-"+Math.random().toString(36).substring(2);this.isXl=!this.ext;this.css=[];this.init=once(function(){return this$._init()});this.init();return this};xlfont.prototype=import$(Object.create(Object.prototype),{_init:function(){var this$=this;return Promise.resolve().then(function(){if(!this$.isXl){this$.css=[{content:'@font-face {\n font-family: "'+this$.name+'";\n src: url("'+this$.path+'") '+this$.format+";\n}\n."+this$.className+' { font-family: "'+this$.name+'"; }'}];return xfl.update()}else{return new Promise(function(res,rej){var xhr;xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}(xhr.responseText||"").split("\n").map(function(d,i){return d.split(" ").map(function(e,j){return this$.codemap[e]=i+1})});return res()});xhr.open("GET",this$.path+"/charmap.txt");return xhr.send()})}})},_fetch:function(f,dofetch){var this$=this;f==null&&(f={});dofetch==null&&(dofetch=false);if(!dofetch){if(!f.url){if(this.isXl){f.url=this.path+"/"+f.key+".woff2";f.type="woff2"}else{f.url=this.path;f.type=this.ext.toLowerCase()}}return Promise.resolve(f)}if(f.blob){return Promise.resolve(f)}if(!f.proxy){f.proxy=proxise(function(f){var p;if(f.running){return}f.running=true;p=new Promise(function(res,rej){var xhr;if(f.blob){return res(f)}xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState!==XMLHttpRequest.DONE){return}if(xhr.status!==200){return rej(err({code:xhr.status,message:xhr.responseText}))}this$.otf.dirty=true;f.url=URL.createObjectURL(xhr.response);f.blob=xhr.response;f.type=this$.ext.toLowerCase()||"ttf";return res(f)});if(this$.isXl){xhr.open("GET",this$.path+"/"+f.key+".ttf")}else{xhr.open("GET",this$.path)}xhr.responseType="blob";return xhr.send()});return p["finally"](function(){return f.running=false})})}return f.proxy(f)},fetchAll:function(){var k,f,this$=this;if(this.isXl){return Promise.all(function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this).map(function(it){return this$._fetch(it,true)}))}else{return this._fetch(this.sub.font[0],true)}},fetch:function(list,dofetch){var ps,this$=this;list==null&&(list=[]);dofetch==null&&(dofetch=false);if(!this.isXl){if(this.sub.font[0].blob){return Promise.resolve()}list=[0]}ps=Array.from(new Set(list.map(function(it){return it}))).filter(function(it){return!this$.sub.font[it]}).map(function(it){var f;this$.sub.font[it]=f={key:it};return this$._fetch(f,dofetch)});return Promise.all(ps).then(function(subfonts){var css,k,ref$,f,i$,len$;if(!subfonts.length){return}css="."+this$.className+' { font-family: "'+this$.name+'"; }';for(k in ref$=this$.sub.font){f=ref$[k]}for(i$=0,len$=subfonts.length;i$<len$;++i$){f=subfonts[i$];css+='@font-face {\n font-family: "'+this$.name+'";\n src: url("'+f.url+"\") format('"+f.type+"');\n}"}return this$.css.push({content:css})})},getotf:function(){var this$=this;if(!(typeof opentype!="undefined"&&opentype!==null)){return Promise.reject(err({id:1022,message:"[@plotdb/xfl] need opentype.js to merge subfonts"}))}if(!this.otf.dirty){return Promise.resolve(this.otf.font)}return Promise.resolve().then(function(){if(!this$.isXl){return this$.fetch()}else{return this$.fetchAll()}}).then(function(){var ps,k,f;ps=function(){var ref$,results$=[];for(k in ref$=this.sub.font){f=ref$[k];results$.push(f)}return results$}.call(this$).map(function(f){if(f.otf){return Promise.resolve(f)}else{return opentype.load(f.url).then(function(it){f.otf=it;return f})}});return Promise.all(ps)}).then(function(list){var glyphs,ref$,ref1$;list==null&&(list=[]);if(list.length===1){return list[0].otf}glyphs=list.map(function(f){var glyphs,i$,to$,i,results$=[];glyphs=f.otf.glyphs;for(i$=1,to$=glyphs.length;i$<=to$;++i$){i=i$;results$.push(glyphs.glyphs[i])}return results$}).reduce(function(a,b){return a.concat(b)},[]).filter(function(it){return it});this$.otf.font=new opentype.Font((ref1$={familyName:this$.name,styleName:this$.style||"normal",glyphs:glyphs},ref1$.unitsPerEm=(ref$=list[0].otf).unitsPerEm,ref1$.ascender=ref$.ascender,ref1$.descender=ref$.descender,ref1$));this$.otf.font.kerningPairs={};return this$.otf.font})},sync:function(txt){var ref$,misschar,missset,this$=this;txt==null&&(txt="");if(!this.isXl){xfl.update();return Promise.resolve()}ref$=[{},{}],misschar=ref$[0],missset=ref$[1];return Promise.resolve().then(function(){var i$,to$,i,code,setIdx,k,list,res$;for(i$=0,to$=txt.length;i$<to$;++i$){i=i$;code=txt.charCodeAt(i);if(this$.cjkOnly&&!xfl.isCJK(code)){continue}setIdx=this$.codemap[code.toString(16)];if(!setIdx){misschar[txt[i]]=true}else if(!this$.sub.set[setIdx]){this$.sub.set[setIdx]=missset[setIdx]=true}}misschar=function(){var results$=[];for(k in misschar){results$.push(k)}return results$}().filter(function(it){return it.trim()});if(misschar.length){console.log("[@plotdb/xfl] sync xl-font with following chars unsupported: "+misschar.join(""))}res$=[];for(k in missset){res$.push(k)}list=res$;if(list.length){return this$.fetch(list)}}).then(function(){return xfl.update()})}});xfl={range:{CJK:[[12352,12543],[13312,19903],[19968,40959],[63744,64255],[65382,65439],[12593,55197]]},fonts:{},running:{},isCJK:function(code){return this.range.CJK.filter(function(it){return code>=it[0]&&code<=it[1]}).length},proxy:{},update:function(){var css,k,ref$,v,node;css="";for(k in ref$=this.fonts){v=ref$[k];(v.css||[]).filter(fn$).map(fn1$)}if(css){node=document.createElement("style");node.textContent=css;node.setAttribute("type","text/css");return document.body.appendChild(node)}function fn$(it){return!it.rendered}function fn1$(it){it.rendered=true;return css=css+it.content}},_load:function(opt){var path,this$=this;opt==null&&(opt={});path=opt.path;if(this.running[path]){return}this.running[path]=true;return Promise.resolve().then(function(){var fobj;this$.fonts[path]=fobj=new xlfont(opt);return fobj.init()})["finally"](function(){return this$.running[path]=false}).then(function(){this$.proxy[path].resolve(this$.fonts[path]);return this$.fonts[path]})["catch"](function(it){this$.proxy[path].reject(it);return Promise.reject(it)})},load:function(opt){var this$=this;opt==null&&(opt={});return new Promise(function(res,rej){var path,that,ref$;if(!(path=opt.path)){return rej(err({id:400}))}path=path.replace(/\/$/,"");if(that=this$.fonts[path]){return res(that)}if(!this$.proxy[path]){this$.proxy[path]=proxise(function(it){return this$._load(it)})}return this$.proxy[path]((ref$=import$({},opt),ref$.path=path,ref$)).then(function(it){return res(it)})["catch"](function(it){return rej(it)})})}};if(typeof module!="undefined"&&module!==null){module.exports=xfl}else if(typeof window!="undefined"&&window!==null){window.xfl=xfl}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@xlfont/load",
4
4
  "license": "MIT",
5
5
  "description": "XL font generator and loader",
6
- "version": "1.0.10",
6
+ "version": "1.0.11",
7
7
  "main": "dist/xfl.js",
8
8
  "homepage": "https://github.com/xlfont/load",
9
9
  "files": [
package/tool/README.md ADDED
@@ -0,0 +1,3 @@
1
+ use this to prevent OOM when running `npx xfl` ( or build.ls ):
2
+
3
+ export NODE_OPTIONS=--max_old_space_size=4096