troika-3d-text
Advanced tools
Comparing version 0.22.0 to 0.23.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [0.23.0](https://github.com/protectwise/troika/compare/v0.22.0...v0.23.0) (2020-04-16) | ||
### Bug Fixes | ||
* **troika-3d-text:** selection range rects now honor clipRect, and are instanced ([ba86004](https://github.com/protectwise/troika/commit/ba860049c46d104fb755a192de56e8e397bb4862)) | ||
### Features | ||
* **troika-worker-modules:** improve rehydration of functions in worker ([8f63090](https://github.com/protectwise/troika/commit/8f63090a5ad4fa3569faeade8e5c532ebfb065c5)), closes [#31](https://github.com/protectwise/troika/issues/31) | ||
# [0.22.0](https://github.com/protectwise/troika/compare/v0.21.0...v0.22.0) (2020-04-02) | ||
@@ -8,0 +24,0 @@ |
@@ -7,46 +7,47 @@ 'use strict';(function(D,y){"object"===typeof exports&&"undefined"!==typeof module?y(exports,require("three"),require("troika-worker-utils"),require("troika-three-utils")):"function"===typeof define&&define.amd?define(["exports","three","troika-worker-utils","troika-three-utils"],y):(D=D||self,y(D.troika_3d_text={},D.THREE,D.troika_worker_utils,D.troika_three_utils))})(this,function(D,y,M,ba){function ca(m,g){m=T({},m);U.href=m.font||K.defaultFontURL;m.font=U.href;m.text=""+m.text;var b=K.sdfGlyphSize, | ||
fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform float uTroikaSDFMinDistancePct;\nuniform bool uTroikaSDFDebug;\nvarying vec2 vTroikaSDFTextureUV;\nvarying vec2 vTroikaGlyphUV;\n\nfloat troikaGetTextAlpha() {\n float troikaSDFValue = texture2D(uTroikaSDFTexture, vTroikaSDFTextureUV).r;\n \n #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)\n float alpha = step(0.5, troikaSDFValue);\n #else\n \n #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n float aaDist = min(\n 0.5,\n 0.5 * min(\n fwidth(vTroikaGlyphUV.x),\n fwidth(vTroikaGlyphUV.y)\n )\n ) / uTroikaSDFMinDistancePct;\n #else\n float aaDist = 0.01;\n #endif\n \n float alpha = uTroikaSDFDebug ? troikaSDFValue : smoothstep(\n 0.5 - aaDist,\n 0.5 + aaDist,\n troikaSDFValue\n );\n #endif\n \n return alpha;\n}\n", | ||
fragmentColorTransform:"\nfloat troikaAlphaMult = troikaGetTextAlpha();\nif (troikaAlphaMult == 0.0) {\n discard;\n} else {\n gl_FragColor.a *= troikaAlphaMult;\n}\n"});m.transparent=!0;Object.defineProperty(m,"shadowSide",{get:function(){return this.side}});return m}var G=M.defineWorkerModule({dependencies:[function(){var m=self,g={parse:function(b){var a=g._bin;b=new Uint8Array(b);if("ttcf"==a.readASCII(b,0,4)){var c=4;a.readUshort(b,c);c+=2;a.readUshort(b,c);c+=2;var d=a.readUint(b,c);c+=4;for(var e= | ||
[],f=0;f<d;f++){var h=a.readUint(b,c);c+=4;e.push(g._readFont(b,h))}return e}return[g._readFont(b,0)]},_readFont:function(b,a){var c=g._bin,d=a;c.readFixed(b,a);a+=4;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;var f="cmap;head;hhea;maxp;hmtx;name;OS/2;post;loca;glyf;kern;CFF ;GPOS;GSUB;SVG ".split(";");d={_data:b,_offset:d};for(var h={},k=0;k<e;k++){var l=c.readASCII(b,a,4);a+=4;c.readUint(b,a);a+=4;var q=c.readUint(b,a);a+=4;var u=c.readUint(b, | ||
a);a+=4;h[l]={offset:q,length:u}}for(k=0;k<f.length;k++)a=f[k],h[a]&&(d[a.trim()]=g[a.trim()].parse(b,h[a].offset,h[a].length,d));return d},_tabOffset:function(b,a,c){var d=g._bin,e=d.readUshort(b,c+4);c+=12;for(var f=0;f<e;f++){var h=d.readASCII(b,c,4);c+=4;d.readUint(b,c);c+=4;var k=d.readUint(b,c);c+=4;d.readUint(b,c);c+=4;if(h==a)return k}return 0}};g._bin={readFixed:function(b,a){return(b[a]<<8|b[a+1])+(b[a+2]<<8|b[a+3])/65540},readF2dot14:function(b,a){return g._bin.readShort(b,a)/16384},readInt:function(b, | ||
a){var c=g._bin.t.uint8;c[0]=b[a+3];c[1]=b[a+2];c[2]=b[a+1];c[3]=b[a];return g._bin.t.int32[0]},readInt8:function(b,a){g._bin.t.uint8[0]=b[a];return g._bin.t.int8[0]},readShort:function(b,a){var c=g._bin.t.uint8;c[1]=b[a];c[0]=b[a+1];return g._bin.t.int16[0]},readUshort:function(b,a){return b[a]<<8|b[a+1]},readUshorts:function(b,a,c){for(var d=[],e=0;e<c;e++)d.push(g._bin.readUshort(b,a+2*e));return d},readUint:function(b,a){var c=g._bin.t.uint8;c[3]=b[a];c[2]=b[a+1];c[1]=b[a+2];c[0]=b[a+3];return g._bin.t.uint32[0]}, | ||
readUint64:function(b,a){return 4294967296*g._bin.readUint(b,a)+g._bin.readUint(b,a+4)},readASCII:function(b,a,c){for(var d="",e=0;e<c;e++)d+=String.fromCharCode(b[a+e]);return d},readUnicode:function(b,a,c){for(var d="",e=0;e<c;e++){var f=b[a++]<<8|b[a++];d+=String.fromCharCode(f)}return d},_tdec:m.TextDecoder?new m.TextDecoder:null,readUTF8:function(b,a,c){var d=g._bin._tdec;return d&&0==a&&c==b.length?d.decode(b):g._bin.readASCII(b,a,c)},readBytes:function(b,a,c){for(var d=[],e=0;e<c;e++)d.push(b[a+ | ||
e]);return d},readASCIIArray:function(b,a,c){for(var d=[],e=0;e<c;e++)d.push(String.fromCharCode(b[a+e]));return d}};g._bin.t={buff:new ArrayBuffer(8)};g._bin.t.int8=new Int8Array(g._bin.t.buff);g._bin.t.uint8=new Uint8Array(g._bin.t.buff);g._bin.t.int16=new Int16Array(g._bin.t.buff);g._bin.t.uint16=new Uint16Array(g._bin.t.buff);g._bin.t.int32=new Int32Array(g._bin.t.buff);g._bin.t.uint32=new Uint32Array(g._bin.t.buff);g._lctf={};g._lctf.parse=function(b,a,c,d,e){var f=g._bin;c={};d=a;f.readFixed(b, | ||
a);a+=4;var h=f.readUshort(b,a);a+=2;var k=f.readUshort(b,a);a=f.readUshort(b,a+2);c.scriptList=g._lctf.readScriptList(b,d+h);c.featureList=g._lctf.readFeatureList(b,d+k);c.lookupList=g._lctf.readLookupList(b,d+a,e);return c};g._lctf.readLookupList=function(b,a,c){var d=g._bin,e=a,f=[],h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var l=d.readUshort(b,a);a+=2;l=g._lctf.readLookupTable(b,e+l,c);f.push(l)}return f};g._lctf.readLookupTable=function(b,a,c){var d=g._bin,e=a,f={tabs:[]};f.ltype=d.readUshort(b, | ||
a);a+=2;f.flag=d.readUshort(b,a);a+=2;var h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var l=d.readUshort(b,a);a+=2;l=c(b,f.ltype,e+l);f.tabs.push(l)}return f};g._lctf.numOfOnes=function(b){for(var a=0,c=0;32>c;c++)0!=(b>>>c&1)&&a++;return a};g._lctf.readClassDef=function(b,a){var c=g._bin,d=[],e=c.readUshort(b,a);a+=2;if(1==e){var f=c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++)d.push(f+k),d.push(f+k),d.push(c.readUshort(b,a)),a+=2}if(2==e)for(e=c.readUshort(b,a),a+=2, | ||
k=0;k<e;k++)d.push(c.readUshort(b,a)),a+=2,d.push(c.readUshort(b,a)),a+=2,d.push(c.readUshort(b,a)),a+=2;return d};g._lctf.getInterval=function(b,a){for(var c=0;c<b.length;c+=3){var d=b[c+1];if(b[c]<=a&&a<=d)return c}return-1};g._lctf.readCoverage=function(b,a){var c=g._bin,d={};d.fmt=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;1==d.fmt&&(d.tab=c.readUshorts(b,a,e));2==d.fmt&&(d.tab=c.readUshorts(b,a,3*e));return d};g._lctf.coverageIndex=function(b,a){var c=b.tab;return 1==b.fmt?c.indexOf(a): | ||
2==b.fmt&&(b=g._lctf.getInterval(c,a),-1!=b)?c[b+2]+(a-c[b]):-1};g._lctf.readFeatureList=function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e.push({tag:k.trim(),tab:g._lctf.readFeatureTable(b,d+l)})}return e};g._lctf.readFeatureTable=function(b,a){var c=g._bin;c.readUshort(b,a);a+=2;var d=c.readUshort(b,a);a+=2;for(var e=[],f=0;f<d;f++)e.push(c.readUshort(b,a+2*f));return e};g._lctf.readScriptList=function(b, | ||
a){var c=g._bin,d=a,e={},f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e[k.trim()]=g._lctf.readScriptTable(b,d+l)}return e};g._lctf.readScriptTable=function(b,a){var c=g._bin,d=a,e={},f=c.readUshort(b,a);a+=2;e.default=g._lctf.readLangSysTable(b,d+f);f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e[k.trim()]=g._lctf.readLangSysTable(b,d+l)}return e};g._lctf.readLangSysTable=function(b, | ||
a){var c=g._bin,d={};c.readUshort(b,a);a+=2;d.reqFeature=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);d.features=c.readUshorts(b,a+2,e);return d};g.CFF={};g.CFF.parse=function(b,a,c){var d=g._bin;b=new Uint8Array(b.buffer,a,c);a=0;a++;a++;a++;a++;var e=[];a=g.CFF.readIndex(b,a,e);var f=[];for(c=0;c<e.length-1;c++)f.push(d.readASCII(b,a+e[c],e[c+1]-e[c]));a+=e[e.length-1];e=[];a=g.CFF.readIndex(b,a,e);f=[];for(c=0;c<e.length-1;c++)f.push(g.CFF.readDict(b,a+e[c],a+e[c+1]));a+=e[e.length-1];e=f[0]; | ||
var h=[];a=g.CFF.readIndex(b,a,h);f=[];for(c=0;c<h.length-1;c++)f.push(d.readASCII(b,a+h[c],h[c+1]-h[c]));a+=h[h.length-1];g.CFF.readSubrs(b,a,e);if(e.CharStrings){a=e.CharStrings;h=[];a=g.CFF.readIndex(b,a,h);var k=[];for(c=0;c<h.length-1;c++)k.push(d.readBytes(b,a+h[c],h[c+1]-h[c]));e.CharStrings=k}if(e.ROS){a=e.FDArray;h=[];a=g.CFF.readIndex(b,a,h);e.FDArray=[];for(c=0;c<h.length-1;c++)k=g.CFF.readDict(b,a+h[c],a+h[c+1]),g.CFF._readFDict(b,k,f),e.FDArray.push(k);a=e.FDSelect;e.FDSelect=[];c=b[a]; | ||
a++;if(3==c)for(h=d.readUshort(b,a),a+=2,c=0;c<h+1;c++)e.FDSelect.push(d.readUshort(b,a),b[a+2]),a+=3;else throw c;}e.Encoding&&(e.Encoding=g.CFF.readEncoding(b,e.Encoding,e.CharStrings.length));e.charset&&(e.charset=g.CFF.readCharset(b,e.charset,e.CharStrings.length));g.CFF._readFDict(b,e,f);return e};g.CFF._readFDict=function(b,a,c){if(a.Private){var d=a.Private[1];a.Private=g.CFF.readDict(b,d,d+a.Private[0]);a.Private.Subrs&&g.CFF.readSubrs(b,d+a.Private.Subrs,a.Private)}for(var e in a)-1!="FamilyName FontName FullName Notice version Copyright".split(" ").indexOf(e)&& | ||
(a[e]=c[a[e]-426+35])};g.CFF.readSubrs=function(b,a,c){var d=g._bin,e=[];a=g.CFF.readIndex(b,a,e);var f=e.length;c.Bias=1240>f?107:33900>f?1131:32768;c.Subrs=[];for(f=0;f<e.length-1;f++)c.Subrs.push(d.readBytes(b,a+e[f],e[f+1]-e[f]))};g.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];g.CFF.glyphByUnicode=function(b,a){for(var c=0;c<b.charset.length;c++)if(b.charset[c]== | ||
a)return c;return-1};g.CFF.glyphBySE=function(b,a){return 0>a||255<a?-1:g.CFF.glyphByUnicode(b,g.CFF.tableSE[a])};g.CFF.readEncoding=function(b,a,c){c=[".notdef"];var d=b[a];a++;if(0==d){d=b[a];a++;for(var e=0;e<d;e++)c.push(b[a+e])}else throw"error: unknown encoding format: "+d;return c};g.CFF.readCharset=function(b,a,c){var d=g._bin,e=[".notdef"],f=b[a];a++;if(0==f)for(var h=0;h<c;h++){var k=d.readUshort(b,a);a+=2;e.push(k)}else if(1==f||2==f)for(;e.length<c;){k=d.readUshort(b,a);a+=2;if(1==f){var l= | ||
b[a];a++}else l=d.readUshort(b,a),a+=2;for(h=0;h<=l;h++)e.push(k),k++}else throw"error: format: "+f;return e};g.CFF.readIndex=function(b,a,c){var d=g._bin,e=d.readUshort(b,a)+1;a+=2;var f=b[a];a++;if(1==f)for(var h=0;h<e;h++)c.push(b[a+h]);else if(2==f)for(h=0;h<e;h++)c.push(d.readUshort(b,a+2*h));else if(3==f)for(h=0;h<e;h++)c.push(d.readUint(b,a+3*h-1)&16777215);else if(1!=e)throw"unsupported offset size: "+f+", count: "+e;return a+e*f-1};g.CFF.getCharString=function(b,a,c){var d=g._bin,e=b[a], | ||
f=b[a+1],h=1,k=null,l=null;20>=e&&(k=e,h=1);12==e&&(k=100*e+f,h=2);21<=e&&27>=e&&(k=e,h=1);28==e&&(l=d.readShort(b,a+1),h=3);29<=e&&31>=e&&(k=e,h=1);32<=e&&246>=e&&(l=e-139,h=1);247<=e&&250>=e&&(l=256*(e-247)+f+108,h=2);251<=e&&254>=e&&(l=256*-(e-251)-f-108,h=2);255==e&&(l=d.readInt(b,a+1)/65535,h=5);c.val=null!=l?l:"o"+k;c.size=h};g.CFF.readCharString=function(b,a,c){c=a+c;for(var d=g._bin,e=[];a<c;){var f=b[a],h=b[a+1],k=1,l=null,q=null;20>=f&&(l=f,k=1);12==f&&(l=100*f+h,k=2);if(19==f||20==f)l= | ||
f,k=2;21<=f&&27>=f&&(l=f,k=1);28==f&&(q=d.readShort(b,a+1),k=3);29<=f&&31>=f&&(l=f,k=1);32<=f&&246>=f&&(q=f-139,k=1);247<=f&&250>=f&&(q=256*(f-247)+h+108,k=2);251<=f&&254>=f&&(q=256*-(f-251)-h-108,k=2);255==f&&(q=d.readInt(b,a+1)/65535,k=5);e.push(null!=q?q:"o"+l);a+=k}return e};g.CFF.readDict=function(b,a,c){for(var d=g._bin,e={},f=[];a<c;){var h=b[a],k=b[a+1],l=1,q=null,u=null;28==h&&(u=d.readShort(b,a+1),l=3);29==h&&(u=d.readInt(b,a+1),l=5);32<=h&&246>=h&&(u=h-139,l=1);247<=h&&250>=h&&(u=256*(h- | ||
247)+k+108,l=2);251<=h&&254>=h&&(u=256*-(h-251)-k-108,l=2);if(255==h)throw d.readInt(b,a+1),"unknown number";if(30==h){u=[];for(l=1;;){var n=b[a+l];l++;var r=n>>4;n&=15;15!=r&&u.push(r);15!=n&&u.push(n);if(15==n)break}r="";n=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"];for(var p=0;p<u.length;p++)r+=n[u[p]];u=parseFloat(r)}21>=h&&(l="version Notice FullName FamilyName Weight FontBBox BlueValues OtherBlues FamilyBlues FamilyOtherBlues StdHW StdVW escape UniqueID XUID charset Encoding CharStrings Private Subrs defaultWidthX nominalWidthX".split(" "), | ||
q=l[h],l=1,12==h&&(l=["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"],q=l[k],l=2));null!=q?(e[q]=1==f.length? | ||
f[0]:f,f=[]):f.push(u);a+=l}return e};g.cmap={};g.cmap.parse=function(b,a,c){b=new Uint8Array(b.buffer,a,c);a=0;c=g._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;var f=[];d.tables=[];for(var h=0;h<e;h++){var k=c.readUshort(b,a);a+=2;var l=c.readUshort(b,a);a+=2;var q=c.readUint(b,a);a+=4;var u="p"+k+"e"+l,n=f.indexOf(q);if(-1==n){n=d.tables.length;var r;f.push(q);var p=c.readUshort(b,q);0==p?r=g.cmap.parse0(b,q):4==p?r=g.cmap.parse4(b,q):6==p?r=g.cmap.parse6(b,q):12==p?r=g.cmap.parse12(b, | ||
q):console.log("unknown format: "+p,k,l,q);d.tables.push(r)}if(null!=d[u])throw"multiple tables for one platform+encoding";d[u]=n}return d};g.cmap.parse0=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;d.map=[];for(c=0;c<e-6;c++)d.map.push(b[a+c]);return d};g.cmap.parse4=function(b,a){var c=g._bin,d=a,e={};e.format=c.readUshort(b,a);a+=2;var f=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;h/=2;e.searchRange= | ||
c.readUshort(b,a);a+=2;e.entrySelector=c.readUshort(b,a);a+=2;e.rangeShift=c.readUshort(b,a);a+=2;e.endCount=c.readUshorts(b,a,h);a=a+2*h+2;e.startCount=c.readUshorts(b,a,h);a+=2*h;e.idDelta=[];for(var k=0;k<h;k++)e.idDelta.push(c.readShort(b,a)),a+=2;e.idRangeOffset=c.readUshorts(b,a,h);a+=2*h;for(e.glyphIdArray=[];a<d+f;)e.glyphIdArray.push(c.readUshort(b,a)),a+=2;return e};g.cmap.parse6=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+= | ||
2;d.firstCode=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;d.glyphIdArray=[];for(var f=0;f<e;f++)d.glyphIdArray.push(c.readUshort(b,a)),a+=2;return d};g.cmap.parse12=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a=a+2+2;c.readUint(b,a);a+=4;c.readUint(b,a);a+=4;var e=c.readUint(b,a);a+=4;d.groups=[];for(var f=0;f<e;f++){var h=a+12*f,k=c.readUint(b,h+0),l=c.readUint(b,h+4);h=c.readUint(b,h+8);d.groups.push([k,l,h])}return d};g.glyf={};g.glyf.parse=function(b,a,c,d){b=[];for(a=0;a< | ||
d.maxp.numGlyphs;a++)b.push(null);return b};g.glyf._parseGlyf=function(b,a){var c=g._bin,d=b._data,e=g._tabOffset(d,"glyf",b._offset)+b.loca[a];if(b.loca[a]==b.loca[a+1])return null;b={};b.noc=c.readShort(d,e);e+=2;b.xMin=c.readShort(d,e);e+=2;b.yMin=c.readShort(d,e);e+=2;b.xMax=c.readShort(d,e);e+=2;b.yMax=c.readShort(d,e);e+=2;if(b.xMin>=b.xMax||b.yMin>=b.yMax)return null;if(0<b.noc){b.endPts=[];for(a=0;a<b.noc;a++)b.endPts.push(c.readUshort(d,e)),e+=2;a=c.readUshort(d,e);e+=2;if(d.length-e<a)return null; | ||
b.instructions=c.readBytes(d,e,a);e+=a;var f=b.endPts[b.noc-1]+1;b.flags=[];for(a=0;a<f;a++){var h=d[e];e++;b.flags.push(h);if(0!=(h&8)){var k=d[e];e++;for(var l=0;l<k;l++)b.flags.push(h),a++}}b.xs=[];for(a=0;a<f;a++)h=0!=(b.flags[a]&2),k=0!=(b.flags[a]&16),h?(b.xs.push(k?d[e]:-d[e]),e++):k?b.xs.push(0):(b.xs.push(c.readShort(d,e)),e+=2);b.ys=[];for(a=0;a<f;a++)h=0!=(b.flags[a]&4),k=0!=(b.flags[a]&32),h?(b.ys.push(k?d[e]:-d[e]),e++):k?b.ys.push(0):(b.ys.push(c.readShort(d,e)),e+=2);for(a=e=d=0;a< | ||
f;a++)d+=b.xs[a],e+=b.ys[a],b.xs[a]=d,b.ys[a]=e}else{b.parts=[];do a=c.readUshort(d,e),e+=2,f={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1},b.parts.push(f),f.glyphIndex=c.readUshort(d,e),e+=2,a&1?(h=c.readShort(d,e),e+=2,k=c.readShort(d,e),e+=2):(h=c.readInt8(d,e),e++,k=c.readInt8(d,e),e++),a&2?(f.m.tx=h,f.m.ty=k):(f.p1=h,f.p2=k),a&8?(f.m.a=f.m.d=c.readF2dot14(d,e),e+=2):a&64?(f.m.a=c.readF2dot14(d,e),e+=2,f.m.d=c.readF2dot14(d,e),e+=2):a&128&&(f.m.a=c.readF2dot14(d,e),e+=2,f.m.b=c.readF2dot14(d,e), | ||
e+=2,f.m.c=c.readF2dot14(d,e),e+=2,f.m.d=c.readF2dot14(d,e),e+=2);while(a&32);if(a&256)for(c=c.readUshort(d,e),e+=2,b.instr=[],a=0;a<c;a++)b.instr.push(d[e]),e++}return b};g.GPOS={};g.GPOS.parse=function(b,a,c,d){return g._lctf.parse(b,a,c,d,g.GPOS.subt)};g.GPOS.subt=function(b,a,c){var d=g._bin,e=c,f={};f.fmt=d.readUshort(b,c);c+=2;if(1==a||2==a||3==a||7==a||8==a&&2>=f.fmt){var h=d.readUshort(b,c);c+=2;f.coverage=g._lctf.readCoverage(b,h+e)}if(1==a&&1==f.fmt){var k=d.readUshort(b,c);c+=2;g._lctf.numOfOnes(k); | ||
0!=k&&(f.pos=g.GPOS.readValueRecord(b,c,k))}else if(2==a){k=d.readUshort(b,c);c+=2;var l=d.readUshort(b,c);c+=2;a=g._lctf.numOfOnes(k);h=g._lctf.numOfOnes(l);if(1==f.fmt){f.pairsets=[];var q=d.readUshort(b,c);c+=2;for(var u=0;u<q;u++){var n=e+d.readUshort(b,c);c+=2;var r=d.readUshort(b,n);n+=2;for(var p=[],t=0;t<r;t++){var z=d.readUshort(b,n);n+=2;if(0!=k){var m=g.GPOS.readValueRecord(b,n,k);n+=2*a}if(0!=l){var x=g.GPOS.readValueRecord(b,n,l);n+=2*h}p.push({gid2:z,val1:m,val2:x})}f.pairsets.push(p)}}if(2== | ||
f.fmt)for(m=d.readUshort(b,c),c+=2,x=d.readUshort(b,c),c+=2,k=d.readUshort(b,c),c+=2,d=d.readUshort(b,c),c+=2,f.classDef1=g._lctf.readClassDef(b,e+m),f.classDef2=g._lctf.readClassDef(b,e+x),f.matrix=[],u=0;u<k;u++){e=[];for(t=0;t<d;t++)x=m=null,0!=f.valFmt1&&(m=g.GPOS.readValueRecord(b,c,f.valFmt1),c+=2*a),0!=f.valFmt2&&(x=g.GPOS.readValueRecord(b,c,f.valFmt2),c+=2*h),e.push({val1:m,val2:x});f.matrix.push(e)}}return f};g.GPOS.readValueRecord=function(b,a,c){var d=g._bin,e=[];e.push(c&1?d.readShort(b, | ||
a):0);a+=c&1?2:0;e.push(c&2?d.readShort(b,a):0);a+=c&2?2:0;e.push(c&4?d.readShort(b,a):0);e.push(c&8?d.readShort(b,a+(c&4?2:0)):0);return e};g.GSUB={};g.GSUB.parse=function(b,a,c,d){return g._lctf.parse(b,a,c,d,g.GSUB.subt)};g.GSUB.subt=function(b,a,c){var d=g._bin,e=c,f={};f.fmt=d.readUshort(b,c);c+=2;if(1!=a&&4!=a&&5!=a&&6!=a)return null;if(1==a||4==a||5==a&&2>=f.fmt||6==a&&2>=f.fmt){var h=d.readUshort(b,c);c+=2;f.coverage=g._lctf.readCoverage(b,e+h)}if(1==a)1==f.fmt?f.delta=d.readShort(b,c):2== | ||
f.fmt&&(h=d.readUshort(b,c),f.newg=d.readUshorts(b,c+2,h));else if(4==a)for(f.vals=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++){var k=d.readUshort(b,c);c+=2;f.vals.push(g.GSUB.readLigatureSet(b,e+k))}else if(5==a){if(2==f.fmt)for(a=d.readUshort(b,c),c+=2,f.cDef=g._lctf.readClassDef(b,e+a),f.scset=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++)k=d.readUshort(b,c),c+=2,f.scset.push(0==k?null:g.GSUB.readSubClassSet(b,e+k))}else if(6==a&&3==f.fmt){for(a=0;3>a;a++){h=d.readUshort(b,c);c+=2;k=[];for(var l=0;l<h;l++)k.push(g._lctf.readCoverage(b, | ||
e+d.readUshort(b,c+2*l)));c+=2*h;0==a&&(f.backCvg=k);1==a&&(f.inptCvg=k);2==a&&(f.ahedCvg=k)}h=d.readUshort(b,c);f.lookupRec=g.GSUB.readSubstLookupRecords(b,c+2,h)}return f};g.GSUB.readSubClassSet=function(b,a){var c=g._bin.readUshort,d=a,e=[],f=c(b,a);a+=2;for(var h=0;h<f;h++){var k=c(b,a);a+=2;e.push(g.GSUB.readSubClassRule(b,d+k))}return e};g.GSUB.readSubClassRule=function(b,a){var c=g._bin.readUshort,d={},e=c(b,a);a+=2;var f=c(b,a);a+=2;d.input=[];for(var h=0;h<e-1;h++)d.input.push(c(b,a)),a+= | ||
2;d.substLookupRecords=g.GSUB.readSubstLookupRecords(b,a,f);return d};g.GSUB.readSubstLookupRecords=function(b,a,c){for(var d=g._bin.readUshort,e=[],f=0;f<c;f++)e.push(d(b,a),d(b,a+2)),a+=4;return e};g.GSUB.readChainSubClassSet=function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readUshort(b,a);a+=2;e.push(g.GSUB.readChainSubClassRule(b,d+k))}return e};g.GSUB.readChainSubClassRule=function(b,a){for(var c=g._bin,d={},e=["backtrack","input","lookahead"],f=0;f<e.length;f++){var h= | ||
c.readUshort(b,a);a+=2;1==f&&h--;d[e[f]]=c.readUshorts(b,a,h);a+=2*d[e[f]].length}h=c.readUshort(b,a);d.subst=c.readUshorts(b,a+2,2*h);return d};g.GSUB.readLigatureSet=function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readUshort(b,a);a+=2;e.push(g.GSUB.readLigature(b,d+k))}return e};g.GSUB.readLigature=function(b,a){var c=g._bin,d={chain:[]};d.nglyph=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;for(var f=0;f<e-1;f++)d.chain.push(c.readUshort(b,a)),a+= | ||
2;return d};g.head={};g.head.parse=function(b,a,c){c=g._bin;var d={};c.readFixed(b,a);a+=4;d.fontRevision=c.readFixed(b,a);a+=4;c.readUint(b,a);a+=4;c.readUint(b,a);a+=4;d.flags=c.readUshort(b,a);a+=2;d.unitsPerEm=c.readUshort(b,a);a+=2;d.created=c.readUint64(b,a);a+=8;d.modified=c.readUint64(b,a);a+=8;d.xMin=c.readShort(b,a);a+=2;d.yMin=c.readShort(b,a);a+=2;d.xMax=c.readShort(b,a);a+=2;d.yMax=c.readShort(b,a);a+=2;d.macStyle=c.readUshort(b,a);a+=2;d.lowestRecPPEM=c.readUshort(b,a);a+=2;d.fontDirectionHint= | ||
c.readShort(b,a);a+=2;d.indexToLocFormat=c.readShort(b,a);d.glyphDataFormat=c.readShort(b,a+2);return d};g.hhea={};g.hhea.parse=function(b,a,c){c=g._bin;var d={};c.readFixed(b,a);a+=4;d.ascender=c.readShort(b,a);a+=2;d.descender=c.readShort(b,a);a+=2;d.lineGap=c.readShort(b,a);a+=2;d.advanceWidthMax=c.readUshort(b,a);a+=2;d.minLeftSideBearing=c.readShort(b,a);a+=2;d.minRightSideBearing=c.readShort(b,a);a+=2;d.xMaxExtent=c.readShort(b,a);a+=2;d.caretSlopeRise=c.readShort(b,a);a+=2;d.caretSlopeRun= | ||
c.readShort(b,a);a+=2;d.caretOffset=c.readShort(b,a);a=a+2+8;d.metricDataFormat=c.readShort(b,a);d.numberOfHMetrics=c.readUshort(b,a+2);return d};g.hmtx={};g.hmtx.parse=function(b,a,c,d){c=g._bin;for(var e={aWidth:[],lsBearing:[]},f=0,h=0,k=0;k<d.maxp.numGlyphs;k++)k<d.hhea.numberOfHMetrics&&(f=c.readUshort(b,a),a+=2,h=c.readShort(b,a),a+=2),e.aWidth.push(f),e.lsBearing.push(h);return e};g.kern={};g.kern.parse=function(b,a,c,d){var e=g._bin,f=e.readUshort(b,a);a+=2;if(1==f)return g.kern.parseV1(b, | ||
a-2,c,d);c=e.readUshort(b,a);a+=2;d={glyph1:[],rval:[]};for(f=0;f<c;f++){a+=2;e.readUshort(b,a);a+=2;var h=e.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=g.kern.readFormat0(b,a,d);else throw"unknown kern table format: "+h;}return d};g.kern.parseV1=function(b,a,c,d){c=g._bin;c.readFixed(b,a);a+=4;d=c.readUint(b,a);a+=4;for(var e={glyph1:[],rval:[]},f=0;f<d;f++){c.readUint(b,a);a+=4;var h=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=g.kern.readFormat0(b,a,e);else throw"unknown kern table format: "+ | ||
h;}return e};g.kern.readFormat0=function(b,a,c){var d=g._bin,e=-1,f=d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=d.readUshort(b,a);a+=2;var l=d.readUshort(b,a);a+=2;var q=d.readShort(b,a);a+=2;k!=e&&(c.glyph1.push(k),c.rval.push({glyph2:[],vals:[]}));e=c.rval[c.rval.length-1];e.glyph2.push(l);e.vals.push(q);e=k}return a};g.loca={};g.loca.parse=function(b,a,c,d){c=g._bin;var e=[],f=d.head.indexToLocFormat;d=d.maxp.numGlyphs+ | ||
1;if(0==f)for(var h=0;h<d;h++)e.push(c.readUshort(b,a+(h<<1))<<1);if(1==f)for(h=0;h<d;h++)e.push(c.readUint(b,a+(h<<2)));return e};g.maxp={};g.maxp.parse=function(b,a,c){c=g._bin;var d={},e=c.readUint(b,a);a+=4;d.numGlyphs=c.readUshort(b,a);a+=2;65536==e&&(d.maxPoints=c.readUshort(b,a),a+=2,d.maxContours=c.readUshort(b,a),a+=2,d.maxCompositePoints=c.readUshort(b,a),a+=2,d.maxCompositeContours=c.readUshort(b,a),a+=2,d.maxZones=c.readUshort(b,a),a+=2,d.maxTwilightPoints=c.readUshort(b,a),a+=2,d.maxStorage= | ||
c.readUshort(b,a),a+=2,d.maxFunctionDefs=c.readUshort(b,a),a+=2,d.maxInstructionDefs=c.readUshort(b,a),a+=2,d.maxStackElements=c.readUshort(b,a),a+=2,d.maxSizeOfInstructions=c.readUshort(b,a),a+=2,d.maxComponentElements=c.readUshort(b,a),d.maxComponentDepth=c.readUshort(b,a+2));return d};g.name={};g.name.parse=function(b,a,c){c=g._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;for(var f="copyright fontFamily fontSubfamily ID fullName version postScriptName trademark manufacturer designer description urlVendor urlDesigner licence licenceURL --- typoFamilyName typoSubfamilyName compatibleFull sampleText postScriptCID wwsFamilyName wwsSubfamilyName lightPalette darkPalette".split(" "), | ||
fragmentColorTransform:"\nfloat troikaAlphaMult = troikaGetTextAlpha();\nif (troikaAlphaMult == 0.0) {\n discard;\n} else {\n gl_FragColor.a *= troikaAlphaMult;\n}\n"});m.transparent=!0;Object.defineProperty(m,"shadowSide",{get:function(){return this.side}});return m}var G=M.defineWorkerModule({name:"Typr Font Parser",dependencies:[function(){var m=self,g={parse:function(b){var a=g._bin;b=new Uint8Array(b);if("ttcf"==a.readASCII(b,0,4)){var c=4;a.readUshort(b,c);c+=2;a.readUshort(b,c);c+=2;var d= | ||
a.readUint(b,c);c+=4;for(var e=[],f=0;f<d;f++){var h=a.readUint(b,c);c+=4;e.push(g._readFont(b,h))}return e}return[g._readFont(b,0)]},_readFont:function(b,a){var c=g._bin,d=a;c.readFixed(b,a);a+=4;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;var f="cmap;head;hhea;maxp;hmtx;name;OS/2;post;loca;glyf;kern;CFF ;GPOS;GSUB;SVG ".split(";");d={_data:b,_offset:d};for(var h={},k=0;k<e;k++){var l=c.readASCII(b,a,4);a+=4;c.readUint(b,a);a+=4;var q=c.readUint(b, | ||
a);a+=4;var u=c.readUint(b,a);a+=4;h[l]={offset:q,length:u}}for(k=0;k<f.length;k++)a=f[k],h[a]&&(d[a.trim()]=g[a.trim()].parse(b,h[a].offset,h[a].length,d));return d},_tabOffset:function(b,a,c){var d=g._bin,e=d.readUshort(b,c+4);c+=12;for(var f=0;f<e;f++){var h=d.readASCII(b,c,4);c+=4;d.readUint(b,c);c+=4;var k=d.readUint(b,c);c+=4;d.readUint(b,c);c+=4;if(h==a)return k}return 0}};g._bin={readFixed:function(b,a){return(b[a]<<8|b[a+1])+(b[a+2]<<8|b[a+3])/65540},readF2dot14:function(b,a){return g._bin.readShort(b, | ||
a)/16384},readInt:function(b,a){var c=g._bin.t.uint8;c[0]=b[a+3];c[1]=b[a+2];c[2]=b[a+1];c[3]=b[a];return g._bin.t.int32[0]},readInt8:function(b,a){g._bin.t.uint8[0]=b[a];return g._bin.t.int8[0]},readShort:function(b,a){var c=g._bin.t.uint8;c[1]=b[a];c[0]=b[a+1];return g._bin.t.int16[0]},readUshort:function(b,a){return b[a]<<8|b[a+1]},readUshorts:function(b,a,c){for(var d=[],e=0;e<c;e++)d.push(g._bin.readUshort(b,a+2*e));return d},readUint:function(b,a){var c=g._bin.t.uint8;c[3]=b[a];c[2]=b[a+1]; | ||
c[1]=b[a+2];c[0]=b[a+3];return g._bin.t.uint32[0]},readUint64:function(b,a){return 4294967296*g._bin.readUint(b,a)+g._bin.readUint(b,a+4)},readASCII:function(b,a,c){for(var d="",e=0;e<c;e++)d+=String.fromCharCode(b[a+e]);return d},readUnicode:function(b,a,c){for(var d="",e=0;e<c;e++){var f=b[a++]<<8|b[a++];d+=String.fromCharCode(f)}return d},_tdec:m.TextDecoder?new m.TextDecoder:null,readUTF8:function(b,a,c){var d=g._bin._tdec;return d&&0==a&&c==b.length?d.decode(b):g._bin.readASCII(b,a,c)},readBytes:function(b, | ||
a,c){for(var d=[],e=0;e<c;e++)d.push(b[a+e]);return d},readASCIIArray:function(b,a,c){for(var d=[],e=0;e<c;e++)d.push(String.fromCharCode(b[a+e]));return d}};g._bin.t={buff:new ArrayBuffer(8)};g._bin.t.int8=new Int8Array(g._bin.t.buff);g._bin.t.uint8=new Uint8Array(g._bin.t.buff);g._bin.t.int16=new Int16Array(g._bin.t.buff);g._bin.t.uint16=new Uint16Array(g._bin.t.buff);g._bin.t.int32=new Int32Array(g._bin.t.buff);g._bin.t.uint32=new Uint32Array(g._bin.t.buff);g._lctf={};g._lctf.parse=function(b, | ||
a,c,d,e){var f=g._bin;c={};d=a;f.readFixed(b,a);a+=4;var h=f.readUshort(b,a);a+=2;var k=f.readUshort(b,a);a=f.readUshort(b,a+2);c.scriptList=g._lctf.readScriptList(b,d+h);c.featureList=g._lctf.readFeatureList(b,d+k);c.lookupList=g._lctf.readLookupList(b,d+a,e);return c};g._lctf.readLookupList=function(b,a,c){var d=g._bin,e=a,f=[],h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var l=d.readUshort(b,a);a+=2;l=g._lctf.readLookupTable(b,e+l,c);f.push(l)}return f};g._lctf.readLookupTable=function(b,a,c){var d= | ||
g._bin,e=a,f={tabs:[]};f.ltype=d.readUshort(b,a);a+=2;f.flag=d.readUshort(b,a);a+=2;var h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var l=d.readUshort(b,a);a+=2;l=c(b,f.ltype,e+l);f.tabs.push(l)}return f};g._lctf.numOfOnes=function(b){for(var a=0,c=0;32>c;c++)0!=(b>>>c&1)&&a++;return a};g._lctf.readClassDef=function(b,a){var c=g._bin,d=[],e=c.readUshort(b,a);a+=2;if(1==e){var f=c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++)d.push(f+k),d.push(f+k),d.push(c.readUshort(b, | ||
a)),a+=2}if(2==e)for(e=c.readUshort(b,a),a+=2,k=0;k<e;k++)d.push(c.readUshort(b,a)),a+=2,d.push(c.readUshort(b,a)),a+=2,d.push(c.readUshort(b,a)),a+=2;return d};g._lctf.getInterval=function(b,a){for(var c=0;c<b.length;c+=3){var d=b[c+1];if(b[c]<=a&&a<=d)return c}return-1};g._lctf.readCoverage=function(b,a){var c=g._bin,d={};d.fmt=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;1==d.fmt&&(d.tab=c.readUshorts(b,a,e));2==d.fmt&&(d.tab=c.readUshorts(b,a,3*e));return d};g._lctf.coverageIndex=function(b, | ||
a){var c=b.tab;return 1==b.fmt?c.indexOf(a):2==b.fmt&&(b=g._lctf.getInterval(c,a),-1!=b)?c[b+2]+(a-c[b]):-1};g._lctf.readFeatureList=function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e.push({tag:k.trim(),tab:g._lctf.readFeatureTable(b,d+l)})}return e};g._lctf.readFeatureTable=function(b,a){var c=g._bin;c.readUshort(b,a);a+=2;var d=c.readUshort(b,a);a+=2;for(var e=[],f=0;f<d;f++)e.push(c.readUshort(b,a+2*f)); | ||
return e};g._lctf.readScriptList=function(b,a){var c=g._bin,d=a,e={},f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e[k.trim()]=g._lctf.readScriptTable(b,d+l)}return e};g._lctf.readScriptTable=function(b,a){var c=g._bin,d=a,e={},f=c.readUshort(b,a);a+=2;e.default=g._lctf.readLangSysTable(b,d+f);f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readASCII(b,a,4);a+=4;var l=c.readUshort(b,a);a+=2;e[k.trim()]=g._lctf.readLangSysTable(b,d+l)}return e}; | ||
g._lctf.readLangSysTable=function(b,a){var c=g._bin,d={};c.readUshort(b,a);a+=2;d.reqFeature=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);d.features=c.readUshorts(b,a+2,e);return d};g.CFF={};g.CFF.parse=function(b,a,c){var d=g._bin;b=new Uint8Array(b.buffer,a,c);a=0;a++;a++;a++;a++;var e=[];a=g.CFF.readIndex(b,a,e);var f=[];for(c=0;c<e.length-1;c++)f.push(d.readASCII(b,a+e[c],e[c+1]-e[c]));a+=e[e.length-1];e=[];a=g.CFF.readIndex(b,a,e);f=[];for(c=0;c<e.length-1;c++)f.push(g.CFF.readDict(b,a+e[c], | ||
a+e[c+1]));a+=e[e.length-1];e=f[0];var h=[];a=g.CFF.readIndex(b,a,h);f=[];for(c=0;c<h.length-1;c++)f.push(d.readASCII(b,a+h[c],h[c+1]-h[c]));a+=h[h.length-1];g.CFF.readSubrs(b,a,e);if(e.CharStrings){a=e.CharStrings;h=[];a=g.CFF.readIndex(b,a,h);var k=[];for(c=0;c<h.length-1;c++)k.push(d.readBytes(b,a+h[c],h[c+1]-h[c]));e.CharStrings=k}if(e.ROS){a=e.FDArray;h=[];a=g.CFF.readIndex(b,a,h);e.FDArray=[];for(c=0;c<h.length-1;c++)k=g.CFF.readDict(b,a+h[c],a+h[c+1]),g.CFF._readFDict(b,k,f),e.FDArray.push(k); | ||
a=e.FDSelect;e.FDSelect=[];c=b[a];a++;if(3==c)for(h=d.readUshort(b,a),a+=2,c=0;c<h+1;c++)e.FDSelect.push(d.readUshort(b,a),b[a+2]),a+=3;else throw c;}e.Encoding&&(e.Encoding=g.CFF.readEncoding(b,e.Encoding,e.CharStrings.length));e.charset&&(e.charset=g.CFF.readCharset(b,e.charset,e.CharStrings.length));g.CFF._readFDict(b,e,f);return e};g.CFF._readFDict=function(b,a,c){if(a.Private){var d=a.Private[1];a.Private=g.CFF.readDict(b,d,d+a.Private[0]);a.Private.Subrs&&g.CFF.readSubrs(b,d+a.Private.Subrs, | ||
a.Private)}for(var e in a)-1!="FamilyName FontName FullName Notice version Copyright".split(" ").indexOf(e)&&(a[e]=c[a[e]-426+35])};g.CFF.readSubrs=function(b,a,c){var d=g._bin,e=[];a=g.CFF.readIndex(b,a,e);var f=e.length;c.Bias=1240>f?107:33900>f?1131:32768;c.Subrs=[];for(f=0;f<e.length-1;f++)c.Subrs.push(d.readBytes(b,a+e[f],e[f+1]-e[f]))};g.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];g.CFF.glyphByUnicode=function(b,a){for(var c=0;c<b.charset.length;c++)if(b.charset[c]==a)return c;return-1};g.CFF.glyphBySE=function(b,a){return 0>a||255<a?-1:g.CFF.glyphByUnicode(b,g.CFF.tableSE[a])};g.CFF.readEncoding=function(b,a,c){c=[".notdef"];var d=b[a];a++;if(0==d){d=b[a];a++;for(var e=0;e<d;e++)c.push(b[a+e])}else throw"error: unknown encoding format: "+d;return c};g.CFF.readCharset=function(b,a,c){var d=g._bin,e=[".notdef"],f=b[a]; | ||
a++;if(0==f)for(var h=0;h<c;h++){var k=d.readUshort(b,a);a+=2;e.push(k)}else if(1==f||2==f)for(;e.length<c;){k=d.readUshort(b,a);a+=2;if(1==f){var l=b[a];a++}else l=d.readUshort(b,a),a+=2;for(h=0;h<=l;h++)e.push(k),k++}else throw"error: format: "+f;return e};g.CFF.readIndex=function(b,a,c){var d=g._bin,e=d.readUshort(b,a)+1;a+=2;var f=b[a];a++;if(1==f)for(var h=0;h<e;h++)c.push(b[a+h]);else if(2==f)for(h=0;h<e;h++)c.push(d.readUshort(b,a+2*h));else if(3==f)for(h=0;h<e;h++)c.push(d.readUint(b,a+3* | ||
h-1)&16777215);else if(1!=e)throw"unsupported offset size: "+f+", count: "+e;return a+e*f-1};g.CFF.getCharString=function(b,a,c){var d=g._bin,e=b[a],f=b[a+1],h=1,k=null,l=null;20>=e&&(k=e,h=1);12==e&&(k=100*e+f,h=2);21<=e&&27>=e&&(k=e,h=1);28==e&&(l=d.readShort(b,a+1),h=3);29<=e&&31>=e&&(k=e,h=1);32<=e&&246>=e&&(l=e-139,h=1);247<=e&&250>=e&&(l=256*(e-247)+f+108,h=2);251<=e&&254>=e&&(l=256*-(e-251)-f-108,h=2);255==e&&(l=d.readInt(b,a+1)/65535,h=5);c.val=null!=l?l:"o"+k;c.size=h};g.CFF.readCharString= | ||
function(b,a,c){c=a+c;for(var d=g._bin,e=[];a<c;){var f=b[a],h=b[a+1],k=1,l=null,q=null;20>=f&&(l=f,k=1);12==f&&(l=100*f+h,k=2);if(19==f||20==f)l=f,k=2;21<=f&&27>=f&&(l=f,k=1);28==f&&(q=d.readShort(b,a+1),k=3);29<=f&&31>=f&&(l=f,k=1);32<=f&&246>=f&&(q=f-139,k=1);247<=f&&250>=f&&(q=256*(f-247)+h+108,k=2);251<=f&&254>=f&&(q=256*-(f-251)-h-108,k=2);255==f&&(q=d.readInt(b,a+1)/65535,k=5);e.push(null!=q?q:"o"+l);a+=k}return e};g.CFF.readDict=function(b,a,c){for(var d=g._bin,e={},f=[];a<c;){var h=b[a], | ||
k=b[a+1],l=1,q=null,u=null;28==h&&(u=d.readShort(b,a+1),l=3);29==h&&(u=d.readInt(b,a+1),l=5);32<=h&&246>=h&&(u=h-139,l=1);247<=h&&250>=h&&(u=256*(h-247)+k+108,l=2);251<=h&&254>=h&&(u=256*-(h-251)-k-108,l=2);if(255==h)throw d.readInt(b,a+1),"unknown number";if(30==h){u=[];for(l=1;;){var n=b[a+l];l++;var r=n>>4;n&=15;15!=r&&u.push(r);15!=n&&u.push(n);if(15==n)break}r="";n=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"];for(var p=0;p<u.length;p++)r+=n[u[p]];u=parseFloat(r)}21>=h&&(l= | ||
"version Notice FullName FamilyName Weight FontBBox BlueValues OtherBlues FamilyBlues FamilyOtherBlues StdHW StdVW escape UniqueID XUID charset Encoding CharStrings Private Subrs defaultWidthX nominalWidthX".split(" "),q=l[h],l=1,12==h&&(l=["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"],q=l[k],l=2));null!=q?(e[q]=1==f.length?f[0]:f,f=[]):f.push(u);a+=l}return e};g.cmap={};g.cmap.parse=function(b,a,c){b=new Uint8Array(b.buffer,a,c);a=0;c=g._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;var f=[];d.tables=[];for(var h=0;h<e;h++){var k=c.readUshort(b,a);a+=2;var l=c.readUshort(b,a);a+=2; | ||
var q=c.readUint(b,a);a+=4;var u="p"+k+"e"+l,n=f.indexOf(q);if(-1==n){n=d.tables.length;var r;f.push(q);var p=c.readUshort(b,q);0==p?r=g.cmap.parse0(b,q):4==p?r=g.cmap.parse4(b,q):6==p?r=g.cmap.parse6(b,q):12==p?r=g.cmap.parse12(b,q):console.log("unknown format: "+p,k,l,q);d.tables.push(r)}if(null!=d[u])throw"multiple tables for one platform+encoding";d[u]=n}return d};g.cmap.parse0=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2; | ||
d.map=[];for(c=0;c<e-6;c++)d.map.push(b[a+c]);return d};g.cmap.parse4=function(b,a){var c=g._bin,d=a,e={};e.format=c.readUshort(b,a);a+=2;var f=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;h/=2;e.searchRange=c.readUshort(b,a);a+=2;e.entrySelector=c.readUshort(b,a);a+=2;e.rangeShift=c.readUshort(b,a);a+=2;e.endCount=c.readUshorts(b,a,h);a=a+2*h+2;e.startCount=c.readUshorts(b,a,h);a+=2*h;e.idDelta=[];for(var k=0;k<h;k++)e.idDelta.push(c.readShort(b,a)),a+=2;e.idRangeOffset= | ||
c.readUshorts(b,a,h);a+=2*h;for(e.glyphIdArray=[];a<d+f;)e.glyphIdArray.push(c.readUshort(b,a)),a+=2;return e};g.cmap.parse6=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;d.firstCode=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;d.glyphIdArray=[];for(var f=0;f<e;f++)d.glyphIdArray.push(c.readUshort(b,a)),a+=2;return d};g.cmap.parse12=function(b,a){var c=g._bin,d={};d.format=c.readUshort(b,a);a=a+2+2;c.readUint(b,a);a+=4;c.readUint(b, | ||
a);a+=4;var e=c.readUint(b,a);a+=4;d.groups=[];for(var f=0;f<e;f++){var h=a+12*f,k=c.readUint(b,h+0),l=c.readUint(b,h+4);h=c.readUint(b,h+8);d.groups.push([k,l,h])}return d};g.glyf={};g.glyf.parse=function(b,a,c,d){b=[];for(a=0;a<d.maxp.numGlyphs;a++)b.push(null);return b};g.glyf._parseGlyf=function(b,a){var c=g._bin,d=b._data,e=g._tabOffset(d,"glyf",b._offset)+b.loca[a];if(b.loca[a]==b.loca[a+1])return null;b={};b.noc=c.readShort(d,e);e+=2;b.xMin=c.readShort(d,e);e+=2;b.yMin=c.readShort(d,e);e+= | ||
2;b.xMax=c.readShort(d,e);e+=2;b.yMax=c.readShort(d,e);e+=2;if(b.xMin>=b.xMax||b.yMin>=b.yMax)return null;if(0<b.noc){b.endPts=[];for(a=0;a<b.noc;a++)b.endPts.push(c.readUshort(d,e)),e+=2;a=c.readUshort(d,e);e+=2;if(d.length-e<a)return null;b.instructions=c.readBytes(d,e,a);e+=a;var f=b.endPts[b.noc-1]+1;b.flags=[];for(a=0;a<f;a++){var h=d[e];e++;b.flags.push(h);if(0!=(h&8)){var k=d[e];e++;for(var l=0;l<k;l++)b.flags.push(h),a++}}b.xs=[];for(a=0;a<f;a++)h=0!=(b.flags[a]&2),k=0!=(b.flags[a]&16),h? | ||
(b.xs.push(k?d[e]:-d[e]),e++):k?b.xs.push(0):(b.xs.push(c.readShort(d,e)),e+=2);b.ys=[];for(a=0;a<f;a++)h=0!=(b.flags[a]&4),k=0!=(b.flags[a]&32),h?(b.ys.push(k?d[e]:-d[e]),e++):k?b.ys.push(0):(b.ys.push(c.readShort(d,e)),e+=2);for(a=e=d=0;a<f;a++)d+=b.xs[a],e+=b.ys[a],b.xs[a]=d,b.ys[a]=e}else{b.parts=[];do a=c.readUshort(d,e),e+=2,f={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1},b.parts.push(f),f.glyphIndex=c.readUshort(d,e),e+=2,a&1?(h=c.readShort(d,e),e+=2,k=c.readShort(d,e),e+=2):(h=c.readInt8(d, | ||
e),e++,k=c.readInt8(d,e),e++),a&2?(f.m.tx=h,f.m.ty=k):(f.p1=h,f.p2=k),a&8?(f.m.a=f.m.d=c.readF2dot14(d,e),e+=2):a&64?(f.m.a=c.readF2dot14(d,e),e+=2,f.m.d=c.readF2dot14(d,e),e+=2):a&128&&(f.m.a=c.readF2dot14(d,e),e+=2,f.m.b=c.readF2dot14(d,e),e+=2,f.m.c=c.readF2dot14(d,e),e+=2,f.m.d=c.readF2dot14(d,e),e+=2);while(a&32);if(a&256)for(c=c.readUshort(d,e),e+=2,b.instr=[],a=0;a<c;a++)b.instr.push(d[e]),e++}return b};g.GPOS={};g.GPOS.parse=function(b,a,c,d){return g._lctf.parse(b,a,c,d,g.GPOS.subt)};g.GPOS.subt= | ||
function(b,a,c){var d=g._bin,e=c,f={};f.fmt=d.readUshort(b,c);c+=2;if(1==a||2==a||3==a||7==a||8==a&&2>=f.fmt){var h=d.readUshort(b,c);c+=2;f.coverage=g._lctf.readCoverage(b,h+e)}if(1==a&&1==f.fmt){var k=d.readUshort(b,c);c+=2;g._lctf.numOfOnes(k);0!=k&&(f.pos=g.GPOS.readValueRecord(b,c,k))}else if(2==a){k=d.readUshort(b,c);c+=2;var l=d.readUshort(b,c);c+=2;a=g._lctf.numOfOnes(k);h=g._lctf.numOfOnes(l);if(1==f.fmt){f.pairsets=[];var q=d.readUshort(b,c);c+=2;for(var u=0;u<q;u++){var n=e+d.readUshort(b, | ||
c);c+=2;var r=d.readUshort(b,n);n+=2;for(var p=[],t=0;t<r;t++){var z=d.readUshort(b,n);n+=2;if(0!=k){var m=g.GPOS.readValueRecord(b,n,k);n+=2*a}if(0!=l){var x=g.GPOS.readValueRecord(b,n,l);n+=2*h}p.push({gid2:z,val1:m,val2:x})}f.pairsets.push(p)}}if(2==f.fmt)for(m=d.readUshort(b,c),c+=2,x=d.readUshort(b,c),c+=2,k=d.readUshort(b,c),c+=2,d=d.readUshort(b,c),c+=2,f.classDef1=g._lctf.readClassDef(b,e+m),f.classDef2=g._lctf.readClassDef(b,e+x),f.matrix=[],u=0;u<k;u++){e=[];for(t=0;t<d;t++)x=m=null,0!= | ||
f.valFmt1&&(m=g.GPOS.readValueRecord(b,c,f.valFmt1),c+=2*a),0!=f.valFmt2&&(x=g.GPOS.readValueRecord(b,c,f.valFmt2),c+=2*h),e.push({val1:m,val2:x});f.matrix.push(e)}}return f};g.GPOS.readValueRecord=function(b,a,c){var d=g._bin,e=[];e.push(c&1?d.readShort(b,a):0);a+=c&1?2:0;e.push(c&2?d.readShort(b,a):0);a+=c&2?2:0;e.push(c&4?d.readShort(b,a):0);e.push(c&8?d.readShort(b,a+(c&4?2:0)):0);return e};g.GSUB={};g.GSUB.parse=function(b,a,c,d){return g._lctf.parse(b,a,c,d,g.GSUB.subt)};g.GSUB.subt=function(b, | ||
a,c){var d=g._bin,e=c,f={};f.fmt=d.readUshort(b,c);c+=2;if(1!=a&&4!=a&&5!=a&&6!=a)return null;if(1==a||4==a||5==a&&2>=f.fmt||6==a&&2>=f.fmt){var h=d.readUshort(b,c);c+=2;f.coverage=g._lctf.readCoverage(b,e+h)}if(1==a)1==f.fmt?f.delta=d.readShort(b,c):2==f.fmt&&(h=d.readUshort(b,c),f.newg=d.readUshorts(b,c+2,h));else if(4==a)for(f.vals=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++){var k=d.readUshort(b,c);c+=2;f.vals.push(g.GSUB.readLigatureSet(b,e+k))}else if(5==a){if(2==f.fmt)for(a=d.readUshort(b,c),c+= | ||
2,f.cDef=g._lctf.readClassDef(b,e+a),f.scset=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++)k=d.readUshort(b,c),c+=2,f.scset.push(0==k?null:g.GSUB.readSubClassSet(b,e+k))}else if(6==a&&3==f.fmt){for(a=0;3>a;a++){h=d.readUshort(b,c);c+=2;k=[];for(var l=0;l<h;l++)k.push(g._lctf.readCoverage(b,e+d.readUshort(b,c+2*l)));c+=2*h;0==a&&(f.backCvg=k);1==a&&(f.inptCvg=k);2==a&&(f.ahedCvg=k)}h=d.readUshort(b,c);f.lookupRec=g.GSUB.readSubstLookupRecords(b,c+2,h)}return f};g.GSUB.readSubClassSet=function(b,a){var c= | ||
g._bin.readUshort,d=a,e=[],f=c(b,a);a+=2;for(var h=0;h<f;h++){var k=c(b,a);a+=2;e.push(g.GSUB.readSubClassRule(b,d+k))}return e};g.GSUB.readSubClassRule=function(b,a){var c=g._bin.readUshort,d={},e=c(b,a);a+=2;var f=c(b,a);a+=2;d.input=[];for(var h=0;h<e-1;h++)d.input.push(c(b,a)),a+=2;d.substLookupRecords=g.GSUB.readSubstLookupRecords(b,a,f);return d};g.GSUB.readSubstLookupRecords=function(b,a,c){for(var d=g._bin.readUshort,e=[],f=0;f<c;f++)e.push(d(b,a),d(b,a+2)),a+=4;return e};g.GSUB.readChainSubClassSet= | ||
function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=c.readUshort(b,a);a+=2;e.push(g.GSUB.readChainSubClassRule(b,d+k))}return e};g.GSUB.readChainSubClassRule=function(b,a){for(var c=g._bin,d={},e=["backtrack","input","lookahead"],f=0;f<e.length;f++){var h=c.readUshort(b,a);a+=2;1==f&&h--;d[e[f]]=c.readUshorts(b,a,h);a+=2*d[e[f]].length}h=c.readUshort(b,a);d.subst=c.readUshorts(b,a+2,2*h);return d};g.GSUB.readLigatureSet=function(b,a){var c=g._bin,d=a,e=[],f=c.readUshort(b, | ||
a);a+=2;for(var h=0;h<f;h++){var k=c.readUshort(b,a);a+=2;e.push(g.GSUB.readLigature(b,d+k))}return e};g.GSUB.readLigature=function(b,a){var c=g._bin,d={chain:[]};d.nglyph=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;for(var f=0;f<e-1;f++)d.chain.push(c.readUshort(b,a)),a+=2;return d};g.head={};g.head.parse=function(b,a,c){c=g._bin;var d={};c.readFixed(b,a);a+=4;d.fontRevision=c.readFixed(b,a);a+=4;c.readUint(b,a);a+=4;c.readUint(b,a);a+=4;d.flags=c.readUshort(b,a);a+=2;d.unitsPerEm=c.readUshort(b, | ||
a);a+=2;d.created=c.readUint64(b,a);a+=8;d.modified=c.readUint64(b,a);a+=8;d.xMin=c.readShort(b,a);a+=2;d.yMin=c.readShort(b,a);a+=2;d.xMax=c.readShort(b,a);a+=2;d.yMax=c.readShort(b,a);a+=2;d.macStyle=c.readUshort(b,a);a+=2;d.lowestRecPPEM=c.readUshort(b,a);a+=2;d.fontDirectionHint=c.readShort(b,a);a+=2;d.indexToLocFormat=c.readShort(b,a);d.glyphDataFormat=c.readShort(b,a+2);return d};g.hhea={};g.hhea.parse=function(b,a,c){c=g._bin;var d={};c.readFixed(b,a);a+=4;d.ascender=c.readShort(b,a);a+=2; | ||
d.descender=c.readShort(b,a);a+=2;d.lineGap=c.readShort(b,a);a+=2;d.advanceWidthMax=c.readUshort(b,a);a+=2;d.minLeftSideBearing=c.readShort(b,a);a+=2;d.minRightSideBearing=c.readShort(b,a);a+=2;d.xMaxExtent=c.readShort(b,a);a+=2;d.caretSlopeRise=c.readShort(b,a);a+=2;d.caretSlopeRun=c.readShort(b,a);a+=2;d.caretOffset=c.readShort(b,a);a=a+2+8;d.metricDataFormat=c.readShort(b,a);d.numberOfHMetrics=c.readUshort(b,a+2);return d};g.hmtx={};g.hmtx.parse=function(b,a,c,d){c=g._bin;for(var e={aWidth:[], | ||
lsBearing:[]},f=0,h=0,k=0;k<d.maxp.numGlyphs;k++)k<d.hhea.numberOfHMetrics&&(f=c.readUshort(b,a),a+=2,h=c.readShort(b,a),a+=2),e.aWidth.push(f),e.lsBearing.push(h);return e};g.kern={};g.kern.parse=function(b,a,c,d){var e=g._bin,f=e.readUshort(b,a);a+=2;if(1==f)return g.kern.parseV1(b,a-2,c,d);c=e.readUshort(b,a);a+=2;d={glyph1:[],rval:[]};for(f=0;f<c;f++){a+=2;e.readUshort(b,a);a+=2;var h=e.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=g.kern.readFormat0(b,a,d);else throw"unknown kern table format: "+ | ||
h;}return d};g.kern.parseV1=function(b,a,c,d){c=g._bin;c.readFixed(b,a);a+=4;d=c.readUint(b,a);a+=4;for(var e={glyph1:[],rval:[]},f=0;f<d;f++){c.readUint(b,a);a+=4;var h=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=g.kern.readFormat0(b,a,e);else throw"unknown kern table format: "+h;}return e};g.kern.readFormat0=function(b,a,c){var d=g._bin,e=-1,f=d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;d.readUshort(b,a);a+=2;for(var h=0;h<f;h++){var k=d.readUshort(b, | ||
a);a+=2;var l=d.readUshort(b,a);a+=2;var q=d.readShort(b,a);a+=2;k!=e&&(c.glyph1.push(k),c.rval.push({glyph2:[],vals:[]}));e=c.rval[c.rval.length-1];e.glyph2.push(l);e.vals.push(q);e=k}return a};g.loca={};g.loca.parse=function(b,a,c,d){c=g._bin;var e=[],f=d.head.indexToLocFormat;d=d.maxp.numGlyphs+1;if(0==f)for(var h=0;h<d;h++)e.push(c.readUshort(b,a+(h<<1))<<1);if(1==f)for(h=0;h<d;h++)e.push(c.readUint(b,a+(h<<2)));return e};g.maxp={};g.maxp.parse=function(b,a,c){c=g._bin;var d={},e=c.readUint(b, | ||
a);a+=4;d.numGlyphs=c.readUshort(b,a);a+=2;65536==e&&(d.maxPoints=c.readUshort(b,a),a+=2,d.maxContours=c.readUshort(b,a),a+=2,d.maxCompositePoints=c.readUshort(b,a),a+=2,d.maxCompositeContours=c.readUshort(b,a),a+=2,d.maxZones=c.readUshort(b,a),a+=2,d.maxTwilightPoints=c.readUshort(b,a),a+=2,d.maxStorage=c.readUshort(b,a),a+=2,d.maxFunctionDefs=c.readUshort(b,a),a+=2,d.maxInstructionDefs=c.readUshort(b,a),a+=2,d.maxStackElements=c.readUshort(b,a),a+=2,d.maxSizeOfInstructions=c.readUshort(b,a),a+= | ||
2,d.maxComponentElements=c.readUshort(b,a),d.maxComponentDepth=c.readUshort(b,a+2));return d};g.name={};g.name.parse=function(b,a,c){c=g._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;c.readUshort(b,a);a+=2;for(var f="copyright fontFamily fontSubfamily ID fullName version postScriptName trademark manufacturer designer description urlVendor urlDesigner licence licenceURL --- typoFamilyName typoSubfamilyName compatibleFull sampleText postScriptCID wwsFamilyName wwsSubfamilyName lightPalette darkPalette".split(" "), | ||
h=a,k=0;k<e;k++){var l=c.readUshort(b,a);a+=2;var q=c.readUshort(b,a);a+=2;var u=c.readUshort(b,a);a+=2;var n=c.readUshort(b,a);a+=2;var r=c.readUshort(b,a);a+=2;var p=c.readUshort(b,a);a+=2;n=f[n];p=h+12*e+p;if(0==l)r=c.readUnicode(b,p,r/2);else if(3==l&&0==q)r=c.readUnicode(b,p,r/2);else if(0==q)r=c.readASCII(b,p,r);else if(1==q)r=c.readUnicode(b,p,r/2);else if(3==q)r=c.readUnicode(b,p,r/2);else if(1==l)r=c.readASCII(b,p,r),console.log("reading unknown MAC encoding "+q+" as ASCII");else throw"unknown encoding "+ | ||
@@ -95,26 +96,26 @@ q+", platformID: "+l;l="p"+l+","+u.toString(16);null==d[l]&&(d[l]={});d[l][n]=r;d[l]._lang=u}for(var t in d)if(null!=d[t].postScriptName&&1033==d[t]._lang)return d[t];for(t in d)if(null!=d[t].postScriptName&&0==d[t]._lang)return d[t];for(t in d)if(null!=d[t].postScriptName&&3084==d[t]._lang)return d[t];for(t in d)if(null!=d[t].postScriptName)return d[t];for(t in d){var z=t;break}console.log("returning name table with languageID "+d[z]._lang);return d[z]};g["OS/2"]={};g["OS/2"].parse=function(b,a, | ||
d)}}}}q.call(null,n,h,l);n.advanceWidth&&(h+=n.advanceWidth*k);g&&(h+=g*d)}l+=65535<b.codePointAt(l)?2:1});return h}};return f}var a={M:2,L:2,Q:4,C:6,Z:0};return function(a){var c=new Uint8Array(a,0,4);c=m._bin.readASCII(c,0,4);if("wOFF"===c)a=g(a);else if("wOF2"===c)throw Error("woff2 fonts not supported");return b(m.parse(a))}}],init:function(m,g,b){m=m();g=g();return b(m,g)}}),K={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff",sdfGlyphSize:64,textureWidth:2048}, | ||
U=document.createElement("a"),V=Object.create(null);G=M.defineWorkerModule({dependencies:[K,.125,G,function(m){function g(a){return a*a}var b=m.sdfTextureSize,a=m.sdfDistancePercent,c=function(a){var b=a.xMin,c=a.yMin,d=a.xMax-b;a=a.yMax-c;this._root={0:null,1:null,2:null,3:null,data:null,cx:Math.round(b+d/2),cy:Math.round(c+a/2),r:Math.pow(2,Math.floor(Math.log(Math.max(d,a))*Math.LOG2E)),minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}};c.prototype.addLineSegment=function(a,b,c,g){this._insertSegment({x0:a, | ||
y0:b,x1:c,y1:g,cx:(a+c)/2,cy:(b+g)/2,minX:Math.min(a,c),minY:Math.min(b,g),maxX:Math.max(a,c),maxY:Math.max(b,g),next:null},this._root)};c.prototype._insertSegment=function(a,b){var c=a.minX,d=a.minY,e=a.maxX,g=a.maxY,q=a.cx,m=a.cy;c<b.minX&&(b.minX=c);d<b.minY&&(b.minY=d);e>b.maxX&&(b.maxX=e);g>b.maxY&&(b.maxY=g);var n=b.data;if(n)if(n.cx===q&&n.cy===m){for(;n.next;)n=n.next;n.next=a}else b.data=null,this._insertSegment(n,b),this._insertSegment(a,b);else q=(m<b.cy?0:2)+(q<b.cx?0:1),b[q]?this._insertSegment(a, | ||
b[q]):b[q]={0:null,1:null,2:null,3:null,data:a,cx:b.cx+b.r/2*(q%2?1:-1),cy:b.cy+b.r/2*(2>q?-1:1),r:b.r/2,minX:c,minY:d,maxX:e,maxY:g}};c.prototype.walkTree=function(a){this.walkBranch(this._root,a)};c.prototype.walkBranch=function(a,b){if(!1!==b(a)&&!a.data)for(var c=0;4>c;c++)null!==a[c]&&this.walkBranch(a[c],b)};c.prototype.findNearestSignedDistance=function(a,b,c){var d=c;this.walkTree(function(c){if(a-d>c.maxX||a+d<c.minX||b-d>c.maxY||b+d<c.minY)return!1;if(c.data)for(c=c.data;c;c=c.next)if(a- | ||
d<c.maxX||a+d>c.minX||b-d<c.maxY||b+d>c.minY){var e=a;var f=b,h=c.x0,k=c.y0,m=c.x1-h,p=c.y1-k,t=m*m+p*p;t=t?Math.max(0,Math.min(1,((e-h)*m+(f-k)*p)/t)):0;e=Math.sqrt(g(e-(h+t*m))+g(f-(k+t*p)));e<d&&(d=e)}});this.isPointInPoly(a,b)||(d=-d);return d};c.prototype.isPointInPoly=function(a,b){var c=!1;this.walkTree(function(d){if(d.maxX<a||d.minY>b||d.maxY<b)return!1;if(d.data)for(d=d.data;d;d=d.next){var e=d.x0,f=d.y0,g=d.x1,h=d.y1;f>b!==h>b&&a<(g-e)*(b-f)/(h-f)+e&&(c=!c)}});return c};return function(d){var e= | ||
new Uint8Array(b*b),f=d.xMax-d.xMin,g=d.yMax-d.yMin,k=Math.max(f,g)*a,l=(f+2*k)/b,m=(g+2*k)/b;g=d.xMin-k-l;f=d.yMin-k-m;l=d.xMax+k+l;m=d.yMax+k+m;if(d.pathCommandCount){var u=new c(d),n,r,p,t;d.forEachPathCommand(function(a,b,c,d,e,f,g){switch(a){case "M":p=n=b;t=r=c;break;case "L":b===p&&c===t||u.addLineSegment(p,t,p=b,t=c);break;case "Q":f={x:p,y:t};for(g=1;16>g;g++){a=g/15;var h=1-a;a={x:h*h*p+2*h*a*b+a*a*d,y:h*h*t+2*h*a*c+a*a*e};u.addLineSegment(f.x,f.y,a.x,a.y);f=a}p=d;t=e;break;case "C":a={x:p, | ||
y:t};for(h=1;16>h;h++){var k=h/15;var l=1-k;k={x:l*l*l*p+3*l*l*k*b+3*l*k*k*d+k*k*k*f,y:l*l*l*t+3*l*l*k*c+3*l*k*k*e+k*k*k*g};u.addLineSegment(a.x,a.y,k.x,k.y);a=k}p=f;t=g;break;case "Z":p===n&&t===r||u.addLineSegment(p,t,n,r)}});for(d=0;d<b;d++)for(var z=0;z<b;z++){var v=u.findNearestSignedDistance(g+(l-g)*(d+.5)/b,f+(m-f)*(z+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[z*b+d]=v}}return{textureData:e,renderingBounds:[g,f,l,m]}}},function(m,g,b){function a(a,b){function c(){var d= | ||
function(b){console.error("Failure loading font "+a+(a===f?"":"; trying fallback"),b);a!==f&&(a=f,c())};try{var e=new XMLHttpRequest;e.open("get",a,!0);e.responseType="arraybuffer";e.onload=function(){if(400<=e.status)d(Error(e.statusText));else if(0<e.status)try{var a=m(e.response);b(a)}catch(p){d(p)}};e.onerror=d;e.send()}catch(r){d(r)}}c()}function c(b,c){b||(b=f);var d=h[b];if(d)d.onload?d.onload.push(c):c();else{var e=h[b]={onload:[c]};a(b,function(a){d=h[b]={fontObj:a,glyphs:{},glyphCount:0}; | ||
e.onload.forEach(function(a){return a()})})}}function d(a,b){a||(a=f);c(a,function(){b(h[a])})}function e(a,b,c){var e=a.text;void 0===e&&(e="");var h=a.font;void 0===h&&(h=f);var k=a.fontSize;void 0===k&&(k=1);var l=a.letterSpacing;void 0===l&&(l=0);var m=a.lineHeight;void 0===m&&(m="normal");var q=a.maxWidth;void 0===q&&(q=Infinity);var v=a.textAlign;void 0===v&&(v="left");var x=a.whiteSpace;void 0===x&&(x="normal");var A=a.overflowWrap;void 0===A&&(A="normal");var y=a.anchor,E=a.includeCaretPositions; | ||
void 0===E&&(E=!1);void 0===c&&(c=!1);-1<e.indexOf("\r")&&(console.warn("FontProcessor.process: got text with \\r chars; normalizing to \\n"),e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"));k=+k;l=+l;q=+q;m=m||"normal";d(h,function(a){var d=a.fontObj,f=isFinite(q),h=null,n=null,p=null,r=null,t=null,u=0,z="nowrap"!==x,B=d.ascender,D=d.descender,C=d.unitsPerEm,I=k/C;"normal"===m&&(m=(B-D)/C);m*=k;var K=(m-(B-D)*I)/2;C=Math.min(m,(B-D)*I);var M=(B+D)/2*I-C/2,N=0,J={glyphs:[],width:0},O=[J];d.forEachGlyph(e, | ||
k,l,function(a,b,c){var d=e.charAt(c),g=a.advanceWidth*I,h=!!d&&/\s/.test(d),m=J.glyphs;if(z&&f&&!h&&b+g+N>q&&m.length){if(m[m.length-1].isWhitespace){var n=[];N=-b}else for(var p=m.length;p--;)if(0===p&&"break-word"===A){n=[];N=-b;break}else if(m[p].isWhitespace){n=m.splice(p+1);m=n[0].x;N-=m;for(p=0;p<n.length;p++)n[p].x-=m;break}n&&(J.isSoftWrapped=!0,J={glyphs:n,width:0},O.push(J),u=q)}J.glyphs.push({glyphObj:a,x:b+N,y:0,width:g,char:d,charIndex:c,isWhitespace:h,isEmpty:a.xMin===a.xMax||a.yMin=== | ||
a.yMax,atlasInfo:null});"\n"===d&&(J={glyphs:[],width:0},O.push(J),N=-(b+g+l*k))});O.forEach(function(a){for(var b=a.glyphs,c=b.length;c--;){var d=b[c];if(!d.isWhitespace){a.width=d.x+d.width;a.width>u&&(u=a.width);break}}});if(!c){var G=[],L=-(k+K);E&&(r=new Float32Array(3*e.length));var H=-1;O.forEach(function(b){var c=b.glyphs,d=b.width;if(c.length){var e=0,f=0;if("center"===v)e=(u-d)/2;else if("right"===v)e=u-d;else if("justify"===v)for(var k=c.length;k--;)if(!c[k].isWhitespace){for(;k--;)c[k].isWhitespace&& | ||
f++;break}k=0;for(var n=c.length;k<n;k++){var l=c[k];e&&(l.x+=e);l.y=L;if(l.isWhitespace&&"justify"===v&&b.isSoftWrapped){var p=(u-d)/f;e+=p;l.width+=p}if(E){p=l.charIndex;r[3*p]=l.x;r[3*p+1]=l.x+l.width;for(r[3*p+2]=l.y+M;1<p-H;)r[3*(H+1)]=r[3*H+1],r[3*(H+1)+1]=r[3*H+1],r[3*(H+1)+2]=r[3*H+2],H++;H=p}if(!l.isWhitespace&&!l.isEmpty){p=l.glyphObj;var q=a.glyphs[p.index];q||(q=g(p),q.atlasIndex=a.glyphCount++,h||(h=[]),h.push(q),q=a.glyphs[p.index]={atlasIndex:q.atlasIndex,glyphObj:p,renderingBounds:q.renderingBounds}); | ||
l.atlasInfo=q;G.push(l)}}}L-=m});var P=0,Q=0;y&&(y[0]&&(P=-u*y[0]),y[1]&&(Q=O.length*m*y[1]));if(E&&(P||Q))for(d=0,B=r.length;d<B;d+=3)r[d]+=P,r[d+1]+=P,r[d+2]+=Q;n=new Float32Array(4*G.length);p=new Float32Array(G.length);t=[Infinity,Infinity,-Infinity,-Infinity];G.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=n[4*b]=a.x+d[0]*I+P,f=n[4*b+1]=a.y+d[1]*I+Q,g=n[4*b+2]=a.x+d[2]*I+P;a=n[4*b+3]=a.y+d[3]*I+Q;e<t[0]&&(t[0]=e);f<t[1]&&(t[1]=f);g>t[2]&&(t[2]=g);a>t[3]&&(t[3]= | ||
a);p[b]=c})}b({glyphBounds:n,glyphAtlasIndices:p,caretPositions:r,caretHeight:C,totalBounds:t,totalBlockSize:[u,O.length*m],newGlyphSDFs:h})})}var f=b.defaultFontUrl,h=Object.create(null);return{process:e,measure:function(a,b){e(a,function(a){b({width:a.totalBlockSize[0],height:a.totalBlockSize[1]})},{metricsOnly:!0})},loadFont:c}}],init:function(m,g,b,a,c){g=a({sdfTextureSize:m.sdfGlyphSize,sdfDistancePercent:g});return c(b,g,{defaultFontUrl:m.defaultFontURL})}});var da=M.defineWorkerModule({dependencies:[G, | ||
M.ThenableWorkerModule],init:function(m,g){return function(b){var a=new g;m.process(b,a.resolve);return a}},getTransferables:function(m){var g=[m.glyphBounds.buffer,m.glyphAtlasIndices.buffer];m.caretPositions&&g.push(m.caretPositions.buffer);m.newGlyphSDFs&&m.newGlyphSDFs.forEach(function(b){g.push(b.textureData.buffer)});return g}}),fa=(new y.PlaneBufferGeometry(1,1)).translate(.5,.5,0),ha=new y.Vector3,L=function(m){function g(){m.call(this);this.copy(fa);this.boundingSphere=new y.Sphere}m&&(g.__proto__= | ||
m);g.prototype=Object.create(m&&m.prototype);g.prototype.constructor=g;g.prototype.computeBoundingSphere=function(){};g.prototype.updateGlyphs=function(b,a,c){W(this,"aTroikaGlyphBounds",b,4);W(this,"aTroikaGlyphIndex",a,1);this.maxInstancedCount=a.length;b=this.boundingSphere;b.center.set((c[0]+c[2])/2,(c[1]+c[3])/2,0);b.radius=b.center.distanceTo(ha.set(c[0],c[1],0))};return g}(y.InstancedBufferGeometry);L.prototype.setAttribute||(L.prototype.setAttribute=function(m,g){this.attributes[m]=g;return this}); | ||
var X=new y.MeshBasicMaterial({color:16777215,side:y.DoubleSide,transparent:!0}),R=new y.Matrix4,Y=new y.Vector3,S=new y.Vector3,ia=new y.Vector3,Z=new y.Mesh((new y.PlaneBufferGeometry(1,1)).translate(.5,.5,0),X),aa=function(m){function g(a){a=new L;m.call(this,a,null);this.text="";this.font=this.anchor=null;this.fontSize=.1;this.letterSpacing=0;this.lineHeight="normal";this.maxWidth=Infinity;this.overflowWrap="normal";this.textAlign="left";this.whiteSpace="normal";this.color=this.material=null; | ||
this.depthOffset=0;this.clipRect=null;this.orientation="+x+y";this.debugSDF=!1}m&&(g.__proto__=m);g.prototype=Object.create(m&&m.prototype);g.prototype.constructor=g;var b={textRenderInfo:{configurable:!0},material:{configurable:!0},customDepthMaterial:{configurable:!0},customDistanceMaterial:{configurable:!0}};g.prototype.sync=function(a){var b=this;this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(a):(this._isSyncing=!0,ca({text:this.text,font:this.font, | ||
fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,textAlign:this.textAlign,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchor:this.anchor,includeCaretPositions:!0},function(c){b._isSyncing=!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphAtlasIndices,c.totalBounds);var d=b._queuedSyncs;d&&(b._queuedSyncs=null,b._needsSync=!0,b.sync(function(){d.forEach(function(a){return a&&a()})}));a&&a()})))}; | ||
g.prototype.onBeforeRender=function(){this.sync();this._prepareMaterial()};g.prototype.dispose=function(){this.geometry.dispose()};b.textRenderInfo.get=function(){return this._textRenderInfo||null};b.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||X;a&&a.baseMaterial===b||(a&&a.dispose(),a=this._derivedMaterial=ea(b),b.addEventListener("dispose",function e(){b.removeEventListener("dispose",e);a.dispose()}));return a};b.material.set=function(a){this._baseMaterial=a};b.customDepthMaterial.get= | ||
function(){return this.material.getDepthMaterial()};b.customDistanceMaterial.get=function(){return this.material.getDistanceMaterial()};g.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=a.uniforms,d=this.textRenderInfo;if(d){var e=d.sdfTexture,f=d.totalBounds;b.uTroikaSDFTexture.value=e;b.uTroikaSDFTextureSize.value.set(e.image.width,e.image.height);b.uTroikaSDFGlyphSize.value=d.sdfGlyphSize;b.uTroikaSDFMinDistancePct.value=d.sdfMinDistancePercent;b.uTroikaTotalBounds.value.fromArray(f); | ||
(d=this.clipRect)&&Array.isArray(d)&&4===d.length?b.uTroikaClipRect.value.set(Math.max(f[0],d[0]),Math.max(f[1],d[1]),Math.min(f[2],d[2]),Math.min(f[3],d[3])):b.uTroikaClipRect.value.fromArray(f)}b.uTroikaSDFDebug.value=!!this.debugSDF;a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;f=this.color;null!=f&&a.color&&a.color.isColor&&f!==a._troikaColor&&a.color.set(a._troikaColor=f);f=this.orientation||"+x+y";if(f!==a._orientation){b=b.uTroikaOrient.value; | ||
f=f.replace(/[^-+xyz]/g,"");var g="+x+y"!==f&&f.match(/^([-+])([xyz])([-+])([xyz])$/);if(g){d=g[1];e=g[2];var k=g[3];g=g[4];Y.set(0,0,0)[e]="-"===d?1:-1;S.set(0,0,0)[g]="-"===k?-1:1;R.lookAt(ia,Y.cross(S),S);b.setFromMatrix4(R)}else b.identity();a._orientation=f}};g.prototype.raycast=function(a,b){var c=this.textRenderInfo;c&&(c=c.totalBounds,Z.matrixWorld.multiplyMatrices(this.matrixWorld,R.set(c[2]-c[0],0,0,c[0],0,c[3]-c[1],0,c[1],0,0,1,0,0,0,0,1)),Z.raycast(a,b))};Object.defineProperties(g.prototype, | ||
b);return g}(y.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(m){var g="_private_"+m;Object.defineProperty(aa.prototype,m,{get:function(){return this[g]},set:"anchor"===m?function(b){JSON.stringify(b)!==JSON.stringify(this[g])&&(this[g]=b,this._needsSync=!0)}:function(b){b!==this[g]&&(this[g]=b,this._needsSync=!0)}})});D.GlyphsGeometry=L;D.TextMesh=aa;D.configureTextBuilder=function(m){T(K,m)};D.fontProcessorWorkerModule= | ||
G;Object.defineProperty(D,"__esModule",{value:!0})}) | ||
U=document.createElement("a"),V=Object.create(null);G=M.defineWorkerModule({name:"FontProcessor",dependencies:[K,.125,G,function(m){function g(a){return a*a}var b=m.sdfTextureSize,a=m.sdfDistancePercent,c=function(a){var b=a.xMin,c=a.yMin,d=a.xMax-b;a=a.yMax-c;this._root={0:null,1:null,2:null,3:null,data:null,cx:Math.round(b+d/2),cy:Math.round(c+a/2),r:Math.pow(2,Math.floor(Math.log(Math.max(d,a))*Math.LOG2E)),minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}};c.prototype.addLineSegment= | ||
function(a,b,c,g){this._insertSegment({x0:a,y0:b,x1:c,y1:g,cx:(a+c)/2,cy:(b+g)/2,minX:Math.min(a,c),minY:Math.min(b,g),maxX:Math.max(a,c),maxY:Math.max(b,g),next:null},this._root)};c.prototype._insertSegment=function(a,b){var c=a.minX,d=a.minY,e=a.maxX,g=a.maxY,q=a.cx,m=a.cy;c<b.minX&&(b.minX=c);d<b.minY&&(b.minY=d);e>b.maxX&&(b.maxX=e);g>b.maxY&&(b.maxY=g);var n=b.data;if(n)if(n.cx===q&&n.cy===m){for(;n.next;)n=n.next;n.next=a}else b.data=null,this._insertSegment(n,b),this._insertSegment(a,b);else q= | ||
(m<b.cy?0:2)+(q<b.cx?0:1),b[q]?this._insertSegment(a,b[q]):b[q]={0:null,1:null,2:null,3:null,data:a,cx:b.cx+b.r/2*(q%2?1:-1),cy:b.cy+b.r/2*(2>q?-1:1),r:b.r/2,minX:c,minY:d,maxX:e,maxY:g}};c.prototype.walkTree=function(a){this.walkBranch(this._root,a)};c.prototype.walkBranch=function(a,b){if(!1!==b(a)&&!a.data)for(var c=0;4>c;c++)null!==a[c]&&this.walkBranch(a[c],b)};c.prototype.findNearestSignedDistance=function(a,b,c){var d=c;this.walkTree(function(c){if(a-d>c.maxX||a+d<c.minX||b-d>c.maxY||b+d<c.minY)return!1; | ||
if(c.data)for(c=c.data;c;c=c.next)if(a-d<c.maxX||a+d>c.minX||b-d<c.maxY||b+d>c.minY){var e=a;var f=b,h=c.x0,k=c.y0,m=c.x1-h,p=c.y1-k,t=m*m+p*p;t=t?Math.max(0,Math.min(1,((e-h)*m+(f-k)*p)/t)):0;e=Math.sqrt(g(e-(h+t*m))+g(f-(k+t*p)));e<d&&(d=e)}});this.isPointInPoly(a,b)||(d=-d);return d};c.prototype.isPointInPoly=function(a,b){var c=!1;this.walkTree(function(d){if(d.maxX<a||d.minY>b||d.maxY<b)return!1;if(d.data)for(d=d.data;d;d=d.next){var e=d.x0,f=d.y0,g=d.x1,h=d.y1;f>b!==h>b&&a<(g-e)*(b-f)/(h-f)+ | ||
e&&(c=!c)}});return c};return function(d){var e=new Uint8Array(b*b),f=d.xMax-d.xMin,g=d.yMax-d.yMin,k=Math.max(f,g)*a,l=(f+2*k)/b,m=(g+2*k)/b;g=d.xMin-k-l;f=d.yMin-k-m;l=d.xMax+k+l;m=d.yMax+k+m;if(d.pathCommandCount){var u=new c(d),n,r,p,t;d.forEachPathCommand(function(a,b,c,d,e,f,g){switch(a){case "M":p=n=b;t=r=c;break;case "L":b===p&&c===t||u.addLineSegment(p,t,p=b,t=c);break;case "Q":f={x:p,y:t};for(g=1;16>g;g++){a=g/15;var h=1-a;a={x:h*h*p+2*h*a*b+a*a*d,y:h*h*t+2*h*a*c+a*a*e};u.addLineSegment(f.x, | ||
f.y,a.x,a.y);f=a}p=d;t=e;break;case "C":a={x:p,y:t};for(h=1;16>h;h++){var k=h/15;var l=1-k;k={x:l*l*l*p+3*l*l*k*b+3*l*k*k*d+k*k*k*f,y:l*l*l*t+3*l*l*k*c+3*l*k*k*e+k*k*k*g};u.addLineSegment(a.x,a.y,k.x,k.y);a=k}p=f;t=g;break;case "Z":p===n&&t===r||u.addLineSegment(p,t,n,r)}});for(d=0;d<b;d++)for(var z=0;z<b;z++){var v=u.findNearestSignedDistance(g+(l-g)*(d+.5)/b,f+(m-f)*(z+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[z*b+d]=v}}return{textureData:e,renderingBounds:[g, | ||
f,l,m]}}},function(m,g,b){function a(a,b){function c(){var d=function(b){console.error("Failure loading font "+a+(a===f?"":"; trying fallback"),b);a!==f&&(a=f,c())};try{var e=new XMLHttpRequest;e.open("get",a,!0);e.responseType="arraybuffer";e.onload=function(){if(400<=e.status)d(Error(e.statusText));else if(0<e.status)try{var a=m(e.response);b(a)}catch(p){d(p)}};e.onerror=d;e.send()}catch(r){d(r)}}c()}function c(b,c){b||(b=f);var d=h[b];if(d)d.onload?d.onload.push(c):c();else{var e=h[b]={onload:[c]}; | ||
a(b,function(a){d=h[b]={fontObj:a,glyphs:{},glyphCount:0};e.onload.forEach(function(a){return a()})})}}function d(a,b){a||(a=f);c(a,function(){b(h[a])})}function e(a,b,c){var e=a.text;void 0===e&&(e="");var h=a.font;void 0===h&&(h=f);var k=a.fontSize;void 0===k&&(k=1);var l=a.letterSpacing;void 0===l&&(l=0);var m=a.lineHeight;void 0===m&&(m="normal");var q=a.maxWidth;void 0===q&&(q=Infinity);var v=a.textAlign;void 0===v&&(v="left");var x=a.whiteSpace;void 0===x&&(x="normal");var A=a.overflowWrap; | ||
void 0===A&&(A="normal");var y=a.anchor,E=a.includeCaretPositions;void 0===E&&(E=!1);void 0===c&&(c=!1);-1<e.indexOf("\r")&&(console.warn("FontProcessor.process: got text with \\r chars; normalizing to \\n"),e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"));k=+k;l=+l;q=+q;m=m||"normal";d(h,function(a){var d=a.fontObj,f=isFinite(q),h=null,n=null,p=null,r=null,t=null,u=0,z="nowrap"!==x,B=d.ascender,D=d.descender,C=d.unitsPerEm,I=k/C;"normal"===m&&(m=(B-D)/C);m*=k;var K=(m-(B-D)*I)/2;C=Math.min(m,(B-D)* | ||
I);var M=(B+D)/2*I-C/2,N=0,J={glyphs:[],width:0},O=[J];d.forEachGlyph(e,k,l,function(a,b,c){var d=e.charAt(c),g=a.advanceWidth*I,h=!!d&&/\s/.test(d),m=J.glyphs;if(z&&f&&!h&&b+g+N>q&&m.length){if(m[m.length-1].isWhitespace){var n=[];N=-b}else for(var p=m.length;p--;)if(0===p&&"break-word"===A){n=[];N=-b;break}else if(m[p].isWhitespace){n=m.splice(p+1);m=n[0].x;N-=m;for(p=0;p<n.length;p++)n[p].x-=m;break}n&&(J.isSoftWrapped=!0,J={glyphs:n,width:0},O.push(J),u=q)}J.glyphs.push({glyphObj:a,x:b+N,y:0, | ||
width:g,char:d,charIndex:c,isWhitespace:h,isEmpty:a.xMin===a.xMax||a.yMin===a.yMax,atlasInfo:null});"\n"===d&&(J={glyphs:[],width:0},O.push(J),N=-(b+g+l*k))});O.forEach(function(a){for(var b=a.glyphs,c=b.length;c--;){var d=b[c];if(!d.isWhitespace){a.width=d.x+d.width;a.width>u&&(u=a.width);break}}});if(!c){var G=[],L=-(k+K);E&&(r=new Float32Array(3*e.length));var H=-1;O.forEach(function(b){var c=b.glyphs,d=b.width;if(c.length){var e=0,f=0;if("center"===v)e=(u-d)/2;else if("right"===v)e=u-d;else if("justify"=== | ||
v)for(var k=c.length;k--;)if(!c[k].isWhitespace){for(;k--;)c[k].isWhitespace&&f++;break}k=0;for(var n=c.length;k<n;k++){var l=c[k];e&&(l.x+=e);l.y=L;if(l.isWhitespace&&"justify"===v&&b.isSoftWrapped){var p=(u-d)/f;e+=p;l.width+=p}if(E){p=l.charIndex;r[3*p]=l.x;r[3*p+1]=l.x+l.width;for(r[3*p+2]=l.y+M;1<p-H;)r[3*(H+1)]=r[3*H+1],r[3*(H+1)+1]=r[3*H+1],r[3*(H+1)+2]=r[3*H+2],H++;H=p}if(!l.isWhitespace&&!l.isEmpty){p=l.glyphObj;var q=a.glyphs[p.index];q||(q=g(p),q.atlasIndex=a.glyphCount++,h||(h=[]),h.push(q), | ||
q=a.glyphs[p.index]={atlasIndex:q.atlasIndex,glyphObj:p,renderingBounds:q.renderingBounds});l.atlasInfo=q;G.push(l)}}}L-=m});var P=0,Q=0;y&&(y[0]&&(P=-u*y[0]),y[1]&&(Q=O.length*m*y[1]));if(E&&(P||Q))for(d=0,B=r.length;d<B;d+=3)r[d]+=P,r[d+1]+=P,r[d+2]+=Q;n=new Float32Array(4*G.length);p=new Float32Array(G.length);t=[Infinity,Infinity,-Infinity,-Infinity];G.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=n[4*b]=a.x+d[0]*I+P,f=n[4*b+1]=a.y+d[1]*I+Q,g=n[4*b+2]=a.x+d[2]* | ||
I+P;a=n[4*b+3]=a.y+d[3]*I+Q;e<t[0]&&(t[0]=e);f<t[1]&&(t[1]=f);g>t[2]&&(t[2]=g);a>t[3]&&(t[3]=a);p[b]=c})}b({glyphBounds:n,glyphAtlasIndices:p,caretPositions:r,caretHeight:C,totalBounds:t,totalBlockSize:[u,O.length*m],newGlyphSDFs:h})})}var f=b.defaultFontUrl,h=Object.create(null);return{process:e,measure:function(a,b){e(a,function(a){b({width:a.totalBlockSize[0],height:a.totalBlockSize[1]})},{metricsOnly:!0})},loadFont:c}}],init:function(m,g,b,a,c){g=a({sdfTextureSize:m.sdfGlyphSize,sdfDistancePercent:g}); | ||
return c(b,g,{defaultFontUrl:m.defaultFontURL})}});var da=M.defineWorkerModule({name:"TextBuilder",dependencies:[G,M.ThenableWorkerModule],init:function(m,g){return function(b){var a=new g;m.process(b,a.resolve);return a}},getTransferables:function(m){var g=[m.glyphBounds.buffer,m.glyphAtlasIndices.buffer];m.caretPositions&&g.push(m.caretPositions.buffer);m.newGlyphSDFs&&m.newGlyphSDFs.forEach(function(b){g.push(b.textureData.buffer)});return g}}),fa=(new y.PlaneBufferGeometry(1,1)).translate(.5, | ||
.5,0),ha=new y.Vector3,L=function(m){function g(){m.call(this);this.copy(fa);this.boundingSphere=new y.Sphere}m&&(g.__proto__=m);g.prototype=Object.create(m&&m.prototype);g.prototype.constructor=g;g.prototype.computeBoundingSphere=function(){};g.prototype.updateGlyphs=function(b,a,c){W(this,"aTroikaGlyphBounds",b,4);W(this,"aTroikaGlyphIndex",a,1);this.maxInstancedCount=a.length;b=this.boundingSphere;b.center.set((c[0]+c[2])/2,(c[1]+c[3])/2,0);b.radius=b.center.distanceTo(ha.set(c[0],c[1],0))};return g}(y.InstancedBufferGeometry); | ||
L.prototype.setAttribute||(L.prototype.setAttribute=function(m,g){this.attributes[m]=g;return this});var X=new y.MeshBasicMaterial({color:16777215,side:y.DoubleSide,transparent:!0}),R=new y.Matrix4,Y=new y.Vector3,S=new y.Vector3,ia=new y.Vector3,Z=new y.Mesh((new y.PlaneBufferGeometry(1,1)).translate(.5,.5,0),X),aa=function(m){function g(a){a=new L;m.call(this,a,null);this.text="";this.font=this.anchor=null;this.fontSize=.1;this.letterSpacing=0;this.lineHeight="normal";this.maxWidth=Infinity;this.overflowWrap= | ||
"normal";this.textAlign="left";this.whiteSpace="normal";this.color=this.material=null;this.depthOffset=0;this.clipRect=null;this.orientation="+x+y";this.debugSDF=!1}m&&(g.__proto__=m);g.prototype=Object.create(m&&m.prototype);g.prototype.constructor=g;var b={textRenderInfo:{configurable:!0},material:{configurable:!0},customDepthMaterial:{configurable:!0},customDistanceMaterial:{configurable:!0}};g.prototype.sync=function(a){var b=this;this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs|| | ||
(this._queuedSyncs=[])).push(a):(this._isSyncing=!0,ca({text:this.text,font:this.font,fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,textAlign:this.textAlign,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchor:this.anchor,includeCaretPositions:!0},function(c){b._isSyncing=!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphAtlasIndices,c.totalBounds);var d=b._queuedSyncs;d&&(b._queuedSyncs=null, | ||
b._needsSync=!0,b.sync(function(){d.forEach(function(a){return a&&a()})}));a&&a()})))};g.prototype.onBeforeRender=function(){this.sync();this._prepareMaterial()};g.prototype.dispose=function(){this.geometry.dispose()};b.textRenderInfo.get=function(){return this._textRenderInfo||null};b.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||X;a&&a.baseMaterial===b||(a&&a.dispose(),a=this._derivedMaterial=ea(b),b.addEventListener("dispose",function e(){b.removeEventListener("dispose", | ||
e);a.dispose()}));return a};b.material.set=function(a){this._baseMaterial=a};b.customDepthMaterial.get=function(){return this.material.getDepthMaterial()};b.customDistanceMaterial.get=function(){return this.material.getDistanceMaterial()};g.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=a.uniforms,d=this.textRenderInfo;if(d){var e=d.sdfTexture,f=d.totalBounds;b.uTroikaSDFTexture.value=e;b.uTroikaSDFTextureSize.value.set(e.image.width,e.image.height);b.uTroikaSDFGlyphSize.value= | ||
d.sdfGlyphSize;b.uTroikaSDFMinDistancePct.value=d.sdfMinDistancePercent;b.uTroikaTotalBounds.value.fromArray(f);(d=this.clipRect)&&Array.isArray(d)&&4===d.length?b.uTroikaClipRect.value.set(Math.max(f[0],d[0]),Math.max(f[1],d[1]),Math.min(f[2],d[2]),Math.min(f[3],d[3])):b.uTroikaClipRect.value.fromArray(f)}b.uTroikaSDFDebug.value=!!this.debugSDF;a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;f=this.color;null!=f&&a.color&&a.color.isColor&&f!==a._troikaColor&& | ||
a.color.set(a._troikaColor=f);f=this.orientation||"+x+y";if(f!==a._orientation){b=b.uTroikaOrient.value;f=f.replace(/[^-+xyz]/g,"");var g="+x+y"!==f&&f.match(/^([-+])([xyz])([-+])([xyz])$/);if(g){d=g[1];e=g[2];var k=g[3];g=g[4];Y.set(0,0,0)[e]="-"===d?1:-1;S.set(0,0,0)[g]="-"===k?-1:1;R.lookAt(ia,Y.cross(S),S);b.setFromMatrix4(R)}else b.identity();a._orientation=f}};g.prototype.raycast=function(a,b){var c=this.textRenderInfo;c&&(c=c.totalBounds,Z.matrixWorld.multiplyMatrices(this.matrixWorld,R.set(c[2]- | ||
c[0],0,0,c[0],0,c[3]-c[1],0,c[1],0,0,1,0,0,0,0,1)),Z.raycast(a,b))};Object.defineProperties(g.prototype,b);return g}(y.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(m){var g="_private_"+m;Object.defineProperty(aa.prototype,m,{get:function(){return this[g]},set:"anchor"===m?function(b){JSON.stringify(b)!==JSON.stringify(this[g])&&(this[g]=b,this._needsSync=!0)}:function(b){b!==this[g]&&(this[g]=b,this._needsSync=!0)}})}); | ||
D.GlyphsGeometry=L;D.TextMesh=aa;D.configureTextBuilder=function(m){T(K,m)};D.fontProcessorWorkerModule=G;Object.defineProperty(D,"__esModule",{value:!0})}) |
{ | ||
"name": "troika-3d-text", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "Troika 3D Text", | ||
@@ -18,5 +18,5 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"dependencies": { | ||
"troika-3d": "^0.22.0", | ||
"troika-three-utils": "^0.22.0", | ||
"troika-worker-utils": "^0.22.0" | ||
"troika-3d": "^0.23.0", | ||
"troika-three-utils": "^0.23.0", | ||
"troika-worker-utils": "^0.23.0" | ||
}, | ||
@@ -31,3 +31,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "c3ff4002b468f00bc7c4775578e0ad9d950ff52d" | ||
"gitHead": "c58983745861fe3fc4a5ec15a24addce603061c9" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Group3DFacade } from 'troika-3d' | ||
import { ListFacade } from 'troika-3d' | ||
import { Matrix4, Plane, Vector3 } from 'three' | ||
@@ -11,2 +11,3 @@ import { getCaretAtPoint, getSelectionRects } from '../selectionUtils.js' | ||
const tempVec3 = new Vector3() | ||
const noClip = Object.freeze([-Infinity, -Infinity, Infinity, Infinity]) | ||
@@ -16,3 +17,3 @@ /** | ||
*/ | ||
class SelectionManagerFacade extends Group3DFacade { | ||
class SelectionManagerFacade extends ListFacade { | ||
constructor (parent, onSelectionChange) { | ||
@@ -23,3 +24,21 @@ super(parent) | ||
this.rangeColor = 0x00ccff | ||
this.clipRect = noClip | ||
this.template = { | ||
key: (d, i) => `rect${i}`, | ||
facade: SelectionRangeRect, | ||
top: d => clamp(d.top, this.clipRect[1], this.clipRect[3]), | ||
right: d => clamp(d.right, this.clipRect[0], this.clipRect[2]), | ||
bottom: d => clamp(d.bottom, this.clipRect[1], this.clipRect[3]), | ||
left: d => clamp(d.left, this.clipRect[0], this.clipRect[2]), | ||
z: d => (d.top - d.bottom) * THICKNESS / 2, | ||
scaleZ: d => (d.top - d.bottom) * THICKNESS, | ||
color: d => this.rangeColor, | ||
visible: d => { | ||
let r = this.clipRect | ||
return d.right > r[0] && d.top > r[1] && d.left < r[2] && d.bottom < r[3] | ||
}, | ||
renderOrder: d => this.renderOrder || 0 | ||
} | ||
const onDragStart = e => { | ||
@@ -35,2 +54,3 @@ const textRenderInfo = this.textRenderInfo | ||
} | ||
e.preventDefault() | ||
} | ||
@@ -51,2 +71,3 @@ } | ||
} | ||
e.preventDefault() | ||
} | ||
@@ -70,16 +91,15 @@ } | ||
describeChildren() { | ||
const rects = getSelectionRects(this.textRenderInfo, this.selectionStart, this.selectionEnd) | ||
// TODO make the rects into a single draw call, either by instancing or updating a single geometry | ||
return rects ? rects.map(({top, right, bottom, left}, i) => ({ | ||
key: `rect${i}`, | ||
facade: SelectionRangeRect, | ||
top, right, bottom, left, | ||
z: (top - bottom) * THICKNESS / 2, | ||
scaleZ: (top - bottom) * THICKNESS, | ||
color: this.rangeColor, | ||
renderOrder: this.renderOrder || 0 | ||
})) : null | ||
afterUpdate() { | ||
this.data = getSelectionRects(this.textRenderInfo, this.selectionStart, this.selectionEnd) | ||
super.afterUpdate() | ||
} | ||
// normalize clipRect | ||
set clipRect(clipRect) { | ||
this._clipRect = (clipRect && Array.isArray(clipRect) && clipRect.length === 4) ? clipRect : noClip | ||
} | ||
get clipRect() { | ||
return this._clipRect | ||
} | ||
destructor () { | ||
@@ -91,3 +111,6 @@ this._cleanupEvents() | ||
function clamp(val, min, max) { | ||
return Math.min(max, Math.max(min, val)) | ||
} | ||
export default SelectionManagerFacade |
@@ -1,11 +0,8 @@ | ||
import { BoxBufferGeometry, Mesh, MeshBasicMaterial, Vector4 } from 'three' | ||
import {Object3DFacade, createDerivedMaterial} from 'troika-3d' | ||
import { BoxBufferGeometry, Color, Mesh, MeshBasicMaterial, Vector4 } from 'three' | ||
import {Instanceable3DFacade, createDerivedMaterial} from 'troika-3d' | ||
function getRectGeometry() { | ||
const geom = new BoxBufferGeometry().translate(0, 0, -0.5) //origin on front face for distance sorting | ||
getRectGeometry = () => geom | ||
return geom | ||
} | ||
function getRectMaterial() { | ||
const mtl = createDerivedMaterial( | ||
const tempVec4 = new Vector4() | ||
function getMesh() { | ||
let material = createDerivedMaterial( | ||
new MeshBasicMaterial({ | ||
@@ -27,4 +24,8 @@ transparent: true, | ||
) | ||
getRectMaterial = () => mtl | ||
return mtl | ||
material.instanceUniforms = ['rect', 'diffuse'] | ||
const mesh = new Mesh( | ||
new BoxBufferGeometry().translate(0, 0, -0.5), //origin on front face for distance sorting | ||
material | ||
) | ||
return (getMesh = () => mesh)() | ||
} | ||
@@ -35,19 +36,27 @@ | ||
class RangeRectFacade extends Object3DFacade { | ||
constructor(parent) { | ||
super(parent, new Mesh( | ||
getRectGeometry(), | ||
getRectMaterial().clone() | ||
)) | ||
class RangeRectFacade extends Instanceable3DFacade { | ||
constructor (parent) { | ||
super(parent) | ||
this.instancedThreeObject = getMesh() | ||
this._color = new Color() | ||
this._rect = new Vector4() | ||
} | ||
afterUpdate() { | ||
const {top, right, bottom, left, color} = this | ||
if (color !== this._color) { | ||
this.threeObject.material.color.set(this._color = color) | ||
if (!this._color.equals(color)) { | ||
this.setInstanceUniform('diffuse', this._color = new Color(color)) | ||
} | ||
this.threeObject.material.uniforms.rect.value.set(left, top, right, bottom) | ||
if (!this._rect.equals(tempVec4.set(left, top, right, bottom))) { | ||
this.setInstanceUniform('rect', tempVec4.clone()) | ||
} | ||
super.afterUpdate() | ||
} | ||
getBoundingSphere () { | ||
return null | ||
} | ||
} | ||
export default RangeRectFacade |
@@ -97,2 +97,3 @@ import { Object3DFacade } from 'troika-3d' | ||
selFacade.selectionEnd = selectionEnd | ||
selFacade.clipRect = this.clipRect | ||
selFacade.renderOrder = this.renderOrder | ||
@@ -99,0 +100,0 @@ selFacade.afterUpdate() |
@@ -72,2 +72,3 @@ /** | ||
const workerModule = defineWorkerModule({ | ||
name: 'OpenType Font Parser', | ||
dependencies: [opentypeFactory, parserFactory], | ||
@@ -74,0 +75,0 @@ init(opentypeFactory, parserFactory) { |
@@ -101,2 +101,3 @@ /** | ||
const workerModule = defineWorkerModule({ | ||
name: 'Typr Font Parser', | ||
dependencies: [typrFactory, woff2otfFactory, parserFactory], | ||
@@ -103,0 +104,0 @@ init(typrFactory, woff2otfFactory, parserFactory) { |
@@ -183,2 +183,3 @@ import { DataTexture, LinearFilter, LuminanceFormat, Vector2 } from 'three' | ||
export const fontProcessorWorkerModule = defineWorkerModule({ | ||
name: 'FontProcessor', | ||
dependencies: [ | ||
@@ -203,2 +204,3 @@ CONFIG, | ||
export const processInWorker = defineWorkerModule({ | ||
name: 'TextBuilder', | ||
dependencies: [fontProcessorWorkerModule, ThenableWorkerModule], | ||
@@ -205,0 +207,0 @@ init(fontProcessor, Thenable) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1912013
33703
+ Addedtroika-3d@0.23.0(transitive)
+ Addedtroika-animation@0.23.0(transitive)
+ Addedtroika-core@0.23.0(transitive)
+ Addedtroika-three-utils@0.23.0(transitive)
+ Addedtroika-worker-utils@0.23.0(transitive)
- Removedtroika-3d@0.22.0(transitive)
- Removedtroika-animation@0.22.0(transitive)
- Removedtroika-core@0.22.0(transitive)
- Removedtroika-three-utils@0.22.0(transitive)
- Removedtroika-worker-utils@0.22.0(transitive)
Updatedtroika-3d@^0.23.0
Updatedtroika-three-utils@^0.23.0
Updatedtroika-worker-utils@^0.23.0