UNPKG

three-dxf

Version:

A dxf viewer for the browser using three.js.

2 lines 113 kB
/*! For license information please see three-dxf.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],t):"object"==typeof exports?exports.ThreeDxf=t(require("THREE")):e.ThreeDxf=t(e.THREE)}("undefined"!=typeof self?self:this,(function(e){return(()=>{"use strict";var t={824:t=>{t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{n.r(a),n.d(a,{Viewer:()=>X});var e=n(824);function t(t,r){this.object=t,this.domElement=void 0!==r?r:document,this.enabled=!0,this.target=new e.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40};var n=this,a=new e.Vector2,o=new e.Vector2,i=new e.Vector2,s=new e.Vector2,l=new e.Vector2,u=new e.Vector2,f=new e.Vector3,h=new e.Vector3,c=new e.Vector2,d=new e.Vector2,p=new e.Vector2,v=1,g=new e.Vector3,m=(new e.Vector3,-1),y=m;this.target0=this.target.clone(),this.position0=this.object.position.clone();var b={type:"change"},x={type:"start"},S={type:"end"};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function U(){return Math.pow(.95,n.zoomSpeed)}function w(e){if(!1!==n.enabled){e.preventDefault();var t=n.domElement===document?n.domElement.body:n.domElement;if(0===y){if(!0===n.noRotate)return;o.set(e.clientX,e.clientY),i.subVectors(o,a),n.rotateLeft(2*Math.PI*i.x/t.clientWidth*n.rotateSpeed),n.rotateUp(2*Math.PI*i.y/t.clientHeight*n.rotateSpeed),a.copy(o)}else if(1===y){if(!0===n.noZoom)return;d.set(e.clientX,e.clientY),p.subVectors(d,c),p.y>0?n.dollyIn():n.dollyOut(),c.copy(d)}else if(2===y){if(!0===n.noPan)return;l.set(e.clientX,e.clientY),u.subVectors(l,s),n.pan(u.x,u.y),s.copy(l)}n.update()}}function _(){!1!==n.enabled&&(n.domElement.removeEventListener("mousemove",w,!1),n.domElement.removeEventListener("mouseup",_,!1),n.dispatchEvent(S),y=m)}function T(e){if(!1!==n.enabled&&!0!==n.noZoom){e.preventDefault();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t>0?n.dollyOut():n.dollyIn(),n.update(),n.dispatchEvent(x),n.dispatchEvent(S)}}this.rotateLeft=function(e){void 0===e&&(e=k())},this.rotateUp=function(e){void 0===e&&(e=k())},this.panLeft=function(e){var t=this.object.matrix.elements;f.set(t[0],t[1],t[2]),f.multiplyScalar(-e),g.add(f)},this.panUp=function(e){var t=this.object.matrix.elements;f.set(t[4],t[5],t[6]),f.multiplyScalar(e),g.add(f)},this.pan=function(e,t){var r=n.domElement===document?n.domElement.body:n.domElement;if(void 0!==n.object.fov){var a=n.object.position.clone().sub(n.target).length();a*=Math.tan(n.object.fov/2*Math.PI/180),n.panLeft(2*e*a/r.clientHeight),n.panUp(2*t*a/r.clientHeight)}else void 0!==n.object.top?(n.panLeft(e*(n.object.right-n.object.left)/r.clientWidth),n.panUp(t*(n.object.top-n.object.bottom)/r.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(e){void 0===e&&(e=U()),v/=e},this.dollyOut=function(e){void 0===e&&(e=U()),v*=e},this.update=function(){void 0!==n.object.top&&(this.object.top=v*this.object.top,this.object.bottom=v*this.object.bottom,this.object.left=v*this.object.left,this.object.right=v*this.object.right,this.object.updateProjectionMatrix());var e=this.object.position;h.copy(e).sub(this.target),this.target.add(g),e.copy(this.target).add(h),this.object.lookAt(this.target),this.dispatchEvent(b),v=1,g.set(0,0,0)},this.reset=function(){y=m,this.target.copy(this.target0),this.object.position.copy(this.position0),this.update()},this.domElement.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),this.domElement.addEventListener("mousedown",(function(e){if(!1!==n.enabled){if(e.preventDefault(),0===e.button){if(!0===n.noRotate)return;y=0,a.set(e.clientX,e.clientY)}else if(1===e.button){if(!0===n.noZoom)return;y=1,c.set(e.clientX,e.clientY)}else if(2===e.button){if(!0===n.noPan)return;y=2,s.set(e.clientX,e.clientY)}n.domElement.addEventListener("mousemove",w,!1),n.domElement.addEventListener("mouseup",_,!1),n.dispatchEvent(x)}}),!1),this.domElement.addEventListener("mousewheel",T,!1),this.domElement.addEventListener("DOMMouseScroll",T,!1),this.domElement.addEventListener("touchstart",(function(e){if(!1!==n.enabled){switch(e.touches.length){case 1:if(!0===n.noRotate)return;y=3,a.set(e.touches[0].pageX,e.touches[0].pageY);break;case 2:if(!0===n.noZoom)return;y=4;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+r*r);c.set(0,o);break;case 3:if(!0===n.noPan)return;y=5,s.set(e.touches[0].pageX,e.touches[0].pageY);break;default:y=m}n.dispatchEvent(x)}}),!1),this.domElement.addEventListener("touchend",(function(){!1!==n.enabled&&(n.dispatchEvent(S),y=m)}),!1),this.domElement.addEventListener("touchmove",(function(e){if(!1!==n.enabled){e.preventDefault(),e.stopPropagation();var t=n.domElement===document?n.domElement.body:n.domElement;switch(e.touches.length){case 1:if(!0===n.noRotate)return;if(3!==y)return;o.set(e.touches[0].pageX,e.touches[0].pageY),i.subVectors(o,a),n.rotateLeft(2*Math.PI*i.x/t.clientWidth*n.rotateSpeed),n.rotateUp(2*Math.PI*i.y/t.clientHeight*n.rotateSpeed),a.copy(o),n.update();break;case 2:if(!0===n.noZoom)return;if(4!==y)return;var r=e.touches[0].pageX-e.touches[1].pageX,f=e.touches[0].pageY-e.touches[1].pageY,h=Math.sqrt(r*r+f*f);d.set(0,h),p.subVectors(d,c),p.y>0?n.dollyOut():n.dollyIn(),c.copy(d),n.update();break;case 3:if(!0===n.noPan)return;if(5!==y)return;l.set(e.touches[0].pageX,e.touches[0].pageY),u.subVectors(l,s),n.pan(u.x,u.y),s.copy(l),n.update();break;default:y=m}}}),!1),window.addEventListener("keydown",(function(e){if(!1!==n.enabled&&!0!==n.noKeys&&!0!==n.noPan)switch(e.keyCode){case n.keys.UP:n.pan(0,n.keyPanSpeed),n.update();break;case n.keys.BOTTOM:n.pan(0,-n.keyPanSpeed),n.update();break;case n.keys.LEFT:n.pan(n.keyPanSpeed,0),n.update();break;case n.keys.RIGHT:n.pan(-n.keyPanSpeed,0),n.update()}}),!1)}t.prototype=Object.create(e.EventDispatcher.prototype);const r=(e,t,r,n,a)=>{const o=r.length,i=r[0].length;if(e<0||e>1)throw new Error("t out of bounds [0,1]: "+e);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>o-1)throw new Error("degree must be less than or equal to point count - 1");if(!a){a=[];for(let e=0;e<o;e++)a[e]=1}if(n){if(n.length!==o+t+1)throw new Error("bad knot vector length")}else{n=[];for(let e=0;e<o+t+1;e++)n[e]=e}const s=[t,n.length-1-t],l=n[s[0]],u=n[s[1]];let f;for(e=e*(u-l)+l,e=Math.max(e,l),e=Math.min(e,u),f=s[0];f<s[1]&&!(e>=n[f]&&e<=n[f+1]);f++);const h=[];for(let e=0;e<o;e++){h[e]=[];for(let t=0;t<i;t++)h[e][t]=r[e][t]*a[e];h[e][i]=a[e]}let c;for(let r=1;r<=t+1;r++)for(let a=f;a>f-t-1+r;a--){c=(e-n[a])/(n[a+t+1-r]-n[a]);for(let e=0;e<i+1;e++)h[a][e]=(1-c)*h[a-1][e]+c*h[a][e]}const d=[];for(let e=0;e<i;e++)d[e]=(p=h[f][e]/h[f][i],void 0===(v=-9)||0==+v?Math.round(p):(p=+p,v=+v,isNaN(p)||"number"!=typeof v||v%1!=0?NaN:(p=p.toString().split("e"),+((p=(p=Math.round(+(p[0]+"e"+(p[1]?+p[1]-v:-v)))).toString().split("e"))[0]+"e"+(p[1]?+p[1]+v:v)))));var p,v;return d};function o(){var e,t=0,r=[],n=0,a=0,i=d((function(e){a||l(1,e)})),s=d((function(e){a||l(-1,e)}));function l(r,n){a++;var o=0;try{n===g&&p();var i=r>0&&c(n);i?i.call(n,d((function(e){o++,l(1,e)})),d((function(e){o++,l(-1,e)}))):(t=r,e=n,u())}catch(e){t||o||l(-1,e)}}function u(){n||(setTimeout(f,0),n=1)}function f(){var e=r;n=0,r=[],e.forEach(h)}function h(e){e()}function c(e){var t=e&&(v(e)||"object"==typeof e)&&e.then;return v(t)&&t}function d(e){var t=0;return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t++||e.apply(this,r)}}function p(){throw new TypeError("Chaining cycle detected")}var v=function(e){return"function"==typeof e},g={then:function(n,a){var i=o();return r.push((function(){var r=t>0?n:a;if(v(r))try{var o=r(e);o===i&&p();var s=c(o);s?s.call(o,i.resolve,i.reject):i.resolve(o)}catch(e){i.reject(e)}else i[t>0?"resolve":"reject"](e)})),t&&u(),i},resolve:i,reject:s};return g}function i(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return{then:r.then.bind(r),resolve:e,reject:t}}o.all=i.all=function(e){var t=0,r=[],n=s();return 0===e.length?n.resolve([]):e.forEach((function(a,o){var i=s();i.resolve(a),i.then((function(a){t++,r[o]=a,t===e.length&&n.resolve(r)}),n.reject)})),n};var s="function"==typeof Promise?i:o;function l(){var e=Object.create(null);function t(n,a){var o=n.id,i=n.name,s=n.dependencies;void 0===s&&(s=[]);var l=n.init;void 0===l&&(l=function(){});var u=n.getTransferables;if(void 0===u&&(u=null),!e[o])try{s=s.map((function(r){return r&&r.isWorkerModule&&(t(r,(function(e){if(e instanceof Error)throw e})),r=e[r.id].value),r})),l=r("<"+i+">.init",l),u&&(u=r("<"+i+">.getTransferables",u));var f=null;"function"==typeof l?f=l.apply(void 0,s):console.error("worker module init function failed to rehydrate"),e[o]={id:o,value:f,getTransferables:u},a(f)}catch(e){e&&e.noLog||console.error(e),a(e)}}function r(e,t){var r=void 0;self.troikaDefine=function(e){return r=e};var n=URL.createObjectURL(new Blob(["/** "+e.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+t+"\n)"],{type:"application/javascript"}));try{importScripts(n)}catch(e){console.error(e)}return URL.revokeObjectURL(n),delete self.troikaDefine,r}self.addEventListener("message",(function(r){var n=r.data,a=n.messageId,o=n.action,i=n.data;try{"registerModule"===o&&t(i,(function(e){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:{isCallable:"function"==typeof e}})})),"callModule"===o&&function(t,r){var n,a=t.id,o=t.args;e[a]&&"function"==typeof e[a].value||r(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var i=(n=e[a]).value.apply(n,o);i&&"function"==typeof i.then?i.then(s,(function(e){return r(e instanceof Error?e:new Error(""+e))})):s(i)}catch(e){r(e)}function s(t){try{var n=e[a].getTransferables&&e[a].getTransferables(t);n&&Array.isArray(n)&&n.length||(n=void 0),r(t,n)}catch(e){console.error(e),r(e)}}}(i,(function(e,t){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:e},t||void 0)}))}catch(e){postMessage({messageId:a,success:!1,error:e.stack})}}))}var u=function(){var e=!1;if("undefined"!=typeof window&&void 0!==window.document)try{new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"}))).terminate(),e=!0}catch(e){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+e.message+"]")}return u=function(){return e},e},f=0,h=0,c=!1,d=Object.create(null),p=function(){var e=Object.create(null);return e._count=0,e}();function v(e){if(!(e&&"function"==typeof e.init||c))throw new Error("requires `options.init` function");var t=e.dependencies,r=e.init,n=e.getTransferables,a=e.workerId;if(!u())return function(e){var t=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return t._getInitResult().then((function(t){if("function"==typeof t)return t.apply(void 0,e);throw new Error("Worker module function was called but `init` did not return a callable function")}))};return t._getInitResult=function(){var r=e.dependencies,n=e.init;r=Array.isArray(r)?r.map((function(e){return e&&e._getInitResult?e._getInitResult():e})):[];var a=s.all(r).then((function(e){return n.apply(null,e)}));return t._getInitResult=function(){return a},a},t}(e);null==a&&(a="#default");var o="workerModule"+ ++f,i=e.name||o,l=null;function h(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return l||(l=m(a,"registerModule",h.workerModuleData)),l.then((function(t){if(t.isCallable)return m(a,"callModule",{id:o,args:e});throw new Error("Worker module function was called but `init` did not return a callable function")}))}return t=t&&t.map((function(e){return"function"!=typeof e||e.workerModuleData||(c=!0,e=v({workerId:a,name:"<"+i+"> function dependency: "+e.name,init:"function(){return (\n"+g(e)+"\n)}"}),c=!1),e&&e.workerModuleData&&(e=e.workerModuleData),e})),h.workerModuleData={isWorkerModule:!0,id:o,name:i,dependencies:t,init:g(r),getTransferables:n&&g(n)},h}function g(e){var t=e.toString();return!/^function/.test(t)&&/^\w+\s*\(/.test(t)&&(t="function "+t),t}function m(e,t,r){var n=s(),a=++h;return p[a]=function(e){e.success?n.resolve(e.result):n.reject(new Error("Error in worker "+t+" call: "+e.error))},p._count++,p._count>1e3&&console.warn("Large number of open WorkerModule requests, some may not be returning"),function(e){var t=d[e];if(!t){var r=g(l);(t=d[e]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+e.replace(/\*/g,"")+" **/\n\n;("+r+")()"],{type:"application/javascript"})))).onmessage=function(e){var t=e.data,r=t.messageId,n=p[r];if(!n)throw new Error("WorkerModule response with empty or unknown messageId");delete p[r],p._count--,n(t)}}return t}(e).postMessage({messageId:a,action:t,data:r}),n}var y=v({name:"Thenable",dependencies:[s],init:function(e){return e}});const b=/\bvoid\s+main\s*\(\s*\)\s*{/g;function x(t){return t.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,(function(t,r){let n=e.ShaderChunk[r];return n?x(n):t}))}const S=[];for(let e=0;e<256;e++)S[e]=(e<16?"0":"")+e.toString(16);const k=Object.assign||function(){let e=arguments[0];for(let t=1,r=arguments.length;t<r;t++){let r=arguments[t];if(r)for(let t in r)r.hasOwnProperty(t)&&(e[t]=r[t])}return e},U=Date.now(),w=new WeakMap,_=new Map;let T=1e10;function F(t,r){const n=function(e){const t=JSON.stringify(e,M);let r=P.get(t);return null==r&&P.set(t,r=++I),r}(r);let a=w.get(t);if(a||w.set(t,a=Object.create(null)),a[n])return new a[n];const o=`_onBeforeCompile${n}`,i=function(e){t.onBeforeCompile.call(this,e);const a=n+"|||"+e.vertexShader+"|||"+e.fragmentShader;let i=_[a];if(!i){const t=function({vertexShader:e,fragmentShader:t},r,n){let{vertexDefs:a,vertexMainIntro:o,vertexMainOutro:i,vertexTransform:s,fragmentDefs:l,fragmentMainIntro:u,fragmentMainOutro:f,fragmentColorTransform:h,customRewriter:c,timeUniform:d}=r;if(a=a||"",o=o||"",i=i||"",l=l||"",u=u||"",f=f||"",(s||c)&&(e=x(e)),(h||c)&&(t=x(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"))),c){let r=c({vertexShader:e,fragmentShader:t});e=r.vertexShader,t=r.fragmentShader}if(h){let e=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,(t=>(e.push(t),""))),f=`${h}\n${e.join("\n")}\n${f}`}if(d){const e=`\nuniform float ${d};\n`;a=e+a,l=e+l}return s&&(a=`${a}\nvoid troikaVertexTransform${n}(inout vec3 position, inout vec3 normal, inout vec2 uv) {\n ${s}\n}\n`,o=`\ntroika_position_${n} = vec3(position);\ntroika_normal_${n} = vec3(normal);\ntroika_uv_${n} = vec2(uv);\ntroikaVertexTransform${n}(troika_position_${n}, troika_normal_${n}, troika_uv_${n});\n${o}\n`,e=(e=`vec3 troika_position_${n};\nvec3 troika_normal_${n};\nvec2 troika_uv_${n};\n${e}\n`).replace(/\b(position|normal|uv)\b/g,((e,t,r,a)=>/\battribute\s+vec[23]\s+$/.test(a.substr(0,r))?t:`troika_${t}_${n}`))),{vertexShader:e=C(e,n,a,o,i),fragmentShader:t=C(t,n,l,u,f)}}(e,r,n);i=_[a]=t}e.vertexShader=i.vertexShader,e.fragmentShader=i.fragmentShader,k(e.uniforms,this.uniforms),r.timeUniform&&(e.uniforms[r.timeUniform]={get value(){return Date.now()-U}}),this[o]&&this[o](e)},s=function(){return l(r.chained?t:t.clone())},l=function(e){const a=Object.create(e,u);return Object.defineProperty(a,"baseMaterial",{value:t}),Object.defineProperty(a,"id",{value:T++}),a.uuid=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(S[255&e]+S[e>>8&255]+S[e>>16&255]+S[e>>24&255]+"-"+S[255&t]+S[t>>8&255]+"-"+S[t>>16&15|64]+S[t>>24&255]+"-"+S[63&r|128]+S[r>>8&255]+"-"+S[r>>16&255]+S[r>>24&255]+S[255&n]+S[n>>8&255]+S[n>>16&255]+S[n>>24&255]).toUpperCase()}(),a.uniforms=k({},e.uniforms,r.uniforms),a.defines=k({},e.defines,r.defines),a.defines[`TROIKA_DERIVED_MATERIAL_${n}`]="",a.extensions=k({},e.extensions,r.extensions),a._listeners=void 0,a},u={constructor:{value:s},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return n}},onBeforeCompile:{get:()=>i,set(e){this[o]=e}},copy:{writable:!0,configurable:!0,value:function(r){return t.copy.call(this,r),t.isShaderMaterial||t.isDerivedMaterial||(k(this.extensions,r.extensions),k(this.defines,r.defines),k(this.uniforms,e.UniformsUtils.clone(r.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const e=new t.constructor;return l(e).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let n=this._depthMaterial;return n||(n=this._depthMaterial=F(t.isDerivedMaterial?t.getDepthMaterial():new e.MeshDepthMaterial({depthPacking:e.RGBADepthPacking}),r),n.defines.IS_DEPTH_MATERIAL="",n.uniforms=this.uniforms),n}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let n=this._distanceMaterial;return n||(n=this._distanceMaterial=F(t.isDerivedMaterial?t.getDistanceMaterial():new e.MeshDistanceMaterial,r),n.defines.IS_DISTANCE_MATERIAL="",n.uniforms=this.uniforms),n}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:e,_distanceMaterial:r}=this;e&&e.dispose(),r&&r.dispose(),t.dispose.call(this)}}};return a[n]=s,new s}function C(e,t,r,n,a){return(n||a||r)&&(e=e.replace(b,`\n${r}\nvoid troikaOrigMain${t}() {`),e+=`\nvoid main() {\n ${n}\n troikaOrigMain${t}();\n ${a}\n}`),e}function M(e,t){return"uniforms"===e?void 0:"function"==typeof t?t.toString():t}let I=0;const P=new Map;e.DoubleSide;const O=v({name:"Typr Font Parser",dependencies:[function(){return"undefined"==typeof window&&(self.window=self),function(e){var t={parse:function(e){var r=t._bin,n=new Uint8Array(e);if("ttcf"==r.readASCII(n,0,4)){var a=4;r.readUshort(n,a),a+=2,r.readUshort(n,a),a+=2;var o=r.readUint(n,a);a+=4;for(var i=[],s=0;s<o;s++){var l=r.readUint(n,a);a+=4,i.push(t._readFont(n,l))}return i}return[t._readFont(n,0)]},_readFont:function(e,r){var n=t._bin,a=r;n.readFixed(e,r),r+=4;var o=n.readUshort(e,r);r+=2,n.readUshort(e,r),r+=2,n.readUshort(e,r),r+=2,n.readUshort(e,r),r+=2;for(var i=["cmap","head","hhea","maxp","hmtx","name","OS/2","post","loca","glyf","kern","CFF ","GPOS","GSUB","SVG "],s={_data:e,_offset:a},l={},u=0;u<o;u++){var f=n.readASCII(e,r,4);r+=4,n.readUint(e,r),r+=4;var h=n.readUint(e,r);r+=4;var c=n.readUint(e,r);r+=4,l[f]={offset:h,length:c}}for(u=0;u<i.length;u++){var d=i[u];l[d]&&(s[d.trim()]=t[d.trim()].parse(e,l[d].offset,l[d].length,s))}return s},_tabOffset:function(e,r,n){for(var a=t._bin,o=a.readUshort(e,n+4),i=n+12,s=0;s<o;s++){var l=a.readASCII(e,i,4);i+=4,a.readUint(e,i),i+=4;var u=a.readUint(e,i);if(i+=4,a.readUint(e,i),i+=4,l==r)return u}return 0}};t._bin={readFixed:function(e,t){return(e[t]<<8|e[t+1])+(e[t+2]<<8|e[t+3])/65540},readF2dot14:function(e,r){return t._bin.readShort(e,r)/16384},readInt:function(e,r){var n=t._bin.t.uint8;return n[0]=e[r+3],n[1]=e[r+2],n[2]=e[r+1],n[3]=e[r],t._bin.t.int32[0]},readInt8:function(e,r){return t._bin.t.uint8[0]=e[r],t._bin.t.int8[0]},readShort:function(e,r){var n=t._bin.t.uint8;return n[1]=e[r],n[0]=e[r+1],t._bin.t.int16[0]},readUshort:function(e,t){return e[t]<<8|e[t+1]},readUshorts:function(e,r,n){for(var a=[],o=0;o<n;o++)a.push(t._bin.readUshort(e,r+2*o));return a},readUint:function(e,r){var n=t._bin.t.uint8;return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t._bin.t.uint32[0]},readUint64:function(e,r){return 4294967296*t._bin.readUint(e,r)+t._bin.readUint(e,r+4)},readASCII:function(e,t,r){for(var n="",a=0;a<r;a++)n+=String.fromCharCode(e[t+a]);return n},readUnicode:function(e,t,r){for(var n="",a=0;a<r;a++){var o=e[t++]<<8|e[t++];n+=String.fromCharCode(o)}return n},_tdec:"undefined"!=typeof window&&window.TextDecoder?new window.TextDecoder:null,readUTF8:function(e,r,n){var a=t._bin._tdec;return a&&0==r&&n==e.length?a.decode(e):t._bin.readASCII(e,r,n)},readBytes:function(e,t,r){for(var n=[],a=0;a<r;a++)n.push(e[t+a]);return n},readASCIIArray:function(e,t,r){for(var n=[],a=0;a<r;a++)n.push(String.fromCharCode(e[t+a]));return n}},t._bin.t={buff:new ArrayBuffer(8)},t._bin.t.int8=new Int8Array(t._bin.t.buff),t._bin.t.uint8=new Uint8Array(t._bin.t.buff),t._bin.t.int16=new Int16Array(t._bin.t.buff),t._bin.t.uint16=new Uint16Array(t._bin.t.buff),t._bin.t.int32=new Int32Array(t._bin.t.buff),t._bin.t.uint32=new Uint32Array(t._bin.t.buff),t._lctf={},t._lctf.parse=function(e,r,n,a,o){var i=t._bin,s={},l=r;i.readFixed(e,r),r+=4;var u=i.readUshort(e,r);r+=2;var f=i.readUshort(e,r);r+=2;var h=i.readUshort(e,r);return r+=2,s.scriptList=t._lctf.readScriptList(e,l+u),s.featureList=t._lctf.readFeatureList(e,l+f),s.lookupList=t._lctf.readLookupList(e,l+h,o),s},t._lctf.readLookupList=function(e,r,n){var a=t._bin,o=r,i=[],s=a.readUshort(e,r);r+=2;for(var l=0;l<s;l++){var u=a.readUshort(e,r);r+=2;var f=t._lctf.readLookupTable(e,o+u,n);i.push(f)}return i},t._lctf.readLookupTable=function(e,r,n){var a=t._bin,o=r,i={tabs:[]};i.ltype=a.readUshort(e,r),r+=2,i.flag=a.readUshort(e,r),r+=2;var s=a.readUshort(e,r);r+=2;for(var l=i.ltype,u=0;u<s;u++){var f=a.readUshort(e,r);r+=2;var h=n(e,l,o+f,i);i.tabs.push(h)}return i},t._lctf.numOfOnes=function(e){for(var t=0,r=0;r<32;r++)0!=(e>>>r&1)&&t++;return t},t._lctf.readClassDef=function(e,r){var n=t._bin,a=[],o=n.readUshort(e,r);if(r+=2,1==o){var i=n.readUshort(e,r);r+=2;var s=n.readUshort(e,r);r+=2;for(var l=0;l<s;l++)a.push(i+l),a.push(i+l),a.push(n.readUshort(e,r)),r+=2}if(2==o){var u=n.readUshort(e,r);for(r+=2,l=0;l<u;l++)a.push(n.readUshort(e,r)),r+=2,a.push(n.readUshort(e,r)),r+=2,a.push(n.readUshort(e,r)),r+=2}return a},t._lctf.getInterval=function(e,t){for(var r=0;r<e.length;r+=3){var n=e[r],a=e[r+1];if(e[r+2],n<=t&&t<=a)return r}return-1},t._lctf.readCoverage=function(e,r){var n=t._bin,a={};a.fmt=n.readUshort(e,r),r+=2;var o=n.readUshort(e,r);return r+=2,1==a.fmt&&(a.tab=n.readUshorts(e,r,o)),2==a.fmt&&(a.tab=n.readUshorts(e,r,3*o)),a},t._lctf.coverageIndex=function(e,r){var n=e.tab;if(1==e.fmt)return n.indexOf(r);if(2==e.fmt){var a=t._lctf.getInterval(n,r);if(-1!=a)return n[a+2]+(r-n[a])}return-1},t._lctf.readFeatureList=function(e,r){var n=t._bin,a=r,o=[],i=n.readUshort(e,r);r+=2;for(var s=0;s<i;s++){var l=n.readASCII(e,r,4);r+=4;var u=n.readUshort(e,r);r+=2;var f=t._lctf.readFeatureTable(e,a+u);f.tag=l.trim(),o.push(f)}return o},t._lctf.readFeatureTable=function(e,r){var n=t._bin,a=r,o={},i=n.readUshort(e,r);r+=2,i>0&&(o.featureParams=a+i);var s=n.readUshort(e,r);r+=2,o.tab=[];for(var l=0;l<s;l++)o.tab.push(n.readUshort(e,r+2*l));return o},t._lctf.readScriptList=function(e,r){var n=t._bin,a=r,o={},i=n.readUshort(e,r);r+=2;for(var s=0;s<i;s++){var l=n.readASCII(e,r,4);r+=4;var u=n.readUshort(e,r);r+=2,o[l.trim()]=t._lctf.readScriptTable(e,a+u)}return o},t._lctf.readScriptTable=function(e,r){var n=t._bin,a=r,o={},i=n.readUshort(e,r);r+=2,o.default=t._lctf.readLangSysTable(e,a+i);var s=n.readUshort(e,r);r+=2;for(var l=0;l<s;l++){var u=n.readASCII(e,r,4);r+=4;var f=n.readUshort(e,r);r+=2,o[u.trim()]=t._lctf.readLangSysTable(e,a+f)}return o},t._lctf.readLangSysTable=function(e,r){var n=t._bin,a={};n.readUshort(e,r),r+=2,a.reqFeature=n.readUshort(e,r),r+=2;var o=n.readUshort(e,r);return r+=2,a.features=n.readUshorts(e,r,o),a},t.CFF={},t.CFF.parse=function(e,r,n){var a=t._bin;(e=new Uint8Array(e.buffer,r,n))[r=0],e[++r],e[++r],e[++r],r++;var o=[];r=t.CFF.readIndex(e,r,o);for(var i=[],s=0;s<o.length-1;s++)i.push(a.readASCII(e,r+o[s],o[s+1]-o[s]));r+=o[o.length-1];var l=[];r=t.CFF.readIndex(e,r,l);var u=[];for(s=0;s<l.length-1;s++)u.push(t.CFF.readDict(e,r+l[s],r+l[s+1]));r+=l[l.length-1];var f=u[0],h=[];r=t.CFF.readIndex(e,r,h);var c=[];for(s=0;s<h.length-1;s++)c.push(a.readASCII(e,r+h[s],h[s+1]-h[s]));if(r+=h[h.length-1],t.CFF.readSubrs(e,r,f),f.CharStrings){r=f.CharStrings,h=[],r=t.CFF.readIndex(e,r,h);var d=[];for(s=0;s<h.length-1;s++)d.push(a.readBytes(e,r+h[s],h[s+1]-h[s]));f.CharStrings=d}if(f.ROS){r=f.FDArray;var p=[];for(r=t.CFF.readIndex(e,r,p),f.FDArray=[],s=0;s<p.length-1;s++){var v=t.CFF.readDict(e,r+p[s],r+p[s+1]);t.CFF._readFDict(e,v,c),f.FDArray.push(v)}r+=p[p.length-1],r=f.FDSelect,f.FDSelect=[];var g=e[r];if(r++,3!=g)throw g;var m=a.readUshort(e,r);for(r+=2,s=0;s<m+1;s++)f.FDSelect.push(a.readUshort(e,r),e[r+2]),r+=3}return f.Encoding&&(f.Encoding=t.CFF.readEncoding(e,f.Encoding,f.CharStrings.length)),f.charset&&(f.charset=t.CFF.readCharset(e,f.charset,f.CharStrings.length)),t.CFF._readFDict(e,f,c),f},t.CFF._readFDict=function(e,r,n){var a;for(var o in r.Private&&(a=r.Private[1],r.Private=t.CFF.readDict(e,a,a+r.Private[0]),r.Private.Subrs&&t.CFF.readSubrs(e,a+r.Private.Subrs,r.Private)),r)-1!=["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(o)&&(r[o]=n[r[o]-426+35])},t.CFF.readSubrs=function(e,r,n){var a=t._bin,o=[];r=t.CFF.readIndex(e,r,o);var i,s=o.length;i=s<1240?107:s<33900?1131:32768,n.Bias=i,n.Subrs=[];for(var l=0;l<o.length-1;l++)n.Subrs.push(a.readBytes(e,r+o[l],o[l+1]-o[l]))},t.CFF.tableSE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],t.CFF.glyphByUnicode=function(e,t){for(var r=0;r<e.charset.length;r++)if(e.charset[r]==t)return r;return-1},t.CFF.glyphBySE=function(e,r){return r<0||r>255?-1:t.CFF.glyphByUnicode(e,t.CFF.tableSE[r])},t.CFF.readEncoding=function(e,r,n){t._bin;var a=[".notdef"],o=e[r];if(r++,0!=o)throw"error: unknown encoding format: "+o;var i=e[r];r++;for(var s=0;s<i;s++)a.push(e[r+s]);return a},t.CFF.readCharset=function(e,r,n){var a=t._bin,o=[".notdef"],i=e[r];if(r++,0==i)for(var s=0;s<n;s++){var l=a.readUshort(e,r);r+=2,o.push(l)}else{if(1!=i&&2!=i)throw"error: format: "+i;for(;o.length<n;){l=a.readUshort(e,r),r+=2;var u=0;for(1==i?(u=e[r],r++):(u=a.readUshort(e,r),r+=2),s=0;s<=u;s++)o.push(l),l++}}return o},t.CFF.readIndex=function(e,r,n){var a=t._bin,o=a.readUshort(e,r)+1,i=e[r+=2];if(r++,1==i)for(var s=0;s<o;s++)n.push(e[r+s]);else if(2==i)for(s=0;s<o;s++)n.push(a.readUshort(e,r+2*s));else if(3==i)for(s=0;s<o;s++)n.push(16777215&a.readUint(e,r+3*s-1));else if(1!=o)throw"unsupported offset size: "+i+", count: "+o;return(r+=o*i)-1},t.CFF.getCharString=function(e,r,n){var a=t._bin,o=e[r],i=e[r+1];e[r+2],e[r+3],e[r+4];var s=1,l=null,u=null;o<=20&&(l=o,s=1),12==o&&(l=100*o+i,s=2),21<=o&&o<=27&&(l=o,s=1),28==o&&(u=a.readShort(e,r+1),s=3),29<=o&&o<=31&&(l=o,s=1),32<=o&&o<=246&&(u=o-139,s=1),247<=o&&o<=250&&(u=256*(o-247)+i+108,s=2),251<=o&&o<=254&&(u=256*-(o-251)-i-108,s=2),255==o&&(u=a.readInt(e,r+1)/65535,s=5),n.val=null!=u?u:"o"+l,n.size=s},t.CFF.readCharString=function(e,r,n){for(var a=r+n,o=t._bin,i=[];r<a;){var s=e[r],l=e[r+1];e[r+2],e[r+3],e[r+4];var u=1,f=null,h=null;s<=20&&(f=s,u=1),12==s&&(f=100*s+l,u=2),19!=s&&20!=s||(f=s,u=2),21<=s&&s<=27&&(f=s,u=1),28==s&&(h=o.readShort(e,r+1),u=3),29<=s&&s<=31&&(f=s,u=1),32<=s&&s<=246&&(h=s-139,u=1),247<=s&&s<=250&&(h=256*(s-247)+l+108,u=2),251<=s&&s<=254&&(h=256*-(s-251)-l-108,u=2),255==s&&(h=o.readInt(e,r+1)/65535,u=5),i.push(null!=h?h:"o"+f),r+=u}return i},t.CFF.readDict=function(e,r,n){for(var a=t._bin,o={},i=[];r<n;){var s=e[r],l=e[r+1];e[r+2],e[r+3],e[r+4];var u=1,f=null,h=null;if(28==s&&(h=a.readShort(e,r+1),u=3),29==s&&(h=a.readInt(e,r+1),u=5),32<=s&&s<=246&&(h=s-139,u=1),247<=s&&s<=250&&(h=256*(s-247)+l+108,u=2),251<=s&&s<=254&&(h=256*-(s-251)-l-108,u=2),255==s)throw h=a.readInt(e,r+1)/65535,u=5,"unknown number";if(30==s){var c=[];for(u=1;;){var d=e[r+u];u++;var p=d>>4,v=15&d;if(15!=p&&c.push(p),15!=v&&c.push(v),15==v)break}for(var g="",m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],y=0;y<c.length;y++)g+=m[c[y]];h=parseFloat(g)}s<=21&&(f=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][s],u=1,12==s&&(f=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold",0,0,"LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend",0,0,0,0,0,0,"ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][l],u=2)),null!=f?(o[f]=1==i.length?i[0]:i,i=[]):i.push(h),r+=u}return o},t.cmap={},t.cmap.parse=function(e,r,n){e=new Uint8Array(e.buffer,r,n),r=0;var a=t._bin,o={};a.readUshort(e,r),r+=2;var i=a.readUshort(e,r);r+=2;var s=[];o.tables=[];for(var l=0;l<i;l++){var u=a.readUshort(e,r);r+=2;var f=a.readUshort(e,r);r+=2;var h=a.readUint(e,r);r+=4;var c="p"+u+"e"+f,d=s.indexOf(h);if(-1==d){var p;d=o.tables.length,s.push(h);var v=a.readUshort(e,h);0==v?p=t.cmap.parse0(e,h):4==v?p=t.cmap.parse4(e,h):6==v?p=t.cmap.parse6(e,h):12==v?p=t.cmap.parse12(e,h):console.debug("unknown format: "+v,u,f,h),o.tables.push(p)}if(null!=o[c])throw"multiple tables for one platform+encoding";o[c]=d}return o},t.cmap.parse0=function(e,r){var n=t._bin,a={};a.format=n.readUshort(e,r),r+=2;var o=n.readUshort(e,r);r+=2,n.readUshort(e,r),r+=2,a.map=[];for(var i=0;i<o-6;i++)a.map.push(e[r+i]);return a},t.cmap.parse4=function(e,r){var n=t._bin,a=r,o={};o.format=n.readUshort(e,r),r+=2;var i=n.readUshort(e,r);r+=2,n.readUshort(e,r),r+=2;var s=n.readUshort(e,r);r+=2;var l=s/2;o.searchRange=n.readUshort(e,r),r+=2,o.entrySelector=n.readUshort(e,r),r+=2,o.rangeShift=n.readUshort(e,r),r+=2,o.endCount=n.readUshorts(e,r,l),r+=2*l,r+=2,o.startCount=n.readUshorts(e,r,l),r+=2*l,o.idDelta=[];for(var u=0;u<l;u++)o.idDelta.push(n.readShort(e,r)),r+=2;for(o.idRangeOffset=n.readUshorts(e,r,l),r+=2*l,o.glyphIdArray=[];r<a+i;)o.glyphIdArray.push(n.readUshort(e,r)),r+=2;return o},t.cmap.parse6=function(e,r){var n=t._bin,a={};a.format=n.readUshort(e,r),r+=2,n.readUshort(e,r),r+=2,n.readUshort(e,r),r+=2,a.firstCode=n.readUshort(e,r),r+=2;var o=n.readUshort(e,r);r+=2,a.glyphIdArray=[];for(var i=0;i<o;i++)a.glyphIdArray.push(n.readUshort(e,r)),r+=2;return a},t.cmap.parse12=function(e,r){var n=t._bin,a={};a.format=n.readUshort(e,r),r+=2,r+=2,n.readUint(e,r),r+=4,n.readUint(e,r),r+=4;var o=n.readUint(e,r);r+=4,a.groups=[];for(var i=0;i<o;i++){var s=r+12*i,l=n.readUint(e,s+0),u=n.readUint(e,s+4),f=n.readUint(e,s+8);a.groups.push([l,u,f])}return a},t.glyf={},t.glyf.parse=function(e,t,r,n){for(var a=[],o=0;o<n.maxp.numGlyphs;o++)a.push(null);return a},t.glyf._parseGlyf=function(e,r){var n=t._bin,a=e._data,o=t._tabOffset(a,"glyf",e._offset)+e.loca[r];if(e.loca[r]==e.loca[r+1])return null;var i={};if(i.noc=n.readShort(a,o),o+=2,i.xMin=n.readShort(a,o),o+=2,i.yMin=n.readShort(a,o),o+=2,i.xMax=n.readShort(a,o),o+=2,i.yMax=n.readShort(a,o),o+=2,i.xMin>=i.xMax||i.yMin>=i.yMax)return null;if(i.noc>0){i.endPts=[];for(var s=0;s<i.noc;s++)i.endPts.push(n.readUshort(a,o)),o+=2;var l=n.readUshort(a,o);if(o+=2,a.length-o<l)return null;i.instructions=n.readBytes(a,o,l),o+=l;var u=i.endPts[i.noc-1]+1;for(i.flags=[],s=0;s<u;s++){var f=a[o];if(o++,i.flags.push(f),0!=(8&f)){var h=a[o];o++;for(var c=0;c<h;c++)i.flags.push(f),s++}}for(i.xs=[],s=0;s<u;s++){var d=0!=(2&i.flags[s]),p=0!=(16&i.flags[s]);d?(i.xs.push(p?a[o]:-a[o]),o++):p?i.xs.push(0):(i.xs.push(n.readShort(a,o)),o+=2)}for(i.ys=[],s=0;s<u;s++)d=0!=(4&i.flags[s]),p=0!=(32&i.flags[s]),d?(i.ys.push(p?a[o]:-a[o]),o++):p?i.ys.push(0):(i.ys.push(n.readShort(a,o)),o+=2);var v=0,g=0;for(s=0;s<u;s++)v+=i.xs[s],g+=i.ys[s],i.xs[s]=v,i.ys[s]=g}else{var m;i.parts=[];do{m=n.readUshort(a,o),o+=2;var y={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(i.parts.push(y),y.glyphIndex=n.readUshort(a,o),o+=2,1&m){var b=n.readShort(a,o);o+=2;var x=n.readShort(a,o);o+=2}else b=n.readInt8(a,o),o++,x=n.readInt8(a,o),o++;2&m?(y.m.tx=b,y.m.ty=x):(y.p1=b,y.p2=x),8&m?(y.m.a=y.m.d=n.readF2dot14(a,o),o+=2):64&m?(y.m.a=n.readF2dot14(a,o),o+=2,y.m.d=n.readF2dot14(a,o),o+=2):128&m&&(y.m.a=n.readF2dot14(a,o),o+=2,y.m.b=n.readF2dot14(a,o),o+=2,y.m.c=n.readF2dot14(a,o),o+=2,y.m.d=n.readF2dot14(a,o),o+=2)}while(32&m);if(256&m){var S=n.readUshort(a,o);for(o+=2,i.instr=[],s=0;s<S;s++)i.instr.push(a[o]),o++}}return i},t.GPOS={},t.GPOS.parse=function(e,r,n,a){return t._lctf.parse(e,r,n,a,t.GPOS.subt)},t.GPOS.subt=function(e,r,n,a){var o=t._bin,i=n,s={};if(s.fmt=o.readUshort(e,n),n+=2,1==r||2==r||3==r||7==r||8==r&&s.fmt<=2){var l=o.readUshort(e,n);n+=2,s.coverage=t._lctf.readCoverage(e,l+i)}if(1==r&&1==s.fmt){var u=o.readUshort(e,n);n+=2;var f=t._lctf.numOfOnes(u);0!=u&&(s.pos=t.GPOS.readValueRecord(e,n,u))}else if(2==r&&s.fmt>=1&&s.fmt<=2){u=o.readUshort(e,n),n+=2;var h=o.readUshort(e,n);n+=2,f=t._lctf.numOfOnes(u);var c=t._lctf.numOfOnes(h);if(1==s.fmt){s.pairsets=[];var d=o.readUshort(e,n);n+=2;for(var p=0;p<d;p++){var v=i+o.readUshort(e,n);n+=2;var g=o.readUshort(e,v);v+=2;for(var m=[],y=0;y<g;y++){var b=o.readUshort(e,v);v+=2,0!=u&&(_=t.GPOS.readValueRecord(e,v,u),v+=2*f),0!=h&&(T=t.GPOS.readValueRecord(e,v,h),v+=2*c),m.push({gid2:b,val1:_,val2:T})}s.pairsets.push(m)}}if(2==s.fmt){var x=o.readUshort(e,n);n+=2;var S=o.readUshort(e,n);n+=2;var k=o.readUshort(e,n);n+=2;var U=o.readUshort(e,n);for(n+=2,s.classDef1=t._lctf.readClassDef(e,i+x),s.classDef2=t._lctf.readClassDef(e,i+S),s.matrix=[],p=0;p<k;p++){var w=[];for(y=0;y<U;y++){var _=null,T=null;0!=u&&(_=t.GPOS.readValueRecord(e,n,u),n+=2*f),0!=h&&(T=t.GPOS.readValueRecord(e,n,h),n+=2*c),w.push({val1:_,val2:T})}s.matrix.push(w)}}}else{if(9==r&&1==s.fmt){var F=o.readUshort(e,n);n+=2;var C=o.readUint(e,n);if(n+=4,9==a.ltype)a.ltype=F;else if(a.ltype!=F)throw"invalid extension substitution";return t.GPOS.subt(e,a.ltype,i+C)}console.debug("unsupported GPOS table LookupType",r,"format",s.fmt)}return s},t.GPOS.readValueRecord=function(e,r,n){var a=t._bin,o=[];return o.push(1&n?a.readShort(e,r):0),r+=1&n?2:0,o.push(2&n?a.readShort(e,r):0),r+=2&n?2:0,o.push(4&n?a.readShort(e,r):0),r+=4&n?2:0,o.push(8&n?a.readShort(e,r):0),r+=8&n?2:0,o},t.GSUB={},t.GSUB.parse=function(e,r,n,a){return t._lctf.parse(e,r,n,a,t.GSUB.subt)},t.GSUB.subt=function(e,r,n,a){var o=t._bin,i=n,s={};if(s.fmt=o.readUshort(e,n),n+=2,1!=r&&4!=r&&5!=r&&6!=r)return null;if(1==r||4==r||5==r&&s.fmt<=2||6==r&&s.fmt<=2){var l=o.readUshort(e,n);n+=2,s.coverage=t._lctf.readCoverage(e,i+l)}if(1==r&&s.fmt>=1&&s.fmt<=2){if(1==s.fmt)s.delta=o.readShort(e,n),n+=2;else if(2==s.fmt){var u=o.readUshort(e,n);n+=2,s.newg=o.readUshorts(e,n,u),n+=2*s.newg.length}}else if(4==r){s.vals=[],u=o.readUshort(e,n),n+=2;for(var f=0;f<u;f++){var h=o.readUshort(e,n);n+=2,s.vals.push(t.GSUB.readLigatureSet(e,i+h))}}else if(5==r&&2==s.fmt){if(2==s.fmt){var c=o.readUshort(e,n);n+=2,s.cDef=t._lctf.readClassDef(e,i+c),s.scset=[];var d=o.readUshort(e,n);for(n+=2,f=0;f<d;f++){var p=o.readUshort(e,n);n+=2,s.scset.push(0==p?null:t.GSUB.readSubClassSet(e,i+p))}}}else if(6==r&&3==s.fmt){if(3==s.fmt){for(f=0;f<3;f++){u=o.readUshort(e,n),n+=2;for(var v=[],g=0;g<u;g++)v.push(t._lctf.readCoverage(e,i+o.readUshort(e,n+2*g)));n+=2*u,0==f&&(s.backCvg=v),1==f&&(s.inptCvg=v),2==f&&(s.ahedCvg=v)}u=o.readUshort(e,n),n+=2,s.lookupRec=t.GSUB.readSubstLookupRecords(e,n,u)}}else{if(7==r&&1==s.fmt){var m=o.readUshort(e,n);n+=2;var y=o.readUint(e,n);if(n+=4,9==a.ltype)a.ltype=m;else if(a.ltype!=m)throw"invalid extension substitution";return t.GSUB.subt(e,a.ltype,i+y)}console.debug("unsupported GSUB table LookupType",r,"format",s.fmt)}return s},t.GSUB.readSubClassSet=function(e,r){var n=t._bin.readUshort,a=r,o=[],i=n(e,r);r+=2;for(var s=0;s<i;s++){var l=n(e,r);r+=2,o.push(t.GSUB.readSubClassRule(e,a+l))}return o},t.GSUB.readSubClassRule=function(e,r){var n=t._bin.readUshort,a={},o=n(e,r),i=n(e,r+=2);r+=2,a.input=[];for(var s=0;s<o-1;s++)a.input.push(n(e,r)),r+=2;return a.substLookupRecords=t.GSUB.readSubstLookupRecords(e,r,i),a},t.GSUB.readSubstLookupRecords=function(e,r,n){for(var a=t._bin.readUshort,o=[],i=0;i<n;i++)o.push(a(e,r),a(e,r+2)),r+=4;return o},t.GSUB.readChainSubClassSet=function(e,r){var n=t._bin,a=r,o=[],i=n.readUshort(e,r);r+=2;for(var s=0;s<i;s++){var l=n.readUshort(e,r);r+=2,o.push(t.GSUB.readChainSubClassRule(e,a+l))}return o},t.GSUB.readChainSubClassRule=function(e,r){for(var n=t._bin,a={},o=["backtrack","input","lookahead"],i=0;i<o.length;i++){var s=n.readUshort(e,r);r+=2,1==i&&s--,a[o[i]]=n.readUshorts(e,r,s),r+=2*a[o[i]].length}return s=n.readUshort(e,r),r+=2,a.subst=n.readUshorts(e,r,2*s),r+=2*a.subst.length,a},t.GSUB.readLigatureSet=function(e,r){var n=t._bin,a=r,o=[],i=n.readUshort(e,r);r+=2;for(var s=0;s<i;s++){var l=n.readUshort(e,r);r+=2,o.push(t.GSUB.readLigature(e,a+l))}return o},t.GSUB.readLigature=function(e,r){var n=t._bin,a={chain:[]};a.nglyph=n.readUshort(e,r),r+=2;var o=n.readUshort(e,r);r+=2;for(var i=0;i<o-1;i++)a.chain.push(n.readUshort(e,r)),r+=2;return a},t.head={},t.head.parse=function(e,r,n){var a=t._bin,o={};return a.readFixed(e,r),r+=4,o.fontRevision=a.readFixed(e,r),r+=4,a.readUint(e,r),r+=4,a.readUint(e,r),r+=4,o.flags=a.readUshort(e,r),r+=2,o.unitsPerEm=a.readUshort(e,r),r+=2,o.created=a.readUint64(e,r),r+=8,o.modified=a.readUint64(e,r),r+=8,o.xMin=a.readShort(e,r),r+=2,o.yMin=a.readShort(e,r),r+=2,o.xMax=a.readShort(e,r),r+=2,o.yMax=a.readShort(e,r),r+=2,o.macStyle=a.readUshort(e,r),r+=2,o.lowestRecPPEM=a.readUshort(e,r),r+=2,o.fontDirectionHint=a.readShort(e,r),r+=2,o.indexToLocFormat=a.readShort(e,r),r+=2,o.glyphDataFormat=a.readShort(e,r),r+=2,o},t.hhea={},t.hhea.parse=function(e,r,n){var a=t._bin,o={};return a.readFixed(e,r),r+=4,o.ascender=a.readShort(e,r),r+=2,o.descender=a.readShort(e,r),r+=2,o.lineGap=a.readShort(e,r),r+=2,o.advanceWidthMax=a.readUshort(e,r),r+=2,o.minLeftSideBearing=a.readShort(e,r),r+=2,o.minRightSideBearing=a.readShort(e,r),r+=2,o.xMaxExtent=a.readShort(e,r),r+=2,o.caretSlopeRise=a.readShort(e,r),r+=2,o.caretSlopeRun=a.readShort(e,r),r+=2,o.caretOffset=a.readShort(e,r),r+=2,r+=8,o.metricDataFormat=a.readShort(e,r),r+=2,o.numberOfHMetrics=a.readUshort(e,r),r+=2,o},t.hmtx={},t.hmtx.parse=function(e,r,n,a){for(var o=t._bin,i={aWidth:[],lsBearing:[]},s=0,l=0,u=0;u<a.maxp.numGlyphs;u++)u<a.hhea.numberOfHMetrics&&(s=o.readUshort(e,r),r+=2,l=o.readShort(e,r),r+=2),i.aWidth.push(s),i.lsBearing.push(l);return i},t.kern={},t.kern.parse=function(e,r,n,a){var o=t._bin,i=o.readUshort(e,r);if(r+=2,1==i)return t.kern.parseV1(e,r-2,n,a);var s=o.readUshort(e,r);r+=2;for(var l={glyph1:[],rval:[]},u=0;u<s;u++){r+=2,n=o.readUshort(e,r),r+=2;var f=o.readUshort(e,r);r+=2;var h=f>>>8;if(0!=(h&=15))throw"unknown kern table format: "+h;r=t.kern.readFormat0(e,r,l)}return l},t.kern.parseV1=function(e,r,n,a){var o=t._bin;o.readFixed(e,r),r+=4;var i=o.readUint(e,r);r+=4;for(var s={glyph1:[],rval:[]},l=0;l<i;l++){o.readUint(e,r),r+=4;var u=o.readUshort(e,r);r+=2,o.readUshort(e,r),r+=2;var f=u>>>8;if(0!=(f&=15))throw"unknown kern table format: "+f;r=t.kern.readFormat0(e,r,s)}return s},t.kern.readFormat0=function(e,r,n){var a=t._bin,o=-1,i=a.readUshort(e,r);r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2;for(var s=0;s<i;s++){var l=a.readUshort(e,r);r+=2;var u=a.readUshort(e,r);r+=2;var f=a.readShort(e,r);r+=2,l!=o&&(n.glyph1.push(l),n.rval.push({glyph2:[],vals:[]}));var h=n.rval[n.rval.length-1];h.glyph2.push(u),h.vals.push(f),o=l}return r},t.loca={},t.loca.parse=function(e,r,n,a){var o=t._bin,i=[],s=a.head.indexToLocFormat,l=a.maxp.numGlyphs+1;if(0==s)for(var u=0;u<l;u++)i.push(o.readUshort(e,r+(u<<1))<<1);if(1==s)for(u=0;u<l;u++)i.push(o.readUint(e,r+(u<<2)));return i},t.maxp={},t.maxp.parse=function(e,r,n){var a=t._bin,o={},i=a.readUint(e,r);return r+=4,o.numGlyphs=a.readUshort(e,r),r+=2,65536==i&&(o.maxPoints=a.readUshort(e,r),r+=2,o.maxContours=a.readUshort(e,r),r+=2,o.maxCompositePoints=a.readUshort(e,r),r+=2,o.maxCompositeContours=a.readUshort(e,r),r+=2,o.maxZones=a.readUshort(e,r),r+=2,o.maxTwilightPoints=a.readUshort(e,r),r+=2,o.maxStorage=a.readUshort(e,r),r+=2,o.maxFunctionDefs=a.readUshort(e,r),r+=2,o.maxInstructionDefs=a.readUshort(e,r),r+=2,o.maxStackElements=a.readUshort(e,r),r+=2,o.maxSizeOfInstructions=a.readUshort(e,r),r+=2,o.maxComponentElements=a.readUshort(e,r),r+=2,o.maxComponentDepth=a.readUshort(e,r),r+=2),o},t.name={},t.name.parse=function(e,r,n){var a=t._bin,o={};a.readUshort(e,r),r+=2;var i=a.readUshort(e,r);r+=2,a.readUshort(e,r);for(var s,l=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],u=r+=2,f=0;f<i;f++){var h=a.readUshort(e,r);r+=2;var c=a.readUshort(e,r);r+=2;var d=a.readUshort(e,r);r+=2;var p=a.readUshort(e,r);r+=2;var v=a.readUshort(e,r);r+=2;var g=a.readUshort(e,r);r+=2;var m,y=l[p],b=u+12*i+g;if(0==h)m=a.readUnicode(e,b,v/2);else if(3==h&&0==c)m=a.readUnicode(e,b,v/2);else if(0==c)m=a.readASCII(e,b,v);else if(1==c)m=a.readUnicode(e,b,v/2);else if(3==c)m=a.readUnicode(e,b,v/2);else{if(1!=h)throw"unknown encoding "+c+", platformID: "+h;m=a.readASCII(e,b,v),console.debug("reading unknown MAC encoding "+c+" as ASCII")}var x="p"+h+","+d.toString(16);null==o[x]&&(o[x]={}),o[x][void 0!==y?y:p]=m,o[x]._lang=d}for(var S in o)if(null!=o[S].postScriptName&&1033==o[S]._lang)return o[S];for(var S in o)if(null!=o[S].postScriptName&&0==o[S]._lang)return o[S];for(var S in o)if(null!=o[S].postScriptName&&3084==o[S]._lang)return o[S];for(var S in o)if(null!=o[S].postScriptName)return o[S];for(var S in o){s=S;break}return console.debug("returning name table with languageID "+o[s]._lang),o[s]},t["OS/2"]={},t["OS/2"].parse=function(e,r,n){var a=t._bin.readUshort(e,r);r+=2;var o={};if(0==a)t["OS/2"].version0(e,r,o);else if(1==a)t["OS/2"].version1(e,r,o);else if(2==a||3==a||4==a)t["OS/2"].version2(e,r,o);else{if(5!=a)throw"unknown OS/2 table version: "+a;t["OS/2"].version5(e,r,o)}return o},t["OS/2"].version0=function(e,r,n){var a=t._bin;return n.xAvgCharWidth=a.readShort(e,r),r+=2,n.usWeightClass=a.readUshort(e,r),r+=2,n.usWidthClass=a.readUshort(e,r),r+=2,n.fsType=a.readUshort(e,r),r+=2,n.ySubscriptXSize=a.readShort(e,r),r+=2,n.ySubscriptYSize=a.readShort(e,r),r+=2,n.ySubscriptXOffset=a.readShort(e,r),r+=2,n.ySubscriptYOffset=a.readShort(e,r),r+=2,n.ySuperscriptXSize=a.readShort(e,r),r+=2,n.ySuperscriptYSize=a.readShort(e,r),r+=2,n.ySuperscriptXOffset=a.readShort(e,r),r+=2,n.ySuperscriptYOffset=a.readShort(e,r),r+=2,n.yStrikeoutSize=a.readShort(e,r),r+=2,n.yStrikeoutPosition=a.readShort(e,r),r+=2,n.sFamilyClass=a.readShort(e,r),r+=2,n.panose=a.readBytes(e,r,10),r+=10,n.ulUnicodeRange1=a.readUint(e,r),r+=4,n.ulUnicodeRange2=a.readUint(e,r),r+=4,n.ulUnicodeRange3=a.readUint(e,r),r+=4,n.ulUnicodeRange4=a.readUint(e,r),r+=4,n.achVendID=[a.readInt8(e,r),a.readInt8(e,r+1),a.readInt8(e,r+2),a.readInt8(e,r+3)],r+=4,n.fsSelection=a.readUshort(e,r),r+=2,n.usFirstCharIndex=a.readUshort(e,r),r+=2,n.usLastCharIndex=a.readUshort(e,r),r+=2,n.sTypoAscender=a.readShort(e,r),r+=2,n.sTypoDescender=a.readShort(e,r),r+=2,n.sTypoLineGap=a.readShort(e,r),r+=2,n.usWinAscent=a.readUshort(e,r),r+=2,n.usWinDescent=a.readUshort(e,r),r+2},t["OS/2"].version1=function(e,r,n){var a=t._bin;return r=t["OS/2"].version0(e,r,n),n.ulCodePageRange1=a.readUint(e,r),r+=4,n.ulCodePageRange2=a.readUint(e,r),r+4},t["OS/2"].version2=function(e,r,n){var a=t._bin;return r=t["OS/2"].version1(e,r,n),n.sxHeight=a.readShort(e,r),r+=2,n.sCapHeight=a.readShort(e,r),r+=2,n.usDefault=a.readUshort(e,r),r+=2,n.usBreak=a.readUshort(e,r),r+=2,n.usMaxContext=a.readUshort(e,r),r+2},t["OS/2"].version5=function(e,r,n){var a=t._bin;return r=t["OS/2"].version2(e,r,n),n.usLowerOpticalPointSize=a.readUshort(e,r),r+=2,n.usUpperOpticalPointSize=a.readUshort(e,r),r+2},t.post={},t.post.parse=function(e,r,n){var a=t._bin,o={};return o.version=a.readFixed(e,r),r+=4,o.italicAngle=a.readFixed(e,r),r+=4,o.underlinePosition=a.readShort(e,r),r+=2,o.underlineThickness=a.readShort(e,r),r+=2,o},null==t&&(t={}),null==t.U&&(t.U={}),t.U.codeToGlyph=function(e,t){var r=e.cmap,n=-1;if(null!=r.p0e4?n=r.p0e4:null!=r.p3e1?n=r.p3e1:null!=r.p1e0?n=r.p1e0:null!=r.p0e3&&(n=r.p0e3),-1==n)throw"no familiar platform and encoding!";var a=r.tables[n];if(0==a.format)return t>=a.map.length?0:a.map[t];if(4==a.format){for(var o=-1,i=0;i<a.endCount.length;i++)if(t<=a.endCount[i]){o=i;break}return-1==o||a.startCount[o]>t?0:65535&(0!=a.idRangeOffset[o]?a.glyphIdArray[t-a.startCount[o]+(a.idRangeOffset[o]>>1)-(a.idRangeOffset.length-o)]:t+a.idDelta[o])}if(12==a.format){if(t>a.groups[a.groups.length-1][1])return 0;for(i=0;i<a.groups.length;i++){var s=a.groups[i];if(s[0]<=t&&t<=s[1])return s[2]+(t-s[0])}return 0}throw"unknown cmap table format "+a.format},t.U.glyphToPath=function(e,r){var n={cmds:[],crds:[]};if(e.SVG&&e.SVG.entries[r]){var a=e.SVG.entries[r];return null==a?n:("string"==typeof a&&(a=t.SVG.toPath(a),e.SVG.entries[r]=a),a)}if(e.CFF){var o={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:e.CFF.Private?e.CFF.Private.defaultWidthX:0,open:!1},i=e.CFF,s=e.CFF.Private;if(i.ROS){for(var l=0;i.FDSelect[l+2]<=r;)l+=2;s=i.FDArray[i.FDSelect[l+1]].Private}t.U._drawCFF(e.CFF.CharStrings[r],o,i,s,n)}else e.glyf&&t.U._drawGlyf(r,e,n);return n},t.U._drawGlyf=function(e,r,n){var a=r.glyf[e];null==a&&(a=r.glyf[e]=t.glyf._parseGlyf(r,e)),null!=a&&(a.noc>-1?t.U._simpleGlyph(a,n):t.U._compoGlyph(a,r,n))},t.U._simpleGlyph=function(e,r){for(var n=0;n<e.noc;n++){for(var a=0==n?0:e.endPts[n-1]+1,o=e.endPts[n],i=a;i<=o;i++){var s=i==a?o:i-1,l=i==o?a:i+1,u=1&e.flags[i],f=1&e.flags[s],h=1&e.flags[l],c=e.xs[i],d=e.ys[i];if(i==a)if(u){if(!f){t.U.P.moveTo(r,c,d);continue}t.U.P.moveTo(r,e.xs[s],e.ys[s])}else f?t.U.P.moveTo(r,e.xs[s],e.ys[s]):t.U.P.moveTo(r,(e.xs[s]+c)/2,(e.ys[s]+d)/2);u?f&&t.U.P.lineTo(r,c,d):h?t.U.P.qcurveTo(r,c,d,e.xs[l],e.ys[l]):t.U.P.qcurveTo(r,c,d,(c+e.xs[l])/2,(d+e.ys[l])/2)}t.U.P.closePath(r)}},t.U._compoGlyph=function(e,r,n){for(var a=0;a<e.parts.length;a++){var o={cmds:[],crds:[]},i=e.parts[a];t.U._drawGlyf(i.glyphIndex,r,o);for(var s=i.m,l=0;l<o.crds.length;l+=2){var u=o.crds[l],f=o.crds[l+1];n.crds.push(u*s.a+f*s.b+s.tx),n.crds.push(u*s.c+f*s.d+s.ty)}for(l=0;l<o.cmds.length;l++)n.cmds.push(o.cmds[l])}},t.U._getGlyphClass=function(e,r){var n=t._lctf.getInterval(r,e);return-1==n?0:r[n+2]},t.U.getPairAdjustment=function(e,r,n){var a=0;if(e.GPOS)for(var o=e.GPOS,i=o.lookupList,s=o.featureList,l=[],u=0;u<s.length;u++){var f=s[u];if("kern"==f.tag)for(var h=0;h<f.tab.length;h++)if(!l[f.tab[h]]){l[f.tab[h]]=!0;for(var c=i[f.tab[h]],d=0;d<c.tabs.length;d++)if(null!=c.tabs[d]){var p,v=c.tabs[d];if(!v.coverage||-1!=(p=t._lctf.coverageIndex(v.coverage,r)))if(1==c.ltype);else if(2==c.ltype){var g;if(1==v.fmt){var m=v.pairsets[p];for(u=0;u<m.length;u++)m[u].gid2==n&&(g=m[u])}else if(2==v.fmt){var y=t.U._getGlyphClass(r,v.classDef1),b=t.U._getGlyphClass(n,v.classDef2);g=v.matrix[y][b]}g&&g.val1&&g.val1[2]&&(a+=g.val1[2]),g&&g.val2&&g.val2[0]&&(a+=g.val2[0])}}}}if(e.kern){var x=e.kern.glyph1.indexOf(r);if(-1!=x){var S=e.kern.rval[x].glyph2.indexOf(n);-1!=S&&(a+=e.kern.rval[x].vals[S])}}return a},t.U._applySubs=function(e,r,n,a){for(var o=e.length-r-1,i=0;i<n.tabs.length;i++)if(null!=n.tabs[i]){var s,l=n.tabs[i];if(!l.coverage||-1!=(s=t._lctf.coverageIndex(l.coverage,e[r])))if(1==n.ltype)e[r],1==l.fmt?e[r]=e[r]+l.delta:e[r]=l.newg[s];else if(4==n.ltype)for(var u=l.vals[s],f=0;f<u.length;f++){var h=u[f],c=h.chain.length;if(!(c>o)){for(var d=!0,p=0,v=0;v<c;v++){for(;-1==e[r+p+(1+v)];)p++;h.chain[v]!=e[r+p+(1+v)]&&(d=!1)}if(d){for(e[r]=h.nglyph,v=0;v<c+p;v++)e[r+v+1]=-1;break}}}else if(5==n.ltype&&2==l.fmt)for(var g=t._lctf.getInterval(l.cDef,e[r]),m=l.cDef[g+2],y=l.scset[m],b=0;b<y.length;b++){var x=y[b],S=x.input;if(!(S.length>o)){for(d=!0,v=0;v<S.length;v++){var k=t._lctf.getInterval(l.cDef,e[r+1+v]);if(-1==g&&l.cDef[k+2]!=S[v]){d=!1;break}}if(d){var U=x.substLookupRecords;for(f=0;f<U.length;f+=2)U[f],U[f+1]}}}else if(6==n.ltype&&3==l.fmt){if(!t.U._glsCovered(e,l.backCvg,r-l.backCvg.length))continue;if(!t.U._glsCovered(e,l.inptCvg,r))continue;if(!t.U._glsCovered(e,l.ahedCvg,r+l.inptCvg.length))continue;var w=l.lookupRec;for(b=0;b<w.length;b+=2){g=w[b];var _=a[w[b+1]];t.U._applySubs(e,r+g,_,a)}}}},t.U._glsCovered=function(e,r,n){for(var a=0;a<r.length;a++)if(-1==t._lctf.coverageIndex(r[a],e[n+a]))return!1;return!0},t.U.glyphsToPath=function(e,r,n){for(var a={cmds:[],crds:[]},o=0,i=0;i<r.length;i++){var s=r[i];if(-1!=s){for(var l=i<r.length-1&&-1!=r[i+1]?r[i+1]:0,u=t.U.glyphToPath(e,s),f=0;f<u.crds.length;f+=2)a.crds.push(u.crds[f]+o),a.crds.push(u.crds[f+1]);for(n&&a.cmds.push(n),f=0;f