1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | (function (global, factory) {
|
8 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
9 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
10 | (global = global || self, factory((global.ssw = global.ssw || {}, global.ssw.ttf = {})));
|
11 | }(this, (function (exports) { 'use strict';
|
12 |
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | const cssAppend = function (dir = '') {
|
21 | const id = "SgnwFontCss";
|
22 |
|
23 | if (!document.getElementById(id)) {
|
24 | const style = document.createElement('style');
|
25 | style.setAttribute("id", "SgnwFontCss");
|
26 | style.appendChild(document.createTextNode(`
|
27 | @font-face {
|
28 | font-family: "SuttonSignWritingLine";
|
29 | src:
|
30 | local('SuttonSignWritingLine'),
|
31 | ${dir ? `url('${dir}SuttonSignWritingLine.ttf') format('truetype'),` : ""}
|
32 | url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingLine.ttf') format('truetype');
|
33 | }
|
34 | @font-face {
|
35 | font-family: "SuttonSignWritingFill";
|
36 | src:
|
37 | local('SuttonSignWritingFill'),
|
38 | ${dir ? `url('${dir}SuttonSignWritingFill.ttf') format('truetype'),` : ""}
|
39 | url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingFill.ttf') format('truetype');
|
40 | }
|
41 | @font-face {
|
42 | font-family: "SuttonSignWritingOneD";
|
43 | src:
|
44 | local('SuttonSignWritingOneD'),
|
45 | ${dir ? `url('${dir}SuttonSignWritingOneD.ttf') format('truetype'),` : ""}
|
46 | url('https://cdn.jsdelivr.net/npm/@sutton-signwriting/font-ttf@1.0.0/font/SuttonSignWritingOneD.ttf') format('truetype');
|
47 | }
|
48 | `));
|
49 | document.head.appendChild(style);
|
50 | }
|
51 | };
|
52 |
|
53 | let sizes = {};
|
54 | const zoom = 2;
|
55 | const bound = 76 * zoom;
|
56 | const canvaser = document.createElement("canvas");
|
57 | canvaser.width = bound;
|
58 | canvaser.height = bound;
|
59 | const context = canvaser.getContext("2d");
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | const symbolSize = function (id) {
|
71 | if (id in sizes) {
|
72 | return [...sizes[id]];
|
73 | }
|
74 |
|
75 | context.clearRect(0, 0, bound, bound);
|
76 | context.font = 30 * zoom + "px 'SuttonSignWritingLine'";
|
77 | context.fillText(String.fromCodePoint(id + 0xF0000), 0, 0);
|
78 | const imgData = context.getImageData(0, 0, bound, bound).data;
|
79 | let w, h, i, s;
|
80 |
|
81 | wloop: for (w = bound - 1; w >= 0; w--) {
|
82 | for (h = 0; h < bound; h += 1) {
|
83 | for (s = 0; s < 4; s += 1) {
|
84 | i = w * 4 + h * 4 * bound + s;
|
85 |
|
86 | if (imgData[i]) {
|
87 | break wloop;
|
88 | }
|
89 | }
|
90 | }
|
91 | }
|
92 |
|
93 | var width = w;
|
94 |
|
95 | hloop: for (h = bound - 1; h >= 0; h--) {
|
96 | for (w = 0; w < width; w += 1) {
|
97 | for (s = 0; s < 4; s += 1) {
|
98 | i = w * 4 + h * 4 * bound + s;
|
99 |
|
100 | if (imgData[i]) {
|
101 | break hloop;
|
102 | }
|
103 | }
|
104 | }
|
105 | }
|
106 |
|
107 | var height = h + 1;
|
108 | width = Math.ceil(width / zoom);
|
109 | height = Math.ceil(height / zoom);
|
110 |
|
111 | if (14394 == id) {
|
112 | width = 19;
|
113 | }
|
114 |
|
115 | if ([10468, 10480, 10496, 10512, 10500, 10532, 10548, 10862, 10878, 10894, 11058, 11074, 11476, 11488, 11492, 11504, 11508, 11520, 10516, 10910, 10926, 11042, 11082, 10942].includes(id)) {
|
116 | width = 20;
|
117 | }
|
118 |
|
119 | if (31921 == id) {
|
120 | width = 22;
|
121 | }
|
122 |
|
123 | if (38460 == id) {
|
124 | width = 23;
|
125 | }
|
126 |
|
127 | if ([20164, 20212].includes(id)) {
|
128 | width = 25;
|
129 | }
|
130 |
|
131 | if (31894 == id) {
|
132 | width = 28;
|
133 | }
|
134 |
|
135 | if (46698 == id) {
|
136 | width = 29;
|
137 | }
|
138 |
|
139 | if (29606 == id) {
|
140 | width = 30;
|
141 | }
|
142 |
|
143 | if (44855 == id) {
|
144 | width = 40;
|
145 | }
|
146 |
|
147 | if (32667 == id) {
|
148 | width = 50;
|
149 | }
|
150 |
|
151 | if ([11088, 11474, 11490, 11506].includes(id)) {
|
152 | height = 20;
|
153 | }
|
154 |
|
155 | if (6285 == id) {
|
156 | height = 21;
|
157 | }
|
158 |
|
159 | if (40804 == id) {
|
160 | height = 31;
|
161 | }
|
162 |
|
163 | if (41475 == id) {
|
164 | height = 36;
|
165 | }
|
166 |
|
167 |
|
168 |
|
169 | if (width == 0 && height == 0) {
|
170 | const sizefix = {
|
171 | 9: [15, 30],
|
172 | 10: [21, 30],
|
173 | 11: [30, 15],
|
174 | 12: [30, 21],
|
175 | 13: [15, 30],
|
176 | 14: [21, 30]
|
177 | };
|
178 |
|
179 | if (id in sizefix) {
|
180 | width = sizefix[id][0];
|
181 | height = sizefix[id][1];
|
182 | }
|
183 | }
|
184 |
|
185 | if (width == 0 && height == 0) {
|
186 | return undefined;
|
187 | }
|
188 |
|
189 | sizes[id] = [width, height];
|
190 | return [width, height];
|
191 | };
|
192 |
|
193 | |
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | const symbolLine = function (id) {
|
203 | return String.fromCodePoint(id + 0xF0000);
|
204 | };
|
205 | |
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | const symbolFill = function (id) {
|
217 | return String.fromCodePoint(id + 0x100000);
|
218 | };
|
219 | |
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | const symbolText = function (id) {
|
232 | return ` <text class="sym-fill" fill="white" style="pointer-events:none;font-family:'SuttonSignWritingFill';font-size:30px;">${symbolFill(id)}</text>
|
233 | <text class="sym-line" fill="black" style="pointer-events:none;font-family:'SuttonSignWritingLine';font-size:30px;">${symbolLine(id)}</text>`;
|
234 | };
|
235 |
|
236 | |
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | const cssLoaded = function (callback) {
|
249 | let lineReady = false;
|
250 | let fillReady = false;
|
251 | cssLoadedLine(() => {
|
252 | lineReady = true;
|
253 | });
|
254 | cssLoadedFill(() => {
|
255 | fillReady = true;
|
256 | });
|
257 | const cssCheck = setInterval(function () {
|
258 | if (lineReady && fillReady) {
|
259 | clearInterval(cssCheck);
|
260 | callback();
|
261 | }
|
262 | }, 100);
|
263 | };
|
264 | |
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | const cssLoadedLine = function (callback) {
|
278 | if (!symbolSize(1)) {
|
279 | const cssCheck = setInterval(function () {
|
280 | if (symbolSize(1)) {
|
281 | clearInterval(cssCheck);
|
282 | callback();
|
283 | }
|
284 | }, 100);
|
285 | } else {
|
286 | callback();
|
287 | }
|
288 | };
|
289 | |
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | const cssLoadedFill = function (callback) {
|
303 | const fillReady = function () {
|
304 | const canvaser = document.createElement("canvas");
|
305 | canvaser.width = 15;
|
306 | canvaser.height = 30;
|
307 | const context = canvaser.getContext("2d");
|
308 | context.font = "30px 'SuttonSignWritingFill'";
|
309 | context.fillText(symbolFill(1), 0, 0);
|
310 | const imgData = context.getImageData(0, 0, 15, 30).data;
|
311 | return !imgData.every(item => item === 0);
|
312 | };
|
313 |
|
314 | if (!fillReady()) {
|
315 | const cssCheck = setInterval(function () {
|
316 | if (fillReady()) {
|
317 | clearInterval(cssCheck);
|
318 | callback();
|
319 | }
|
320 | }, 100);
|
321 | } else {
|
322 | callback();
|
323 | }
|
324 | };
|
325 |
|
326 | |
327 |
|
328 |
|
329 |
|
330 | var index = Object.freeze({
|
331 | __proto__: null,
|
332 | cssAppend: cssAppend,
|
333 | cssLoaded: cssLoaded,
|
334 | cssLoadedLine: cssLoadedLine,
|
335 | cssLoadedFill: cssLoadedFill,
|
336 | symbolSize: symbolSize,
|
337 | symbolLine: symbolLine,
|
338 | symbolFill: symbolFill,
|
339 | symbolText: symbolText
|
340 | });
|
341 |
|
342 | |
343 |
|
344 |
|
345 |
|
346 |
|
347 | |
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 | const num2swu = num => String.fromCodePoint(0x1D80C + parseInt(num) - 250);
|
360 | |
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 | const coord2swu = coord => coord.map(num => num2swu(num)).join('');
|
373 | |
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 | const swu2code = swuSym => parseInt(swuSym.codePointAt(0));
|
386 | |
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 | const swu2id = swuSym => swu2code(swuSym) - 0x40000;
|
399 | |
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | const key2id = key => 1 + (parseInt(key.slice(1, 4), 16) - 256) * 96 + parseInt(key.slice(4, 5), 16) * 16 + parseInt(key.slice(5, 6), 16);
|
412 |
|
413 |
|
414 |
|
415 | |
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 | const symbolSize$1 = function (fsw) {
|
426 | return symbolSize(key2id(fsw));
|
427 | };
|
428 |
|
429 | |
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 | const symbolLine$1 = function (fsw) {
|
440 | return symbolLine(key2id(fsw));
|
441 | };
|
442 | |
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 | const symbolFill$1 = function (fsw) {
|
454 | return symbolFill(key2id(fsw));
|
455 | };
|
456 | |
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 | const symbolText$1 = function (fsw) {
|
469 | return symbolText(key2id(fsw));
|
470 | };
|
471 |
|
472 | |
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 | |
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | let re = {
|
486 | 'colorize': 'C',
|
487 | 'colorhex': '(?:[0-9a-fA-F]{3}){1,2}',
|
488 | 'colorname': '[a-zA-Z]+',
|
489 | 'padding': 'P[0-9]{2}',
|
490 | 'zoom': 'Z(?:[0-9]+(?:\\.[0-9]+)?|x)',
|
491 | 'zoomsym': 'Z[0-9]{2},[0-9]+(?:\\.[0-9]+)?(?:,[0-9]{3}x[0-9]{3})?',
|
492 | 'classbase': '-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}',
|
493 | 'id': '[a-zA-Z][_a-zA-Z0-9-]{0,100}'
|
494 | };
|
495 | re.colorbase = `(?:${re.colorhex}|${re.colorname})`;
|
496 | re.color = `_${re.colorbase}_`;
|
497 | re.colors = `_${re.colorbase}(?:,${re.colorbase})?_`;
|
498 | re.background = `G${re.color}`;
|
499 | re.detail = `D${re.colors}`;
|
500 | re.detailsym = `D[0-9]{2}${re.colors}`;
|
501 | re.classes = `${re.classbase}(?: ${re.classbase})*`;
|
502 | re.full = `-(${re.colorize})?(${re.padding})?(${re.background})?(${re.detail})?(${re.zoom})?(?:-((?:${re.detailsym})*)((?:${re.zoomsym})*))?(?:-(${re.classes})?!(?:(${re.id})!)?)?`;
|
503 |
|
504 | const prefixColor = color => {
|
505 | const regex = new RegExp(`^${re.colorhex}$`);
|
506 | return (regex.test(color) ? '#' : '') + color;
|
507 | };
|
508 | |
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 | const parse = styleString => {
|
526 | const regex = `^${re.full}`;
|
527 | const m = (typeof styleString === 'string' ? styleString.match(new RegExp(regex)) : []) || [];
|
528 | return {
|
529 | 'colorize': !m[1] ? undefined : !!m[1],
|
530 | 'padding': !m[2] ? undefined : parseInt(m[2].slice(1)),
|
531 | 'background': !m[3] ? undefined : prefixColor(m[3].slice(2, -1)),
|
532 | 'detail': !m[4] ? undefined : m[4].slice(2, -1).split(',').map(prefixColor),
|
533 | 'zoom': !m[5] ? undefined : m[5] === 'Zx' ? 'x' : parseFloat(m[5].slice(1)),
|
534 | 'detailsym': !m[6] ? undefined : m[6].match(new RegExp(re.detailsym, 'g')).map(val => {
|
535 | const parts = val.split('_');
|
536 | const detail = parts[1].split(',').map(prefixColor);
|
537 | return {
|
538 | 'index': parseInt(parts[0].slice(1)),
|
539 | 'detail': detail
|
540 | };
|
541 | }),
|
542 | 'zoomsym': !m[7] ? undefined : m[7].match(new RegExp(re.zoomsym, 'g')).map(val => {
|
543 | const parts = val.split(',');
|
544 | return {
|
545 | 'index': parseInt(parts[0].slice(1)),
|
546 | 'zoom': parseFloat(parts[1]),
|
547 | 'offset': !parts[2] ? undefined : parts[2].split('x').map(val => parseInt(val) - 500)
|
548 | };
|
549 | }),
|
550 | 'classes': !m[8] ? undefined : m[8],
|
551 | 'id': !m[9] ? undefined : m[9]
|
552 | };
|
553 | };
|
554 |
|
555 |
|
556 |
|
557 | |
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 | |
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 | let re$1 = {
|
571 | 'symbol': 'S[123][0-9a-f]{2}[0-5][0-9a-f]',
|
572 | 'coord': '[0-9]{3}x[0-9]{3}',
|
573 | 'sort': 'A',
|
574 | 'box': '[BLMR]'
|
575 | };
|
576 | re$1.prefix = `(?:${re$1.sort}(?:${re$1.symbol})+)`;
|
577 | re$1.spatial = `${re$1.symbol}${re$1.coord}`;
|
578 | re$1.signbox = `${re$1.box}${re$1.coord}(?:${re$1.spatial})*`;
|
579 | re$1.sign = `${re$1.prefix}?${re$1.signbox}`;
|
580 | re$1.sortable = `${re$1.prefix}${re$1.signbox}`;
|
581 |
|
582 | |
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 | let re$1$1 = {
|
590 | 'colorize': 'C',
|
591 | 'colorhex': '(?:[0-9a-fA-F]{3}){1,2}',
|
592 | 'colorname': '[a-zA-Z]+',
|
593 | 'padding': 'P[0-9]{2}',
|
594 | 'zoom': 'Z(?:[0-9]+(?:\\.[0-9]+)?|x)',
|
595 | 'zoomsym': 'Z[0-9]{2},[0-9]+(?:\\.[0-9]+)?(?:,[0-9]{3}x[0-9]{3})?',
|
596 | 'classbase': '-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}',
|
597 | 'id': '[a-zA-Z][_a-zA-Z0-9-]{0,100}'
|
598 | };
|
599 | re$1$1.colorbase = `(?:${re$1$1.colorhex}|${re$1$1.colorname})`;
|
600 | re$1$1.color = `_${re$1$1.colorbase}_`;
|
601 | re$1$1.colors = `_${re$1$1.colorbase}(?:,${re$1$1.colorbase})?_`;
|
602 | re$1$1.background = `G${re$1$1.color}`;
|
603 | re$1$1.detail = `D${re$1$1.colors}`;
|
604 | re$1$1.detailsym = `D[0-9]{2}${re$1$1.colors}`;
|
605 | re$1$1.classes = `${re$1$1.classbase}(?: ${re$1$1.classbase})*`;
|
606 | re$1$1.full = `-(${re$1$1.colorize})?(${re$1$1.padding})?(${re$1$1.background})?(${re$1$1.detail})?(${re$1$1.zoom})?(?:-((?:${re$1$1.detailsym})*)((?:${re$1$1.zoomsym})*))?(?:-(${re$1$1.classes})?!(?:(${re$1$1.id})!)?)?`;
|
607 |
|
608 | |
609 |
|
610 |
|
611 |
|
612 | |
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 | const fsw2coord = fswCoord => fswCoord.split('x').map(num => parseInt(num));
|
625 |
|
626 | const parse$1 = {
|
627 | |
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 | symbol: fswSym => {
|
642 | const regex = `^(${re$1.symbol})(${re$1.coord})?(${re$1$1.full})?`;
|
643 | const symbol = typeof fswSym === 'string' ? fswSym.match(new RegExp(regex)) : undefined;
|
644 | return {
|
645 | 'symbol': symbol ? symbol[1] : undefined,
|
646 | 'coord': symbol && symbol[2] ? fsw2coord(symbol[2]) : undefined,
|
647 | 'style': symbol ? symbol[3] : undefined
|
648 | };
|
649 | },
|
650 |
|
651 | |
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 | sign: fswSign => {
|
685 | const regex = `^(${re$1.prefix})?(${re$1.signbox})(${re$1$1.full})?`;
|
686 | const sign = typeof fswSign === 'string' ? fswSign.match(new RegExp(regex)) : undefined;
|
687 |
|
688 | if (sign) {
|
689 | return {
|
690 | 'sequence': sign[1] ? sign[1].slice(1).match(/.{6}/g) : undefined,
|
691 | 'box': sign[2][0],
|
692 | 'max': fsw2coord(sign[2].slice(1, 8)),
|
693 | 'spatials': sign[2].length < 9 ? undefined : sign[2].slice(8).match(/(.{13})/g).map(m => {
|
694 | return {
|
695 | symbol: m.slice(0, 6),
|
696 | coord: [parseInt(m.slice(6, 9)), parseInt(m.slice(10, 13))]
|
697 | };
|
698 | }),
|
699 | 'style': sign[3]
|
700 | };
|
701 | } else {
|
702 | return {};
|
703 | }
|
704 | }
|
705 | };
|
706 | |
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 | const category = [0x100, 0x205, 0x2f7, 0x2ff, 0x36d, 0x37f, 0x387];
|
713 | |
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | const ranges = {
|
722 | 'all': [0x100, 0x38b],
|
723 | 'writing': [0x100, 0x37e],
|
724 | 'hand': [0x100, 0x204],
|
725 | 'movement': [0x205, 0x2f6],
|
726 | 'dynamic': [0x2f7, 0x2fe],
|
727 | 'head': [0x2ff, 0x36c],
|
728 | 'hcenter': [0x2ff, 0x36c],
|
729 | 'vcenter': [0x2ff, 0x375],
|
730 | 'trunk': [0x36d, 0x375],
|
731 | 'limb': [0x376, 0x37e],
|
732 | 'location': [0x37f, 0x386],
|
733 | 'punctuation': [0x387, 0x38b]
|
734 | };
|
735 |
|
736 | |
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 | const colors = ['#0000CC', '#CC0000', '#FF0099', '#006600', '#000000', '#884411', '#FF9900'];
|
743 | |
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 | const colorize = key => {
|
755 | const parsed = parse$1.symbol(key);
|
756 | let color = '#000000';
|
757 |
|
758 | if (parsed.symbol) {
|
759 | const dec = parseInt(parsed.symbol.slice(1, 4), 16);
|
760 | const index = category.findIndex(val => val > dec);
|
761 | color = colors[index < 0 ? 6 : index - 1];
|
762 | }
|
763 |
|
764 | return color;
|
765 | };
|
766 |
|
767 |
|
768 |
|
769 | |
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 | const symbolSvg = fswSym => {
|
786 | const parsed = parse$1.symbol(fswSym);
|
787 | const blank = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';
|
788 |
|
789 | if (parsed.symbol) {
|
790 | let size = symbolSize$1(parsed.symbol);
|
791 |
|
792 | if (size) {
|
793 | let styling = parse(parsed.style);
|
794 | let line;
|
795 | let symSvg = symbolText$1(parsed.symbol);
|
796 | symSvg = ` <g transform="translate(500,500)">
|
797 | ${symSvg}
|
798 | </g>`;
|
799 |
|
800 | if (styling.colorize) {
|
801 | line = colorize(parsed.symbol);
|
802 | } else if (styling.detail) {
|
803 | line = styling.detail[0];
|
804 | }
|
805 |
|
806 | if (line) {
|
807 | symSvg = symSvg.replace(/class="sym-line" fill="black"/, `class="sym-line" fill="${line}"`);
|
808 | }
|
809 |
|
810 | let fill = styling.detail && styling.detail[1];
|
811 |
|
812 | if (fill) {
|
813 | symSvg = symSvg.replace(/class="sym-fill" fill="white"/, `class="sym-fill" fill="${fill}"`);
|
814 | }
|
815 |
|
816 | let x1 = 500;
|
817 | let y1 = 500;
|
818 | let background = '';
|
819 |
|
820 | if (styling.padding) {
|
821 | x1 -= styling.padding;
|
822 | y1 -= styling.padding;
|
823 | size[0] += styling.padding * 2;
|
824 | size[1] += styling.padding * 2;
|
825 | }
|
826 |
|
827 | if (styling.background) {
|
828 | background = `\n <rect x="${x1}" y="${y1}" width="${size[0]}" height="${size[1]}" style="fill:${styling.background};" />`;
|
829 | }
|
830 |
|
831 | let sizing = '';
|
832 |
|
833 | if (styling.zoom != 'x') {
|
834 | sizing = ` width="${size[0] * (styling.zoom ? styling.zoom : 1)}" height="${size[1] * (styling.zoom ? styling.zoom : 1)}"`;
|
835 | }
|
836 |
|
837 | let classes = '';
|
838 |
|
839 | if (styling.classes) {
|
840 | classes = ` class="${styling.classes}"`;
|
841 | }
|
842 |
|
843 | let id = '';
|
844 |
|
845 | if (styling.id) {
|
846 | id = ` id="${styling.id}"`;
|
847 | }
|
848 |
|
849 | return `<svg${classes}${id} version="1.1" xmlns="http://www.w3.org/2000/svg"${sizing} viewBox="${x1} ${y1} ${size[0]} ${size[1]}">
|
850 | <text font-size="0">${fswSym}</text>${background}
|
851 | ${symSvg}
|
852 | </svg>`;
|
853 | }
|
854 | }
|
855 |
|
856 | return blank;
|
857 | };
|
858 |
|
859 | const symbolCanvas = function (fswSym) {
|
860 | const parsed = parse$1.symbol(fswSym);
|
861 |
|
862 | if (parsed.symbol) {
|
863 | let size = symbolSize$1(parsed.symbol);
|
864 |
|
865 | if (size) {
|
866 | const canvas = document.createElement('canvas');
|
867 | const context = canvas.getContext('2d');
|
868 | let styling = parse(parsed.style);
|
869 | let line = 'black';
|
870 |
|
871 | if (styling.colorize) {
|
872 | line = colorize(parsed.symbol);
|
873 | } else if (styling.detail) {
|
874 | line = styling.detail[0];
|
875 | }
|
876 |
|
877 | let fill = styling.detail && styling.detail[1] || 'white';
|
878 | let x1 = 500;
|
879 | let x2 = x1 + size[0];
|
880 | let y1 = 500;
|
881 | let y2 = y1 + size[1];
|
882 |
|
883 | if (styling.padding) {
|
884 | x1 -= styling.padding;
|
885 | y1 -= styling.padding;
|
886 | x2 += styling.padding;
|
887 | y2 += styling.padding;
|
888 | }
|
889 |
|
890 | let sizing = 1;
|
891 |
|
892 | if (styling.zoom != 'x') {
|
893 | sizing = styling.zoom;
|
894 | }
|
895 |
|
896 | let w = (x2 - x1) * sizing;
|
897 | let h = (y2 - y1) * sizing;
|
898 | canvas.width = w ? w : 1;
|
899 | canvas.height = h ? h : 1;
|
900 |
|
901 | if (styling.background) {
|
902 | context.rect(0, 0, w, h);
|
903 | context.fillStyle = styling.background;
|
904 | context.fill();
|
905 | }
|
906 |
|
907 | context.font = 30 * sizing + "px 'SuttonSignWritingFill'";
|
908 | context.fillStyle = fill;
|
909 | context.fillText(symbolFill$1(parsed.symbol), (500 - x1) * sizing, (500 - y1) * sizing);
|
910 | context.font = 30 * sizing + "px 'SuttonSignWritingLine'";
|
911 | context.fillStyle = line;
|
912 | context.fillText(symbolLine$1(parsed.symbol), (500 - x1) * sizing, (500 - y1) * sizing);
|
913 | return canvas;
|
914 | }
|
915 | }
|
916 | };
|
917 | |
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 | const symbolPng = fswSym => {
|
929 | const canvas = symbolCanvas(fswSym);
|
930 | const png = canvas.toDataURL("image/png");
|
931 | canvas.remove();
|
932 | return png;
|
933 | };
|
934 |
|
935 | const blank = null;
|
936 | |
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 | const symbolNormalize = fswSym => {
|
947 | const parsed = parse$1.symbol(fswSym);
|
948 |
|
949 | if (parsed.symbol) {
|
950 | let size = symbolSize$1(parsed.symbol);
|
951 |
|
952 | if (size) {
|
953 | return `${parsed.symbol}${500 - parseInt(size[0] / 2)}x${500 - parseInt(size[1] / 2)}${parsed.style || ''}`;
|
954 | }
|
955 | } else {
|
956 | return blank;
|
957 | }
|
958 | };
|
959 |
|
960 | |
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 | const signSvg = fswSign => {
|
989 | let parsed = parse$1.sign(fswSign);
|
990 | const blank = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';
|
991 |
|
992 | if (parsed.spatials) {
|
993 | let styling = parse(parsed.style);
|
994 |
|
995 | if (styling.detailsym) {
|
996 | styling.detailsym.forEach(sym => {
|
997 | if (parsed.spatials[sym.index - 1]) {
|
998 | parsed.spatials[sym.index - 1].detail = sym.detail;
|
999 | }
|
1000 | });
|
1001 | }
|
1002 |
|
1003 | let x1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[0]));
|
1004 | let y1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[1]));
|
1005 | let x2 = parsed.max[0];
|
1006 | let y2 = parsed.max[1];
|
1007 |
|
1008 | if (styling.zoomsym) {
|
1009 | styling.zoomsym.forEach(sym => {
|
1010 | if (parsed.spatials[sym.index - 1]) {
|
1011 | parsed.spatials[sym.index - 1].zoom = sym.zoom;
|
1012 |
|
1013 | if (sym.offset) {
|
1014 | parsed.spatials[sym.index - 1].coord[0] += sym.offset[0];
|
1015 | parsed.spatials[sym.index - 1].coord[1] += sym.offset[1];
|
1016 | }
|
1017 |
|
1018 | let size = symbolSize$1(parsed.spatials[sym.index - 1].symbol);
|
1019 | x2 = Math.max(x2, parsed.spatials[sym.index - 1].coord[0] + size[0] * sym.zoom);
|
1020 | y2 = Math.max(y2, parsed.spatials[sym.index - 1].coord[1] + size[1] * sym.zoom);
|
1021 | }
|
1022 | });
|
1023 | }
|
1024 |
|
1025 | let classes = '';
|
1026 |
|
1027 | if (styling.classes) {
|
1028 | classes = ` class="${styling.classes}"`;
|
1029 | }
|
1030 |
|
1031 | let id = '';
|
1032 |
|
1033 | if (styling.id) {
|
1034 | id = ` id="${styling.id}"`;
|
1035 | }
|
1036 |
|
1037 | let background = '';
|
1038 |
|
1039 | if (styling.padding) {
|
1040 | x1 -= styling.padding;
|
1041 | y1 -= styling.padding;
|
1042 | x2 += styling.padding;
|
1043 | y2 += styling.padding;
|
1044 | }
|
1045 |
|
1046 | if (styling.background) {
|
1047 | background = `\n <rect x="${x1}" y="${y1}" width="${x2 - x1}" height="${y2 - y1}" style="fill:${styling.background};" />`;
|
1048 | }
|
1049 |
|
1050 | let sizing = '';
|
1051 |
|
1052 | if (styling.zoom != 'x') {
|
1053 | sizing = ` width="${(x2 - x1) * (styling.zoom ? styling.zoom : 1)}" height="${(y2 - y1) * (styling.zoom ? styling.zoom : 1)}"`;
|
1054 | }
|
1055 |
|
1056 | let svg = `<svg${classes}${id} version="1.1" xmlns="http://www.w3.org/2000/svg"${sizing} viewBox="${x1} ${y1} ${x2 - x1} ${y2 - y1}">
|
1057 | <text font-size="0">${fswSign}</text>${background}`;
|
1058 | const line = styling.detail && styling.detail[0];
|
1059 | const fill = styling.detail && styling.detail[1];
|
1060 | svg += '\n' + parsed.spatials.map(spatial => {
|
1061 | let svg = symbolText$1(spatial.symbol);
|
1062 | let symLine = line;
|
1063 |
|
1064 | if (spatial.detail) {
|
1065 | symLine = spatial.detail[0];
|
1066 | } else if (styling.colorize) {
|
1067 | symLine = colorize(spatial.symbol);
|
1068 | }
|
1069 |
|
1070 | if (symLine) {
|
1071 | svg = svg.replace(/class="sym-line" fill="black"/, `class="sym-line" fill="${symLine}"`);
|
1072 | }
|
1073 |
|
1074 | let symFill = fill;
|
1075 |
|
1076 | if (spatial.detail && spatial.detail[1]) {
|
1077 | symFill = spatial.detail[1];
|
1078 | }
|
1079 |
|
1080 | if (symFill) {
|
1081 | svg = svg.replace(/class="sym-fill" fill="white"/, `class="sym-fill" fill="${symFill}"`);
|
1082 | }
|
1083 |
|
1084 | if (spatial.zoom) {
|
1085 | svg = `<g transform="scale(${spatial.zoom})">${svg}</g>`;
|
1086 | }
|
1087 |
|
1088 | return ` <g transform="translate(${spatial.coord[0]},${spatial.coord[1]})">
|
1089 | ${svg}
|
1090 | </g>`;
|
1091 | }).join('\n');
|
1092 | svg += '\n</svg>';
|
1093 | return svg;
|
1094 | }
|
1095 |
|
1096 | return blank;
|
1097 | };
|
1098 |
|
1099 | const signCanvas = function (fswSign) {
|
1100 | const parsed = parse$1.sign(fswSign);
|
1101 |
|
1102 | if (parsed.spatials) {
|
1103 | const canvas = document.createElement('canvas');
|
1104 | const context = canvas.getContext('2d');
|
1105 | let styling = parse(parsed.style);
|
1106 |
|
1107 | if (styling.detailsym) {
|
1108 | styling.detailsym.forEach(sym => {
|
1109 | if (parsed.spatials[sym.index - 1]) {
|
1110 | parsed.spatials[sym.index - 1].detail = sym.detail;
|
1111 | }
|
1112 | });
|
1113 | }
|
1114 |
|
1115 | let x1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[0]));
|
1116 | let y1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[1]));
|
1117 | let x2 = parsed.max[0];
|
1118 | let y2 = parsed.max[1];
|
1119 |
|
1120 | if (styling.zoomsym) {
|
1121 | styling.zoomsym.forEach(sym => {
|
1122 | if (parsed.spatials[sym.index - 1]) {
|
1123 | parsed.spatials[sym.index - 1].zoom = sym.zoom;
|
1124 |
|
1125 | if (sym.offset) {
|
1126 | parsed.spatials[sym.index - 1].coord[0] += sym.offset[0];
|
1127 | parsed.spatials[sym.index - 1].coord[1] += sym.offset[1];
|
1128 | }
|
1129 |
|
1130 | let size = symbolSize$1(parsed.spatials[sym.index - 1].symbol);
|
1131 | x2 = Math.max(x2, parsed.spatials[sym.index - 1].coord[0] + size[0] * sym.zoom);
|
1132 | y2 = Math.max(y2, parsed.spatials[sym.index - 1].coord[1] + size[1] * sym.zoom);
|
1133 | }
|
1134 | });
|
1135 | }
|
1136 |
|
1137 | if (styling.padding) {
|
1138 | x1 -= styling.padding;
|
1139 | y1 -= styling.padding;
|
1140 | x2 += styling.padding;
|
1141 | y2 += styling.padding;
|
1142 | }
|
1143 |
|
1144 | let sizing = 1;
|
1145 |
|
1146 | if (styling.zoom != 'x') {
|
1147 | sizing = styling.zoom;
|
1148 | }
|
1149 |
|
1150 | let w = (x2 - x1) * sizing;
|
1151 | let h = (y2 - y1) * sizing;
|
1152 | canvas.width = w ? w : 1;
|
1153 | canvas.height = h ? h : 1;
|
1154 |
|
1155 | if (styling.background) {
|
1156 | context.rect(0, 0, w, h);
|
1157 | context.fillStyle = styling.background;
|
1158 | context.fill();
|
1159 | }
|
1160 |
|
1161 | const line = styling.detail && styling.detail[0] || "black";
|
1162 | const fill = styling.detail && styling.detail[1] || "white";
|
1163 | parsed.spatials.forEach(spatial => {
|
1164 | let symLine = line;
|
1165 |
|
1166 | if (spatial.detail) {
|
1167 | symLine = spatial.detail[0];
|
1168 | } else if (styling.colorize) {
|
1169 | symLine = colorize(spatial.symbol);
|
1170 | }
|
1171 |
|
1172 | let symFill = fill;
|
1173 |
|
1174 | if (spatial.detail && spatial.detail[1]) {
|
1175 | symFill = spatial.detail[1];
|
1176 | }
|
1177 |
|
1178 | let symZoom = spatial.zoom || 1;
|
1179 | context.font = 30 * sizing * symZoom + "px 'SuttonSignWritingFill'";
|
1180 | context.fillStyle = symFill;
|
1181 | context.fillText(symbolFill$1(spatial.symbol), (spatial.coord[0] - x1) * sizing, (spatial.coord[1] - y1) * sizing);
|
1182 | context.font = 30 * sizing * symZoom + "px 'SuttonSignWritingLine'";
|
1183 | context.fillStyle = symLine;
|
1184 | context.fillText(symbolLine$1(spatial.symbol), (spatial.coord[0] - x1) * sizing, (spatial.coord[1] - y1) * sizing);
|
1185 | });
|
1186 | return canvas;
|
1187 | }
|
1188 | };
|
1189 | |
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 | const signPng = fswSign => {
|
1201 | const canvas = signCanvas(fswSign);
|
1202 | const png = canvas.toDataURL("image/png");
|
1203 | canvas.remove();
|
1204 | return png;
|
1205 | };
|
1206 |
|
1207 | |
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 | const signNormalize = fswSign => {
|
1218 | const parsed = parse$1.sign(fswSign);
|
1219 |
|
1220 | if (parsed.spatials) {
|
1221 | const symbolsizes = parsed.spatials.reduce((output, spatial) => {
|
1222 | const size = symbolSize$1(spatial.symbol);
|
1223 | output[spatial.symbol] = {
|
1224 | width: size[0],
|
1225 | height: size[1]
|
1226 | };
|
1227 | return output;
|
1228 | }, {});
|
1229 |
|
1230 | const bbox = symbols => {
|
1231 | const x1 = Math.min(...symbols.map(spatial => spatial.coord[0]));
|
1232 | const y1 = Math.min(...symbols.map(spatial => spatial.coord[1]));
|
1233 | const x2 = Math.max(...symbols.map(spatial => spatial.coord[0] + parseInt(symbolsizes[spatial.symbol].width)));
|
1234 | const y2 = Math.max(...symbols.map(spatial => spatial.coord[1] + parseInt(symbolsizes[spatial.symbol].height)));
|
1235 | return {
|
1236 | x1: x1,
|
1237 | y1: y1,
|
1238 | x2: x2,
|
1239 | y2: y2
|
1240 | };
|
1241 | };
|
1242 |
|
1243 | const hrange = ranges['hcenter'];
|
1244 | const hsyms = parsed.spatials.filter(spatial => {
|
1245 | const dec = parseInt(spatial.symbol.slice(1, 4), 16);
|
1246 | return hrange[0] <= dec && hrange[1] >= dec;
|
1247 | });
|
1248 | const vrange = ranges['vcenter'];
|
1249 | const vsyms = parsed.spatials.filter(spatial => {
|
1250 | const dec = parseInt(spatial.symbol.slice(1, 4), 16);
|
1251 | return vrange[0] <= dec && vrange[1] >= dec;
|
1252 | });
|
1253 | let abox = bbox(parsed.spatials);
|
1254 | let max = [abox.x2, abox.y2];
|
1255 |
|
1256 | if (hsyms.length) {
|
1257 | const hbox = bbox(hsyms);
|
1258 | abox.x1 = hbox.x1;
|
1259 | abox.x2 = hbox.x2;
|
1260 | }
|
1261 |
|
1262 | if (vsyms.length) {
|
1263 | const vbox = bbox(vsyms);
|
1264 | abox.y1 = vbox.y1;
|
1265 | abox.y2 = vbox.y2;
|
1266 | }
|
1267 |
|
1268 | const offset = [parseInt((abox.x2 + abox.x1) / 2) - 500, parseInt((abox.y2 + abox.y1) / 2) - 500];
|
1269 | const fswout = (parsed.sequence ? 'A' + parsed.sequence.join('') : '') + parsed.box + (max[0] - offset[0]) + 'x' + (max[1] - offset[1]) + parsed.spatials.map(spatial => spatial.symbol + (spatial.coord[0] - offset[0]) + 'x' + (spatial.coord[1] - offset[1])).join('') + (parsed.style || '');
|
1270 | return fswout;
|
1271 | }
|
1272 | };
|
1273 |
|
1274 | |
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 | var index$1 = Object.freeze({
|
1280 | __proto__: null,
|
1281 | symbolSize: symbolSize$1,
|
1282 | symbolLine: symbolLine$1,
|
1283 | symbolFill: symbolFill$1,
|
1284 | symbolText: symbolText$1,
|
1285 | symbolSvg: symbolSvg,
|
1286 | symbolPng: symbolPng,
|
1287 | symbolNormalize: symbolNormalize,
|
1288 | signSvg: signSvg,
|
1289 | signPng: signPng,
|
1290 | signNormalize: signNormalize
|
1291 | });
|
1292 |
|
1293 | |
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 | const symbolSize$2 = function (swu) {
|
1304 | return symbolSize(swu2id(swu));
|
1305 | };
|
1306 |
|
1307 | |
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | const symbolLine$2 = function (swu) {
|
1318 | return symbolLine(swu2id(swu));
|
1319 | };
|
1320 | |
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 | const symbolFill$2 = function (swu) {
|
1332 | return symbolFill(swu2id(swu));
|
1333 | };
|
1334 | |
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 | const symbolText$2 = function (swu) {
|
1347 | return symbolText(swu2id(swu));
|
1348 | };
|
1349 |
|
1350 | |
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 | |
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 | let re$2 = {
|
1364 | 'symbol': '(?:(?:\uD8C0[\uDC01-\uDFFF])|(?:[\uD8C1-\uD8FC][\uDC00-\uDFFF])|(?:\uD8FD[\uDC00-\uDC80]))',
|
1365 | 'coord': '(?:\uD836[\uDC0C-\uDDFF]){2}',
|
1366 | 'sort': '\uD836\uDC00',
|
1367 | 'box': '\uD836[\uDC01-\uDC04]'
|
1368 | };
|
1369 | re$2.prefix = `(?:${re$2.sort}(?:${re$2.symbol})+)`;
|
1370 | re$2.spatial = `${re$2.symbol}${re$2.coord}`;
|
1371 | re$2.signbox = `${re$2.box}${re$2.coord}(?:${re$2.spatial})*`;
|
1372 | re$2.sign = `${re$2.prefix}?${re$2.signbox}`;
|
1373 | re$2.sortable = `${re$2.prefix}${re$2.signbox}`;
|
1374 |
|
1375 | |
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 | let re$1$2 = {
|
1383 | 'colorize': 'C',
|
1384 | 'colorhex': '(?:[0-9a-fA-F]{3}){1,2}',
|
1385 | 'colorname': '[a-zA-Z]+',
|
1386 | 'padding': 'P[0-9]{2}',
|
1387 | 'zoom': 'Z(?:[0-9]+(?:\\.[0-9]+)?|x)',
|
1388 | 'zoomsym': 'Z[0-9]{2},[0-9]+(?:\\.[0-9]+)?(?:,[0-9]{3}x[0-9]{3})?',
|
1389 | 'classbase': '-?[_a-zA-Z][_a-zA-Z0-9-]{0,100}',
|
1390 | 'id': '[a-zA-Z][_a-zA-Z0-9-]{0,100}'
|
1391 | };
|
1392 | re$1$2.colorbase = `(?:${re$1$2.colorhex}|${re$1$2.colorname})`;
|
1393 | re$1$2.color = `_${re$1$2.colorbase}_`;
|
1394 | re$1$2.colors = `_${re$1$2.colorbase}(?:,${re$1$2.colorbase})?_`;
|
1395 | re$1$2.background = `G${re$1$2.color}`;
|
1396 | re$1$2.detail = `D${re$1$2.colors}`;
|
1397 | re$1$2.detailsym = `D[0-9]{2}${re$1$2.colors}`;
|
1398 | re$1$2.classes = `${re$1$2.classbase}(?: ${re$1$2.classbase})*`;
|
1399 | re$1$2.full = `-(${re$1$2.colorize})?(${re$1$2.padding})?(${re$1$2.background})?(${re$1$2.detail})?(${re$1$2.zoom})?(?:-((?:${re$1$2.detailsym})*)((?:${re$1$2.zoomsym})*))?(?:-(${re$1$2.classes})?!(?:(${re$1$2.id})!)?)?`;
|
1400 |
|
1401 | |
1402 |
|
1403 |
|
1404 |
|
1405 | |
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 | const swu2num = swuNum => parseInt(swuNum.codePointAt(0)) - 0x1D80C + 250;
|
1418 | |
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 | const swu2coord = swuCoord => [swu2num(swuCoord.slice(0, 2)), swu2num(swuCoord.slice(2, 4))];
|
1431 | |
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 | const swu2code$1 = swuSym => parseInt(swuSym.codePointAt(0));
|
1444 |
|
1445 | const parse$2 = {
|
1446 | |
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 | symbol: swuSym => {
|
1461 | const regex = `^(${re$2.symbol})(${re$2.coord})?(${re$1$2.full})?`;
|
1462 | const symbol = typeof swuSym === 'string' ? swuSym.match(new RegExp(regex)) : undefined;
|
1463 | return {
|
1464 | 'symbol': symbol ? symbol[1] : undefined,
|
1465 | 'coord': symbol && symbol[2] ? swu2coord(symbol[2]) : undefined,
|
1466 | 'style': symbol ? symbol[3] : undefined
|
1467 | };
|
1468 | },
|
1469 |
|
1470 | |
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 | sign: swuSign => {
|
1504 | const regex = `^(${re$2.prefix})?(${re$2.signbox})(${re$1$2.full})?`;
|
1505 | const sign = typeof swuSign === 'string' ? swuSign.match(new RegExp(regex)) : undefined;
|
1506 |
|
1507 | if (sign) {
|
1508 | return {
|
1509 | 'sequence': sign[1] ? sign[1].slice(2).match(/.{2}/g) : undefined,
|
1510 | 'box': sign[2].slice(0, 2),
|
1511 | 'max': swu2coord(sign[2].slice(2, 6)),
|
1512 | 'spatials': sign[2].length < 7 ? undefined : sign[2].slice(6).match(/(.{6})/g).map(m => {
|
1513 | return {
|
1514 | symbol: m.slice(0, 2),
|
1515 | coord: swu2coord(m.slice(2))
|
1516 | };
|
1517 | }),
|
1518 | 'style': sign[3]
|
1519 | };
|
1520 | } else {
|
1521 | return {};
|
1522 | }
|
1523 | }
|
1524 | };
|
1525 | |
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 | const category$1 = [0x40001, 0x461e1, 0x4bca1, 0x4bfa1, 0x4e8e1, 0x4efa1, 0x4f2a1];
|
1532 | |
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 | const ranges$1 = {
|
1541 | 'all': [0x40001, 0x4f480],
|
1542 | 'writing': [0x40001, 0x4efa0],
|
1543 | 'hand': [0x40001, 0x461e0],
|
1544 | 'movement': [0x461e1, 0x4bca0],
|
1545 | 'dynamic': [0x4bca1, 0x4bfa0],
|
1546 | 'head': [0x4bfa1, 0x4e8e0],
|
1547 | 'hcenter': [0x4bfa1, 0x4e8e0],
|
1548 | 'vcenter': [0x4bfa1, 0x4ec40],
|
1549 | 'trunk': [0x4e8e1, 0x4ec40],
|
1550 | 'limb': [0x4ec41, 0x4efa0],
|
1551 | 'location': [0x4efa1, 0x4f2a0],
|
1552 | 'punctuation': [0x4f2a1, 0x4f480]
|
1553 | };
|
1554 |
|
1555 | |
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 | const colors$1 = ['#0000CC', '#CC0000', '#FF0099', '#006600', '#000000', '#884411', '#FF9900'];
|
1562 | |
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 | const colorize$1 = swuSym => {
|
1574 | const parsed = parse$2.symbol(swuSym);
|
1575 | let color = '#000000';
|
1576 |
|
1577 | if (parsed.symbol) {
|
1578 | const code = swu2code$1(parsed.symbol);
|
1579 | const index = category$1.findIndex(val => val > code);
|
1580 | color = colors$1[index < 0 ? 6 : index - 1];
|
1581 | }
|
1582 |
|
1583 | return color;
|
1584 | };
|
1585 |
|
1586 |
|
1587 |
|
1588 | |
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 | const symbolSvg$1 = swuSym => {
|
1606 | const parsed = parse$2.symbol(swuSym);
|
1607 | const blank = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';
|
1608 |
|
1609 | if (parsed.symbol) {
|
1610 | let size = symbolSize$2(parsed.symbol);
|
1611 |
|
1612 | if (size) {
|
1613 | let styling = parse(parsed.style);
|
1614 | let line;
|
1615 | let symSvg = symbolText$2(parsed.symbol);
|
1616 | symSvg = ` <g transform="translate(500,500)">
|
1617 | ${symSvg}
|
1618 | </g>`;
|
1619 |
|
1620 | if (styling.colorize) {
|
1621 | line = colorize$1(parsed.symbol);
|
1622 | } else if (styling.detail) {
|
1623 | line = styling.detail[0];
|
1624 | }
|
1625 |
|
1626 | if (line) {
|
1627 | symSvg = symSvg.replace(/class="sym-line" fill="black"/, `class="sym-line" fill="${line}"`);
|
1628 | }
|
1629 |
|
1630 | let fill = styling.detail && styling.detail[1];
|
1631 |
|
1632 | if (fill) {
|
1633 | symSvg = symSvg.replace(/class="sym-fill" fill="white"/, `class="sym-fill" fill="${fill}"`);
|
1634 | }
|
1635 |
|
1636 | let x1 = 500;
|
1637 | let y1 = 500;
|
1638 | let background = '';
|
1639 |
|
1640 | if (styling.padding) {
|
1641 | x1 -= styling.padding;
|
1642 | y1 -= styling.padding;
|
1643 | size[0] += styling.padding * 2;
|
1644 | size[1] += styling.padding * 2;
|
1645 | }
|
1646 |
|
1647 | if (styling.background) {
|
1648 | background = `\n <rect x="${x1}" y="${y1}" width="${size[0]}" height="${size[1]}" style="fill:${styling.background};" />`;
|
1649 | }
|
1650 |
|
1651 | let sizing = '';
|
1652 |
|
1653 | if (styling.zoom != 'x') {
|
1654 | sizing = ` width="${size[0] * (styling.zoom ? styling.zoom : 1)}" height="${size[1] * (styling.zoom ? styling.zoom : 1)}"`;
|
1655 | }
|
1656 |
|
1657 | let classes = '';
|
1658 |
|
1659 | if (styling.classes) {
|
1660 | classes = ` class="${styling.classes}"`;
|
1661 | }
|
1662 |
|
1663 | let id = '';
|
1664 |
|
1665 | if (styling.id) {
|
1666 | id = ` id="${styling.id}"`;
|
1667 | }
|
1668 |
|
1669 | return `<svg${classes}${id} version="1.1" xmlns="http://www.w3.org/2000/svg"${sizing} viewBox="${x1} ${y1} ${size[0]} ${size[1]}">
|
1670 | <text font-size="0">${swuSym}</text>${background}
|
1671 | ${symSvg}
|
1672 | </svg>`;
|
1673 | }
|
1674 | }
|
1675 |
|
1676 | return blank;
|
1677 | };
|
1678 |
|
1679 | const symbolCanvas$1 = function (swuSym) {
|
1680 | const parsed = parse$2.symbol(swuSym);
|
1681 |
|
1682 | if (parsed.symbol) {
|
1683 | let size = symbolSize$2(parsed.symbol);
|
1684 |
|
1685 | if (size) {
|
1686 | const canvas = document.createElement('canvas');
|
1687 | const context = canvas.getContext('2d');
|
1688 | let styling = parse(parsed.style);
|
1689 | let line = 'black';
|
1690 |
|
1691 | if (styling.colorize) {
|
1692 | line = colorize$1(parsed.symbol);
|
1693 | } else if (styling.detail) {
|
1694 | line = styling.detail[0];
|
1695 | }
|
1696 |
|
1697 | let fill = styling.detail && styling.detail[1] || 'white';
|
1698 | let x1 = 500;
|
1699 | let x2 = x1 + size[0];
|
1700 | let y1 = 500;
|
1701 | let y2 = y1 + size[1];
|
1702 |
|
1703 | if (styling.padding) {
|
1704 | x1 -= styling.padding;
|
1705 | y1 -= styling.padding;
|
1706 | x2 += styling.padding;
|
1707 | y2 += styling.padding;
|
1708 | }
|
1709 |
|
1710 | let sizing = 1;
|
1711 |
|
1712 | if (styling.zoom != 'x') {
|
1713 | sizing = styling.zoom;
|
1714 | }
|
1715 |
|
1716 | let w = (x2 - x1) * sizing;
|
1717 | let h = (y2 - y1) * sizing;
|
1718 | canvas.width = w ? w : 1;
|
1719 | canvas.height = h ? h : 1;
|
1720 |
|
1721 | if (styling.background) {
|
1722 | context.rect(0, 0, w, h);
|
1723 | context.fillStyle = styling.background;
|
1724 | context.fill();
|
1725 | }
|
1726 |
|
1727 | context.font = 30 * sizing + "px 'SuttonSignWritingFill'";
|
1728 | context.fillStyle = fill;
|
1729 | context.fillText(symbolFill$2(parsed.symbol), (500 - x1) * sizing, (500 - y1) * sizing);
|
1730 | context.font = 30 * sizing + "px 'SuttonSignWritingLine'";
|
1731 | context.fillStyle = line;
|
1732 | context.fillText(symbolLine$2(parsed.symbol), (500 - x1) * sizing, (500 - y1) * sizing);
|
1733 | return canvas;
|
1734 | }
|
1735 | }
|
1736 | };
|
1737 | |
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 | const symbolPng$1 = swuSym => {
|
1749 | const canvas = symbolCanvas$1(swuSym);
|
1750 | const png = canvas.toDataURL("image/png");
|
1751 | canvas.remove();
|
1752 | return png;
|
1753 | };
|
1754 |
|
1755 | const blank$1 = null;
|
1756 | |
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 | const symbolNormalize$1 = swuSym => {
|
1767 | const parsed = parse$2.symbol(swuSym);
|
1768 |
|
1769 | if (parsed.symbol) {
|
1770 | let size = symbolSize$2(parsed.symbol);
|
1771 |
|
1772 | if (size) {
|
1773 | return `${parsed.symbol}${coord2swu([500 - parseInt(size[0] / 2), 500 - parseInt(size[1] / 2)])}${parsed.style || ''}`;
|
1774 | }
|
1775 | } else {
|
1776 | return blank$1;
|
1777 | }
|
1778 | };
|
1779 |
|
1780 | |
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 | const signSvg$1 = swuSign => {
|
1810 | let parsed = parse$2.sign(swuSign);
|
1811 | const blank = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>';
|
1812 |
|
1813 | if (parsed.spatials) {
|
1814 | let styling = parse(parsed.style);
|
1815 |
|
1816 | if (styling.detailsym) {
|
1817 | styling.detailsym.forEach(sym => {
|
1818 | if (parsed.spatials[sym.index - 1]) {
|
1819 | parsed.spatials[sym.index - 1].detail = sym.detail;
|
1820 | }
|
1821 | });
|
1822 | }
|
1823 |
|
1824 | let x1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[0]));
|
1825 | let y1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[1]));
|
1826 | let x2 = parsed.max[0];
|
1827 | let y2 = parsed.max[1];
|
1828 |
|
1829 | if (styling.zoomsym) {
|
1830 | styling.zoomsym.forEach(sym => {
|
1831 | if (parsed.spatials[sym.index - 1]) {
|
1832 | parsed.spatials[sym.index - 1].zoom = sym.zoom;
|
1833 |
|
1834 | if (sym.offset) {
|
1835 | parsed.spatials[sym.index - 1].coord[0] += sym.offset[0];
|
1836 | parsed.spatials[sym.index - 1].coord[1] += sym.offset[1];
|
1837 | }
|
1838 |
|
1839 | let size = symbolSize$2(parsed.spatials[sym.index - 1].symbol);
|
1840 | x2 = Math.max(x2, parsed.spatials[sym.index - 1].coord[0] + size[0] * sym.zoom);
|
1841 | y2 = Math.max(y2, parsed.spatials[sym.index - 1].coord[1] + size[1] * sym.zoom);
|
1842 | }
|
1843 | });
|
1844 | }
|
1845 |
|
1846 | let classes = '';
|
1847 |
|
1848 | if (styling.classes) {
|
1849 | classes = ` class="${styling.classes}"`;
|
1850 | }
|
1851 |
|
1852 | let id = '';
|
1853 |
|
1854 | if (styling.id) {
|
1855 | id = ` id="${styling.id}"`;
|
1856 | }
|
1857 |
|
1858 | let background = '';
|
1859 |
|
1860 | if (styling.padding) {
|
1861 | x1 -= styling.padding;
|
1862 | y1 -= styling.padding;
|
1863 | x2 += styling.padding;
|
1864 | y2 += styling.padding;
|
1865 | }
|
1866 |
|
1867 | if (styling.background) {
|
1868 | background = `\n <rect x="${x1}" y="${y1}" width="${x2 - x1}" height="${y2 - y1}" style="fill:${styling.background};" />`;
|
1869 | }
|
1870 |
|
1871 | let sizing = '';
|
1872 |
|
1873 | if (styling.zoom != 'x') {
|
1874 | sizing = ` width="${(x2 - x1) * (styling.zoom ? styling.zoom : 1)}" height="${(y2 - y1) * (styling.zoom ? styling.zoom : 1)}"`;
|
1875 | }
|
1876 |
|
1877 | let svg = `<svg${classes}${id} version="1.1" xmlns="http://www.w3.org/2000/svg"${sizing} viewBox="${x1} ${y1} ${x2 - x1} ${y2 - y1}">
|
1878 | <text font-size="0">${swuSign}</text>${background}`;
|
1879 | const line = styling.detail && styling.detail[0];
|
1880 | const fill = styling.detail && styling.detail[1];
|
1881 | svg += '\n' + parsed.spatials.map(spatial => {
|
1882 | let svg = symbolText$2(spatial.symbol, spatial.coord);
|
1883 | let symLine = line;
|
1884 |
|
1885 | if (spatial.detail) {
|
1886 | symLine = spatial.detail[0];
|
1887 | } else if (styling.colorize) {
|
1888 | symLine = colorize$1(spatial.symbol);
|
1889 | }
|
1890 |
|
1891 | if (symLine) {
|
1892 | svg = svg.replace(/class="sym-line" fill="black"/, `class="sym-line" fill="${symLine}"`);
|
1893 | }
|
1894 |
|
1895 | let symFill = fill;
|
1896 |
|
1897 | if (spatial.detail && spatial.detail[1]) {
|
1898 | symFill = spatial.detail[1];
|
1899 | }
|
1900 |
|
1901 | if (symFill) {
|
1902 | svg = svg.replace(/class="sym-fill" fill="white"/, `class="sym-fill" fill="${symFill}"`);
|
1903 | }
|
1904 |
|
1905 | if (spatial.zoom) {
|
1906 | svg = `<g transform="scale(${spatial.zoom})">${svg}</g>`;
|
1907 | }
|
1908 |
|
1909 | return ` <g transform="translate(${spatial.coord[0]},${spatial.coord[1]})">
|
1910 | ${svg}
|
1911 | </g>`;
|
1912 | }).join('\n');
|
1913 | svg += '\n</svg>';
|
1914 | return svg;
|
1915 | }
|
1916 |
|
1917 | return blank;
|
1918 | };
|
1919 |
|
1920 | const signCanvas$1 = function (swuSign) {
|
1921 | const parsed = parse$2.sign(swuSign);
|
1922 |
|
1923 | if (parsed.spatials) {
|
1924 | const canvas = document.createElement('canvas');
|
1925 | const context = canvas.getContext('2d');
|
1926 | let styling = parse(parsed.style);
|
1927 |
|
1928 | if (styling.detailsym) {
|
1929 | styling.detailsym.forEach(sym => {
|
1930 | if (parsed.spatials[sym.index - 1]) {
|
1931 | parsed.spatials[sym.index - 1].detail = sym.detail;
|
1932 | }
|
1933 | });
|
1934 | }
|
1935 |
|
1936 | let x1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[0]));
|
1937 | let y1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[1]));
|
1938 | let x2 = parsed.max[0];
|
1939 | let y2 = parsed.max[1];
|
1940 |
|
1941 | if (styling.zoomsym) {
|
1942 | styling.zoomsym.forEach(sym => {
|
1943 | if (parsed.spatials[sym.index - 1]) {
|
1944 | parsed.spatials[sym.index - 1].zoom = sym.zoom;
|
1945 |
|
1946 | if (sym.offset) {
|
1947 | parsed.spatials[sym.index - 1].coord[0] += sym.offset[0];
|
1948 | parsed.spatials[sym.index - 1].coord[1] += sym.offset[1];
|
1949 | }
|
1950 |
|
1951 | let size = symbolSize$2(parsed.spatials[sym.index - 1].symbol);
|
1952 | x2 = Math.max(x2, parsed.spatials[sym.index - 1].coord[0] + size[0] * sym.zoom);
|
1953 | y2 = Math.max(y2, parsed.spatials[sym.index - 1].coord[1] + size[1] * sym.zoom);
|
1954 | }
|
1955 | });
|
1956 | }
|
1957 |
|
1958 | if (styling.padding) {
|
1959 | x1 -= styling.padding;
|
1960 | y1 -= styling.padding;
|
1961 | x2 += styling.padding;
|
1962 | y2 += styling.padding;
|
1963 | }
|
1964 |
|
1965 | let sizing = 1;
|
1966 |
|
1967 | if (styling.zoom != 'x') {
|
1968 | sizing = styling.zoom;
|
1969 | }
|
1970 |
|
1971 | let w = (x2 - x1) * sizing;
|
1972 | let h = (y2 - y1) * sizing;
|
1973 | canvas.width = w ? w : 1;
|
1974 | canvas.height = h ? h : 1;
|
1975 |
|
1976 | if (styling.background) {
|
1977 | context.rect(0, 0, w, h);
|
1978 | context.fillStyle = styling.background;
|
1979 | context.fill();
|
1980 | }
|
1981 |
|
1982 | const line = styling.detail && styling.detail[0] || "black";
|
1983 | const fill = styling.detail && styling.detail[1] || "white";
|
1984 | parsed.spatials.forEach(spatial => {
|
1985 | let symLine = line;
|
1986 |
|
1987 | if (spatial.detail) {
|
1988 | symLine = spatial.detail[0];
|
1989 | } else if (styling.colorize) {
|
1990 | symLine = colorize$1(spatial.symbol);
|
1991 | }
|
1992 |
|
1993 | let symFill = fill;
|
1994 |
|
1995 | if (spatial.detail && spatial.detail[1]) {
|
1996 | symFill = spatial.detail[1];
|
1997 | }
|
1998 |
|
1999 | let symZoom = spatial.zoom || 1;
|
2000 | context.font = 30 * sizing * symZoom + "px 'SuttonSignWritingFill'";
|
2001 | context.fillStyle = symFill;
|
2002 | context.fillText(symbolFill$2(spatial.symbol), (spatial.coord[0] - x1) * sizing, (spatial.coord[1] - y1) * sizing);
|
2003 | context.font = 30 * sizing * symZoom + "px 'SuttonSignWritingLine'";
|
2004 | context.fillStyle = symLine;
|
2005 | context.fillText(symbolLine$2(spatial.symbol), (spatial.coord[0] - x1) * sizing, (spatial.coord[1] - y1) * sizing);
|
2006 | });
|
2007 | return canvas;
|
2008 | }
|
2009 | };
|
2010 | |
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 | const signPng$1 = swuSign => {
|
2022 | const canvas = signCanvas$1(swuSign);
|
2023 | const png = canvas.toDataURL("image/png");
|
2024 | canvas.remove();
|
2025 | return png;
|
2026 | };
|
2027 |
|
2028 | |
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 | const signNormalize$1 = swuSign => {
|
2039 | const parsed = parse$2.sign(swuSign);
|
2040 |
|
2041 | if (parsed.spatials) {
|
2042 | const symbolsizes = parsed.spatials.reduce((output, spatial) => {
|
2043 | const size = symbolSize$2(spatial.symbol);
|
2044 | output[spatial.symbol] = {
|
2045 | width: size[0],
|
2046 | height: size[1]
|
2047 | };
|
2048 | return output;
|
2049 | }, {});
|
2050 |
|
2051 | const bbox = symbols => {
|
2052 | const x1 = Math.min(...symbols.map(spatial => spatial.coord[0]));
|
2053 | const y1 = Math.min(...symbols.map(spatial => spatial.coord[1]));
|
2054 | const x2 = Math.max(...symbols.map(spatial => spatial.coord[0] + parseInt(symbolsizes[spatial.symbol].width)));
|
2055 | const y2 = Math.max(...symbols.map(spatial => spatial.coord[1] + parseInt(symbolsizes[spatial.symbol].height)));
|
2056 | return {
|
2057 | x1: x1,
|
2058 | y1: y1,
|
2059 | x2: x2,
|
2060 | y2: y2
|
2061 | };
|
2062 | };
|
2063 |
|
2064 | const hrange = ranges$1['hcenter'];
|
2065 | const hsyms = parsed.spatials.filter(spatial => {
|
2066 | const dec = parseInt(spatial.symbol.slice(1, 4), 16);
|
2067 | return hrange[0] <= dec && hrange[1] >= dec;
|
2068 | });
|
2069 | const vrange = ranges$1['vcenter'];
|
2070 | const vsyms = parsed.spatials.filter(spatial => {
|
2071 | const dec = parseInt(spatial.symbol.slice(1, 4), 16);
|
2072 | return vrange[0] <= dec && vrange[1] >= dec;
|
2073 | });
|
2074 | let abox = bbox(parsed.spatials);
|
2075 | let max = [abox.x2, abox.y2];
|
2076 |
|
2077 | if (hsyms.length) {
|
2078 | const hbox = bbox(hsyms);
|
2079 | abox.x1 = hbox.x1;
|
2080 | abox.x2 = hbox.x2;
|
2081 | }
|
2082 |
|
2083 | if (vsyms.length) {
|
2084 | const vbox = bbox(vsyms);
|
2085 | abox.y1 = vbox.y1;
|
2086 | abox.y2 = vbox.y2;
|
2087 | }
|
2088 |
|
2089 | const offset = [parseInt((abox.x2 + abox.x1) / 2) - 500, parseInt((abox.y2 + abox.y1) / 2) - 500];
|
2090 | const swuout = (parsed.sequence ? 'ð ' + parsed.sequence.join('') : '') + parsed.box + coord2swu([max[0] - offset[0], max[1] - offset[1]]) + parsed.spatials.map(spatial => spatial.symbol + coord2swu([spatial.coord[0] - offset[0], spatial.coord[1] - offset[1]])).join('') + (parsed.style || '');
|
2091 | return swuout;
|
2092 | }
|
2093 | };
|
2094 |
|
2095 | |
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 | var index$2 = Object.freeze({
|
2101 | __proto__: null,
|
2102 | symbolSize: symbolSize$2,
|
2103 | symbolLine: symbolLine$2,
|
2104 | symbolFill: symbolFill$2,
|
2105 | symbolText: symbolText$2,
|
2106 | symbolSvg: symbolSvg$1,
|
2107 | symbolPng: symbolPng$1,
|
2108 | symbolNormalize: symbolNormalize$1,
|
2109 | signSvg: signSvg$1,
|
2110 | signPng: signPng$1,
|
2111 | signNormalize: signNormalize$1
|
2112 | });
|
2113 |
|
2114 | exports.font = index;
|
2115 | exports.fsw = index$1;
|
2116 | exports.swu = index$2;
|
2117 |
|
2118 | Object.defineProperty(exports, '__esModule', { value: true });
|
2119 |
|
2120 | })));
|
2121 |
|
2122 |
|