UNPKG

3.23 kBJavaScriptView Raw
1/* Sutton SignWriting Unicode 8 Module v1.2.0 (https://github.com/sutton-signwriting/unicode8), author: Steve Slevinski (https://SteveSlevinski.me), sponsor: https://patreon.com/signwriting, donate: https://donate.sutton-signwriting.io, license: MIT */
2!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ssw=t.ssw||{},t.ssw.unicode8={}))}(this,(function(t){"use strict";var e=Object.freeze({__proto__:null,cssAppend:function(t=""){if(!document.getElementById("SgnwUnicode8FontCss")){const e=document.createElement("style");e.setAttribute("id","SgnwUnicode8FontCss"),e.appendChild(document.createTextNode(`\n @font-face {\n font-family: "NotoSansSignWriting";\n src: \n local('NotoSansSignWriting'),\n local('Noto Sans SignWriting'),\n local('Noto_Sans_SignWriting'),\n local('Noto Sans SignWriting Regular'),\n local('Noto_Sans_SignWriting_Regular'),\n ${t?`url('${t}NotoSansSignWriting-Regular.ttf') format('truetype'),`:""}\n url('https://notofonts.github.io/sign-writing/fonts/NotoSansSignWriting/full/ttf/NotoSansSignWriting-Regular.ttf') format('opentype');\n }\n `)),document.head.appendChild(e)}}});let n={base:"(?:\ud836[\udc00-\ude8b])",fill:"(?:\ud836[\ude9b-\ude9f])",rotation:"(?:\ud836[\udea1-\udeaf])"};n.full=`(${n.base})(${n.fill})?(${n.rotation})?`;const o=t=>{const e=`^${n.full}`,o=("string"==typeof t?t.match(new RegExp(e)):[])||[];return{base:o[1]?o[1]:void 0,fill:o[2]?o[2]:void 0,rotation:o[3]?o[3]:void 0}};var i=Object.freeze({__proto__:null,re:n,parse:o,compose:t=>{if("object"!=typeof t||null===t)return;const e=(t.base?t.base:"")+(t.fill?t.fill:"")+(t.rotation?t.rotation:"");return e||void 0}});let r={full:`(?:${n.full})+`};var l=Object.freeze({__proto__:null,re:r,parse:t=>{const e=`^(${r.full})`,o=("string"==typeof t?t.match(new RegExp(e)):[])||[];return o[1]?[...o[1].matchAll(new RegExp(n.full,"g"))].map((t=>t[0])):[]},compose:t=>{if(Array.isArray(t))return t.join("")}});const s=t=>String.fromCharCode(55296+(t-65536>>10),56320+(t-65536&1023));var a=Object.freeze({__proto__:null,code2uni:s,uni2code:t=>t.codePointAt(0),uni2hex:t=>t.codePointAt(0).toString(16).toUpperCase(),uni2fsw:t=>{let e=o(t);return e.base?(e.base=e.base.codePointAt(0)-120576,e.fill=e.fill?e.fill.codePointAt(0)-121498:0,e.rotation=e.rotation?e.rotation.codePointAt(0)-121504:0,"S"+e.base.toString(16)+e.fill.toString(16)+e.rotation.toString(16)):void 0},uni2swu:t=>{let e=o(t);return e.base?(e.base=e.base.codePointAt(0)-120832,e.fill=e.fill?e.fill.codePointAt(0)-121498:0,e.rotation=e.rotation?e.rotation.codePointAt(0)-121504:0,s(262145+96*e.base+16*e.fill+e.rotation)):void 0},fsw2uni:t=>{let e=parseInt(t.slice(1,4),16),n=parseInt(t.slice(4,5),16),o=parseInt(t.slice(5,6),16);return s(e+120576)+(n?s(n+121498):"")+(o?s(o+121504):"")},swu2uni:t=>{const e=t.codePointAt(0)-262145,n=parseInt(e/96),o=parseInt((e-96*n)/16),i=parseInt(e-96*n-16*o);return s(n+120832)+(o?s(o+121498):"")+(i?s(i+121504):"")}});t.convert=a,t.font=e,t.string=l,t.symbol=i,Object.defineProperty(t,"__esModule",{value:!0})}));