troika-3d-text
Advanced tools
Comparing version 0.15.1 to 0.15.2
@@ -1,50 +0,53 @@ | ||
'use strict';(function(C,z){"object"===typeof exports&&"undefined"!==typeof module?z(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"],z):(C=C||self,z(C.troika_3d_text={},C.THREE,C.troika_worker_utils,C.troika_three_utils))})(this,function(C,z,F,R){function S(u,g){u=J({},u);K.href=u.font||H.defaultFontURL;u.font=K.href;u.text=""+u.text;var b=H.sdfGlyphSize, | ||
a=L[u.font];a||(a=L[u.font]={sdfTexture:new z.DataTexture(new Uint8Array(b*b*64),b,64*b,z.LuminanceFormat,void 0,void 0,void 0,void 0,z.LinearFilter,z.LinearFilter)},a.sdfTexture.font=u.font);T(u).then(function(c){c.newGlyphSDFs&&(c.newGlyphSDFs.forEach(function(c){var d=c.textureData,f=a.sdfTexture.image;for(c=c.atlasIndex*b*b;c>f.data.length-1;){var g=new Uint8Array(2*f.data.length);g.set(f.data);f.data=g;f.height*=2}f.data.set(d,c)}),a.sdfTexture.needsUpdate=!0);g({sdfTexture:a.sdfTexture,sdfMinDistancePercent:.125, | ||
glyphBounds:c.glyphBounds,glyphIndices:c.glyphIndices,totalBounds:c.totalBounds,totalBlockSize:c.totalBlockSize})})}function J(u,g){for(var b in g)g.hasOwnProperty(b)&&(u[b]=g[b]);return u}function M(u,g){u.array.length===g.length?u.array.set(g):u.setArray(g);u.needsUpdate=!0}var G=F.defineWorkerModule({dependencies:[function(){var u=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 t= | ||
c.readUint(b,a);a+=4;h[l]={offset:q,length:t}}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:u.TextDecoder?new u.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,t=null;28==h&&(t=d.readShort(b,a+1),l=3);29==h&&(t=d.readInt(b,a+1),l=5);32<=h&&246>=h&&(t=h-139,l=1);247<=h&&250>=h&&(t=256*(h-247)+k+108,l=2);251<=h&&254>=h&&(t=256*-(h-251)-k-108,l=2);if(255==h)throw d.readInt(b,a+1),"unknown number";if(30==h){t=[];for(l=1;;){var m=b[a+l];l++;var p=m>>4;m&=15;15!=p&&t.push(p);15!=m&&t.push(m);if(15==m)break}p="";m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"];for(var n=0;n<t.length;n++)p+=m[t[n]];t=parseFloat(p)}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(t);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 t="p"+k+"e"+l,m=f.indexOf(q);if(-1==m){m=d.tables.length;var p;f.push(q);var n=c.readUshort(b,q);0==n?p=g.cmap.parse0(b,q):4==n?p=g.cmap.parse4(b,q):6==n?p=g.cmap.parse6(b,q):12==n?p=g.cmap.parse12(b,q):console.log("unknown format: "+n,k,l,q);d.tables.push(p)}if(null!=d[t])throw"multiple tables for one platform+encoding";d[t]=m}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 t=0;t<q;t++){var m=e+d.readUshort(b, | ||
c);c+=2;var p=d.readUshort(b,m);m+=2;for(var n=[],r=0;r<p;r++){var w=d.readUshort(b,m);m+=2;if(0!=k){var v=g.GPOS.readValueRecord(b,m,k);m+=2*a}if(0!=l){var y=g.GPOS.readValueRecord(b,m,l);m+=2*h}n.push({gid2:w,val1:v,val2:y})}f.pairsets.push(n)}}if(2==f.fmt)for(v=d.readUshort(b,c),c+=2,y=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+v),f.classDef2=g._lctf.readClassDef(b,e+y),f.matrix=[],t=0;t<k;t++){e=[];for(r=0;r<d;r++)y=v=null,0!= | ||
f.valFmt1&&(v=g.GPOS.readValueRecord(b,c,f.valFmt1),c+=2*a),0!=f.valFmt2&&(y=g.GPOS.readValueRecord(b,c,f.valFmt2),c+=2*h),e.push({val1:v,val2:y});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 t=c.readUshort(b,a);a+=2;var m=c.readUshort(b,a);a+=2;var p=c.readUshort(b,a);a+=2;var n=c.readUshort(b,a);a+=2;m=f[m];n=h+12*e+n;if(0==l)p=c.readUnicode(b,n,p/2);else if(3==l&&0==q)p=c.readUnicode(b,n,p/2);else if(0==q)p=c.readASCII(b,n,p);else if(1==q)p=c.readUnicode(b,n,p/2);else if(3==q)p=c.readUnicode(b,n,p/2);else if(1==l)p=c.readASCII(b,n,p),console.log("reading unknown MAC encoding "+q+" as ASCII");else throw"unknown encoding "+ | ||
q+", platformID: "+l;l="p"+l+","+t.toString(16);null==d[l]&&(d[l]={});d[l][m]=p;d[l]._lang=t}for(var r in d)if(null!=d[r].postScriptName&&1033==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName&&0==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName&&3084==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName)return d[r];for(r in d){var w=r;break}console.log("returning name table with languageID "+d[w]._lang);return d[w]};g["OS/2"]={};g["OS/2"].parse=function(b,a, | ||
'use strict';(function(C,z){"object"===typeof exports&&"undefined"!==typeof module?z(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"],z):(C=C||self,z(C.troika_3d_text={},C.THREE,C.troika_worker_utils,C.troika_three_utils))})(this,function(C,z,F,R){function S(r,g){r=J({},r);K.href=r.font||H.defaultFontURL;r.font=K.href;r.text=""+r.text;var b=H.sdfGlyphSize, | ||
a=L[r.font];a||(a=L[r.font]={sdfTexture:new z.DataTexture(new Uint8Array(b*b*64),b,64*b,z.LuminanceFormat,void 0,void 0,void 0,void 0,z.LinearFilter,z.LinearFilter)},a.sdfTexture.font=r.font);T(r).then(function(c){c.newGlyphSDFs&&(c.newGlyphSDFs.forEach(function(c){var d=c.textureData,f=a.sdfTexture.image;for(c=c.atlasIndex*b*b;c>f.data.length-1;){var g=new Uint8Array(2*f.data.length);g.set(f.data);f.data=g;f.height*=2}f.data.set(d,c)}),a.sdfTexture.needsUpdate=!0);g({sdfTexture:a.sdfTexture,sdfMinDistancePercent:.125, | ||
glyphBounds:c.glyphBounds,glyphIndices:c.glyphIndices,totalBounds:c.totalBounds,totalBlockSize:c.totalBlockSize})})}function J(r,g){for(var b in g)g.hasOwnProperty(b)&&(r[b]=g[b]);return r}function M(r,g){r.array.length===g.length?r.array.set(g):r.setArray(g);r.needsUpdate=!0}function U(r){r=R.createDerivedMaterial(r,{extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFMinDistancePct:{value:0},uTroikaGlyphVSize:{value:0},uTroikaTotalBounds:{value:new z.Vector4},uTroikaClipRect:{value:new z.Vector4}, | ||
uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaTotalBounds;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n",vertexTransform:"\nvTroikaGlyphUV = vec2(\n position.x,\n uTroikaGlyphVSize * (aTroikaGlyphIndex + position.y)\n);\n\nposition = vec3(\n mix(aTroikaGlyphBounds.x, aTroikaGlyphBounds.z, position.x),\n mix(aTroikaGlyphBounds.y, aTroikaGlyphBounds.w, position.y),\n position.z\n);\nvTroikaLocalPos = vec3(position);\n\nuv = vec2(\n (position.x - uTroikaTotalBounds.x) / (uTroikaTotalBounds.z - uTroikaTotalBounds.x),\n (position.y - uTroikaTotalBounds.y) / (uTroikaTotalBounds.w - uTroikaTotalBounds.y)\n);\n", | ||
fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform float uTroikaSDFMinDistancePct;\nuniform bool uTroikaSDFDebug;\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaClipRect;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n\nvoid troikaApplyClipping() {\n vec4 rect = uTroikaClipRect;\n vec3 pos = vTroikaLocalPos;\n if (rect != vec4(.0,.0,.0,.0) && (\n pos.x < min(rect.x, rect.z) || \n pos.y < min(rect.y, rect.w) ||\n pos.x > max(rect.x, rect.z) ||\n pos.y > max(rect.y, rect.w)\n )) {\n discard;\n }\n}\n", | ||
fragmentColorTransform:"\ntroikaApplyClipping();\n\nfloat troikaSDFValue = texture2D(uTroikaSDFTexture, vTroikaGlyphUV).r;\n\n\n#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n float troikaAntiAliasDist = min(\n 0.5,\n 0.5 * min(\n fwidth(vTroikaGlyphUV.x), \n fwidth(vTroikaGlyphUV.y / uTroikaGlyphVSize)\n )\n ) / uTroikaSDFMinDistancePct;\n#else\n float troikaAntiAliasDist = 0.01;\n#endif\n\nfloat textAlphaMult = uTroikaSDFDebug ? troikaSDFValue : smoothstep(\n 0.5 - troikaAntiAliasDist,\n 0.5 + troikaAntiAliasDist,\n troikaSDFValue\n);\nif (textAlphaMult == 0.0) {\n if (uTroikaSDFDebug) {\n gl_FragColor *= 0.5;\n } else {\n discard;\n }\n} else {\n gl_FragColor.a *= textAlphaMult;\n}\n"}); | ||
r.transparent=!0;return r}var G=F.defineWorkerModule({dependencies:[function(){var r=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:r.TextDecoder?new r.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 m= | ||
b[a+l];l++;var p=m>>4;m&=15;15!=p&&u.push(p);15!=m&&u.push(m);if(15==m)break}p="";m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"];for(var n=0;n<u.length;n++)p+=m[u[n]];u=parseFloat(p)}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,m=f.indexOf(q);if(-1==m){m=d.tables.length;var p;f.push(q);var n=c.readUshort(b,q);0==n?p=g.cmap.parse0(b,q):4==n?p=g.cmap.parse4(b,q):6==n?p=g.cmap.parse6(b,q):12==n?p=g.cmap.parse12(b,q):console.log("unknown format: "+n,k,l,q);d.tables.push(p)}if(null!= | ||
d[u])throw"multiple tables for one platform+encoding";d[u]=m}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 m=e+d.readUshort(b,c);c+=2;var p=d.readUshort(b,m);m+=2;for(var n=[],t=0;t<p;t++){var w=d.readUshort(b,m);m+=2;if(0!=k){var v=g.GPOS.readValueRecord(b,m,k);m+=2*a}if(0!=l){var y=g.GPOS.readValueRecord(b,m,l);m+=2*h}n.push({gid2:w,val1:v,val2:y})}f.pairsets.push(n)}}if(2==f.fmt)for(v=d.readUshort(b,c),c+=2,y=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+v),f.classDef2=g._lctf.readClassDef(b,e+y),f.matrix=[],u=0;u<k;u++){e=[];for(t=0;t<d;t++)y=v=null,0!=f.valFmt1&&(v=g.GPOS.readValueRecord(b,c,f.valFmt1),c+=2*a),0!=f.valFmt2&&(y=g.GPOS.readValueRecord(b,c,f.valFmt2),c+=2*h),e.push({val1:v,val2:y});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 m=c.readUshort(b,a);a+=2;var p=c.readUshort(b,a);a+=2;var n=c.readUshort(b,a);a+=2;m=f[m];n=h+12*e+n;if(0==l)p=c.readUnicode(b,n,p/2);else if(3==l&&0==q)p=c.readUnicode(b,n,p/2);else if(0==q)p=c.readASCII(b,n,p);else if(1==q)p=c.readUnicode(b,n,p/2);else if(3==q)p=c.readUnicode(b,n,p/2);else if(1==l)p=c.readASCII(b,n,p),console.log("reading unknown MAC encoding "+q+" as ASCII");else throw"unknown encoding "+ | ||
q+", platformID: "+l;l="p"+l+","+u.toString(16);null==d[l]&&(d[l]={});d[l][m]=p;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 w=t;break}console.log("returning name table with languageID "+d[w]._lang);return d[w]};g["OS/2"]={};g["OS/2"].parse=function(b,a, | ||
c){c=g._bin.readUshort(b,a);a+=2;var d={};if(0==c)g["OS/2"].version0(b,a,d);else if(1==c)g["OS/2"].version1(b,a,d);else if(2==c||3==c||4==c)g["OS/2"].version2(b,a,d);else if(5==c)g["OS/2"].version5(b,a,d);else throw"unknown OS/2 table version: "+c;return d};g["OS/2"].version0=function(b,a,c){var d=g._bin;c.xAvgCharWidth=d.readShort(b,a);a+=2;c.usWeightClass=d.readUshort(b,a);a+=2;c.usWidthClass=d.readUshort(b,a);a+=2;c.fsType=d.readUshort(b,a);a+=2;c.ySubscriptXSize=d.readShort(b,a);a+=2;c.ySubscriptYSize= | ||
@@ -55,63 +58,60 @@ d.readShort(b,a);a+=2;c.ySubscriptXOffset=d.readShort(b,a);a+=2;c.ySubscriptYOffset=d.readShort(b,a);a+=2;c.ySuperscriptXSize=d.readShort(b,a);a+=2;c.ySuperscriptYSize=d.readShort(b,a);a+=2;c.ySuperscriptXOffset=d.readShort(b,a);a+=2;c.ySuperscriptYOffset=d.readShort(b,a);a+=2;c.yStrikeoutSize=d.readShort(b,a);a+=2;c.yStrikeoutPosition=d.readShort(b,a);a+=2;c.sFamilyClass=d.readShort(b,a);a+=2;c.panose=d.readBytes(b,a,10);a+=10;c.ulUnicodeRange1=d.readUint(b,a);a+=4;c.ulUnicodeRange2=d.readUint(b, | ||
d.readUshort(b,a);a+=2;c.usUpperOpticalPointSize=d.readUshort(b,a);return a+2};g.post={};g.post.parse=function(b,a,c){c=g._bin;var d={};d.version=c.readFixed(b,a);a+=4;d.italicAngle=c.readFixed(b,a);a+=4;d.underlinePosition=c.readShort(b,a);d.underlineThickness=c.readShort(b,a+2);return d};g.SVG={};g.SVG.parse=function(b,a,c){c=g._bin;var d={entries:[]},e=a;c.readUshort(b,a);a+=2;var f=c.readUint(b,a);c.readUint(b,a+4);a=f+e;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var l=c.readUshort(b,a); | ||
a+=2;var q=c.readUshort(b,a);a+=2;var t=c.readUint(b,a);a+=4;var m=c.readUint(b,a);a+=4;t=new Uint8Array(b.buffer,e+t+f,m);for(t=c.readUTF8(t,0,t.length);l<=q;l++)d.entries[l]=t}return d};g.SVG.toPath=function(b){var a={cmds:[],crds:[]};if(null==b)return a;for(var c=(new DOMParser).parseFromString(b,"image/svg+xml").firstChild;"svg"!=c.tagName;)c=c.nextSibling;b=(b=c.getAttribute("viewBox"))?b.trim().split(" ").map(parseFloat):[0,0,1E3,1E3];g.SVG._toPath(c.children,a);for(c=0;c<a.crds.length;c+=2){var d= | ||
a+=2;var q=c.readUshort(b,a);a+=2;var u=c.readUint(b,a);a+=4;var m=c.readUint(b,a);a+=4;u=new Uint8Array(b.buffer,e+u+f,m);for(u=c.readUTF8(u,0,u.length);l<=q;l++)d.entries[l]=u}return d};g.SVG.toPath=function(b){var a={cmds:[],crds:[]};if(null==b)return a;for(var c=(new DOMParser).parseFromString(b,"image/svg+xml").firstChild;"svg"!=c.tagName;)c=c.nextSibling;b=(b=c.getAttribute("viewBox"))?b.trim().split(" ").map(parseFloat):[0,0,1E3,1E3];g.SVG._toPath(c.children,a);for(c=0;c<a.crds.length;c+=2){var d= | ||
a.crds[c],e=a.crds[c+1];d-=b[0];e-=b[1];e=-e;a.crds[c]=d;a.crds[c+1]=e}return a};g.SVG._toPath=function(b,a,c){for(var d=0;d<b.length;d++){var e=b[d],f=e.tagName,h=e.getAttribute("fill");null==h&&(h=c);"g"==f?g.SVG._toPath(e.children,a,h):"path"==f?(a.cmds.push(h?h:"#000000"),e=e.getAttribute("d"),e=g.SVG._tokens(e),g.SVG._toksToPath(e,a),a.cmds.push("X")):"defs"!=f&&console.log(f,e)}};g.SVG._tokens=function(b){for(var a=[],c=0,d=!1,e="";c<b.length;){var f=b.charCodeAt(c),g=b.charAt(c);c++;f=48<= | ||
f&&57>=f||"."==g||"-"==g;d?"-"==g?(a.push(parseFloat(e)),e=g):f?e+=g:(a.push(parseFloat(e)),","!=g&&" "!=g&&a.push(g),d=!1):f?(e=g,d=!0):","!=g&&" "!=g&&a.push(g)}d&&a.push(parseFloat(e));return a};g.SVG._toksToPath=function(b,a){var c=0,d=0,e=0,f=0,h=0,k={M:2,L:2,H:1,V:1,S:4,C:6},l=a.cmds;for(a=a.crds;c<b.length;){var q=b[c];c++;if("z"==q)l.push("Z"),d=f,e=h;else for(var t=q.toUpperCase(),m=g.SVG._reps(b,c,k[t]),p=0;p<m;p++){var n=0,r=0;q!=t&&(n=d,r=e);if("M"==t)d=n+b[c++],e=r+b[c++],l.push("M"), | ||
a.push(d,e),f=d,h=e;else if("L"==t)d=n+b[c++],e=r+b[c++],l.push("L"),a.push(d,e);else if("H"==t)d=n+b[c++],l.push("L"),a.push(d,e);else if("V"==t)e=r+b[c++],l.push("L"),a.push(d,e);else if("C"==t){d=n+b[c++];e=r+b[c++];var w=n+b[c++],v=r+b[c++];n+=b[c++];r+=b[c++];l.push("C");a.push(d,e,w,v,n,r);d=n;e=r}else"S"==t?(w=Math.max(a.length-4,0),d=d+d-a[w],e=e+e-a[w+1],w=n+b[c++],v=r+b[c++],n+=b[c++],r+=b[c++],l.push("C"),a.push(d,e,w,v,n,r),d=n,e=r):console.log("Unknown SVG command "+q)}}};g.SVG._reps= | ||
f&&57>=f||"."==g||"-"==g;d?"-"==g?(a.push(parseFloat(e)),e=g):f?e+=g:(a.push(parseFloat(e)),","!=g&&" "!=g&&a.push(g),d=!1):f?(e=g,d=!0):","!=g&&" "!=g&&a.push(g)}d&&a.push(parseFloat(e));return a};g.SVG._toksToPath=function(b,a){var c=0,d=0,e=0,f=0,h=0,k={M:2,L:2,H:1,V:1,S:4,C:6},l=a.cmds;for(a=a.crds;c<b.length;){var q=b[c];c++;if("z"==q)l.push("Z"),d=f,e=h;else for(var u=q.toUpperCase(),m=g.SVG._reps(b,c,k[u]),p=0;p<m;p++){var n=0,t=0;q!=u&&(n=d,t=e);if("M"==u)d=n+b[c++],e=t+b[c++],l.push("M"), | ||
a.push(d,e),f=d,h=e;else if("L"==u)d=n+b[c++],e=t+b[c++],l.push("L"),a.push(d,e);else if("H"==u)d=n+b[c++],l.push("L"),a.push(d,e);else if("V"==u)e=t+b[c++],l.push("L"),a.push(d,e);else if("C"==u){d=n+b[c++];e=t+b[c++];var w=n+b[c++],v=t+b[c++];n+=b[c++];t+=b[c++];l.push("C");a.push(d,e,w,v,n,t);d=n;e=t}else"S"==u?(w=Math.max(a.length-4,0),d=d+d-a[w],e=e+e-a[w+1],w=n+b[c++],v=t+b[c++],n+=b[c++],t+=b[c++],l.push("C"),a.push(d,e,w,v,n,t),d=n,e=t):console.log("Unknown SVG command "+q)}}};g.SVG._reps= | ||
function(b,a,c){for(var d=a;d<b.length&&"string"!=typeof b[d];)d+=c;return(d-a)/c};null==g&&(g={});null==g.U&&(g.U={});g.U.codeToGlyph=function(b,a){b=b.cmap;var c=-1;null!=b.p0e4?c=b.p0e4:null!=b.p3e1?c=b.p3e1:null!=b.p1e0?c=b.p1e0:null!=b.p0e3&&(c=b.p0e3);if(-1==c)throw"no familiar platform and encoding!";b=b.tables[c];if(0==b.format)return a>=b.map.length?0:b.map[a];if(4==b.format){var d=-1;for(c=0;c<b.endCount.length;c++)if(a<=b.endCount[c]){d=c;break}return-1==d||b.startCount[d]>a?0:(0!=b.idRangeOffset[d]? | ||
b.glyphIdArray[a-b.startCount[d]+(b.idRangeOffset[d]>>1)-(b.idRangeOffset.length-d)]:a+b.idDelta[d])&65535}if(12==b.format){if(a>b.groups[b.groups.length-1][1])return 0;for(c=0;c<b.groups.length;c++)if(d=b.groups[c],d[0]<=a&&a<=d[1])return d[2]+(a-d[0]);return 0}throw"unknown cmap table format "+b.format;};g.U.glyphToPath=function(b,a){var c={cmds:[],crds:[]};if(b.SVG&&b.SVG.entries[a]){var d=b.SVG.entries[a];if(null==d)return c;"string"==typeof d&&(d=g.SVG.toPath(d),b.SVG.entries[a]=d);return d}if(b.CFF){d= | ||
{x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:b.CFF.Private?b.CFF.Private.defaultWidthX:0,open:!1};var e=b.CFF,f=b.CFF.Private;if(e.ROS){for(f=0;e.FDSelect[f+2]<=a;)f+=2;f=e.FDArray[e.FDSelect[f+1]].Private}g.U._drawCFF(b.CFF.CharStrings[a],d,e,f,c)}else b.glyf&&g.U._drawGlyf(a,b,c);return c};g.U._drawGlyf=function(b,a,c){var d=a.glyf[b];null==d&&(d=a.glyf[b]=g.glyf._parseGlyf(a,b));null!=d&&(-1<d.noc?g.U._simpleGlyph(d,c):g.U._compoGlyph(d,a,c))};g.U._simpleGlyph=function(b,a){for(var c=0;c<b.noc;c++){for(var d= | ||
0==c?0:b.endPts[c-1]+1,e=b.endPts[c],f=d;f<=e;f++){var h=f==d?e:f-1,k=f==e?d:f+1,l=b.flags[f]&1,q=b.flags[h]&1,t=b.flags[k]&1,m=b.xs[f],p=b.ys[f];if(f==d)if(l)if(q)g.U.P.moveTo(a,b.xs[h],b.ys[h]);else{g.U.P.moveTo(a,m,p);continue}else q?g.U.P.moveTo(a,b.xs[h],b.ys[h]):g.U.P.moveTo(a,(b.xs[h]+m)/2,(b.ys[h]+p)/2);l?q&&g.U.P.lineTo(a,m,p):t?g.U.P.qcurveTo(a,m,p,b.xs[k],b.ys[k]):g.U.P.qcurveTo(a,m,p,(m+b.xs[k])/2,(p+b.ys[k])/2)}g.U.P.closePath(a)}};g.U._compoGlyph=function(b,a,c){for(var d=0;d<b.parts.length;d++){var e= | ||
0==c?0:b.endPts[c-1]+1,e=b.endPts[c],f=d;f<=e;f++){var h=f==d?e:f-1,k=f==e?d:f+1,l=b.flags[f]&1,q=b.flags[h]&1,u=b.flags[k]&1,m=b.xs[f],p=b.ys[f];if(f==d)if(l)if(q)g.U.P.moveTo(a,b.xs[h],b.ys[h]);else{g.U.P.moveTo(a,m,p);continue}else q?g.U.P.moveTo(a,b.xs[h],b.ys[h]):g.U.P.moveTo(a,(b.xs[h]+m)/2,(b.ys[h]+p)/2);l?q&&g.U.P.lineTo(a,m,p):u?g.U.P.qcurveTo(a,m,p,b.xs[k],b.ys[k]):g.U.P.qcurveTo(a,m,p,(m+b.xs[k])/2,(p+b.ys[k])/2)}g.U.P.closePath(a)}};g.U._compoGlyph=function(b,a,c){for(var d=0;d<b.parts.length;d++){var e= | ||
{cmds:[],crds:[]},f=b.parts[d];g.U._drawGlyf(f.glyphIndex,a,e);f=f.m;for(var h=0;h<e.crds.length;h+=2){var k=e.crds[h],l=e.crds[h+1];c.crds.push(k*f.a+l*f.b+f.tx);c.crds.push(k*f.c+l*f.d+f.ty)}for(h=0;h<e.cmds.length;h++)c.cmds.push(e.cmds[h])}};g.U._getGlyphClass=function(b,a){b=g._lctf.getInterval(a,b);return-1==b?0:a[b+2]};g.U.getPairAdjustment=function(b,a,c){if(b.GPOS){var d=b.GPOS,e=d.lookupList;d=d.featureList;for(var f=[],h=0;h<d.length;h++){var k=d[h];if("kern"==k.tag)for(var l=0;l<k.tab.length;l++)if(!f[k.tab[l]]){f[k.tab[l]]= | ||
!0;for(var q=e[k.tab[l]],t=0;t<q.tabs.length;t++)if(null!=q.tabs[h]){var m=q.tabs[t];if(m.coverage){var p=g._lctf.coverageIndex(m.coverage,a);if(-1==p)continue}if(1!=q.ltype&&2==q.ltype){var n;if(1==m.fmt)for(m=m.pairsets[p],h=0;h<m.length;h++)m[h].gid2==c&&(n=m[h]);else if(2==m.fmt){n=g.U._getGlyphClass(a,m.classDef1);var r=g.U._getGlyphClass(c,m.classDef2);n=m.matrix[n][r]}if(n&&n.val2)return n.val2[2]}}}}}return b.kern&&(a=b.kern.glyph1.indexOf(a),-1!=a&&(c=b.kern.rval[a].glyph2.indexOf(c),-1!= | ||
!0;for(var q=e[k.tab[l]],u=0;u<q.tabs.length;u++)if(null!=q.tabs[h]){var m=q.tabs[u];if(m.coverage){var p=g._lctf.coverageIndex(m.coverage,a);if(-1==p)continue}if(1!=q.ltype&&2==q.ltype){var n;if(1==m.fmt)for(m=m.pairsets[p],h=0;h<m.length;h++)m[h].gid2==c&&(n=m[h]);else if(2==m.fmt){n=g.U._getGlyphClass(a,m.classDef1);var t=g.U._getGlyphClass(c,m.classDef2);n=m.matrix[n][t]}if(n&&n.val2)return n.val2[2]}}}}}return b.kern&&(a=b.kern.glyph1.indexOf(a),-1!=a&&(c=b.kern.rval[a].glyph2.indexOf(c),-1!= | ||
c))?b.kern.rval[a].vals[c]:0};g.U.stringToGlyphs=function(b,a){for(var c=[],d=0;d<a.length;d++){var e=a.codePointAt(d);65535<e&&d++;c.push(g.U.codeToGlyph(b,e))}for(d=0;d<a.length;d++){e=a.codePointAt(d);if(2367==e){var f=c[d-1];c[d-1]=c[d];c[d]=f}65535<e&&d++}d=b.GSUB;if(null==d)return c;b=d.lookupList;d=d.featureList;e="rlig liga mset isol init fina medi half pres blws".split(" ");f=[];for(var h=0;h<d.length;h++){var k=d[h];if(-1!=e.indexOf(k.tag))for(var l=0;l<k.tab.length;l++)if(!f[k.tab[l]]){f[k.tab[l]]= | ||
!0;for(var q=b[k.tab[l]],t=0;t<c.length;t++){var m=g.U._getWPfeature(a,t);-1!="isol,init,fina,medi".indexOf(k.tag)&&k.tag!=m||g.U._applySubs(c,t,q,b)}}}return c};g.U._getWPfeature=function(b,a){var c=0==a||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a-1]),d=a==b.length-1||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a+1]);c||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a- | ||
!0;for(var q=b[k.tab[l]],u=0;u<c.length;u++){var m=g.U._getWPfeature(a,u);-1!="isol,init,fina,medi".indexOf(k.tag)&&k.tag!=m||g.U._applySubs(c,u,q,b)}}}return c};g.U._getWPfeature=function(b,a){var c=0==a||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a-1]),d=a==b.length-1||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a+1]);c||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a- | ||
1])||(c=!0);d||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a])|| | ||
(d=!0);d||-1=="\ua872\u0acd\u0ad7".indexOf(b[a+1])||(d=!0);c||-1=="\ua872\u0acd\u0ad7".indexOf(b[a])||(c=!0);return c?d?"isol":"init":d?"fina":"medi"};g.U._applySubs=function(b,a,c,d){for(var e=b.length-a-1,f=0;f<c.tabs.length;f++)if(null!=c.tabs[f]){var h=c.tabs[f];if(h.coverage){var k=g._lctf.coverageIndex(h.coverage,b[a]);if(-1==k)continue}if(1==c.ltype)b[a]=1==h.fmt?b[a]+h.delta:h.newg[k];else if(4==c.ltype)for(var l=h.vals[k],q=0;q<l.length;q++){var t=l[q];h=t.chain.length;if(!(h>e)){for(var m= | ||
!0,p=0,n=0;n<h;n++){for(;-1==b[a+p+(1+n)];)p++;t.chain[n]!=b[a+p+(1+n)]&&(m=!1)}if(m){b[a]=t.nglyph;for(n=0;n<h+p;n++)b[a+n+1]=-1;break}}}else if(5==c.ltype&&2==h.fmt)for(l=g._lctf.getInterval(h.cDef,b[a]),p=h.scset[h.cDef[l+2]],t=0;t<p.length;t++){q=p[t];var r=q.input;if(!(r.length>e)){m=!0;for(n=0;n<r.length;n++){var w=g._lctf.getInterval(h.cDef,b[a+1+n]);if(-1==l&&h.cDef[w+2]!=r[n]){m=!1;break}}if(m)for(m=q.substLookupRecords,q=0;q<m.length;q+=2);}}else if(6==c.ltype&&3==h.fmt&&g.U._glsCovered(b, | ||
h.backCvg,a-h.backCvg.length)&&g.U._glsCovered(b,h.inptCvg,a)&&g.U._glsCovered(b,h.ahedCvg,a+h.inptCvg.length))for(m=h.lookupRec,t=0;t<m.length;t+=2)l=m[t],g.U._applySubs(b,a+l,d[m[t+1]],d)}};g.U._glsCovered=function(b,a,c){for(var d=0;d<a.length;d++)if(-1==g._lctf.coverageIndex(a[d],b[c+d]))return!1;return!0};g.U.glyphsToPath=function(b,a,c){for(var d={cmds:[],crds:[]},e=0,f=0;f<a.length;f++){var h=a[f];if(-1!=h){for(var k=f<a.length-1&&-1!=a[f+1]?a[f+1]:0,l=g.U.glyphToPath(b,h),q=0;q<l.crds.length;q+= | ||
(d=!0);d||-1=="\ua872\u0acd\u0ad7".indexOf(b[a+1])||(d=!0);c||-1=="\ua872\u0acd\u0ad7".indexOf(b[a])||(c=!0);return c?d?"isol":"init":d?"fina":"medi"};g.U._applySubs=function(b,a,c,d){for(var e=b.length-a-1,f=0;f<c.tabs.length;f++)if(null!=c.tabs[f]){var h=c.tabs[f];if(h.coverage){var k=g._lctf.coverageIndex(h.coverage,b[a]);if(-1==k)continue}if(1==c.ltype)b[a]=1==h.fmt?b[a]+h.delta:h.newg[k];else if(4==c.ltype)for(var l=h.vals[k],q=0;q<l.length;q++){var u=l[q];h=u.chain.length;if(!(h>e)){for(var m= | ||
!0,p=0,n=0;n<h;n++){for(;-1==b[a+p+(1+n)];)p++;u.chain[n]!=b[a+p+(1+n)]&&(m=!1)}if(m){b[a]=u.nglyph;for(n=0;n<h+p;n++)b[a+n+1]=-1;break}}}else if(5==c.ltype&&2==h.fmt)for(l=g._lctf.getInterval(h.cDef,b[a]),p=h.scset[h.cDef[l+2]],u=0;u<p.length;u++){q=p[u];var t=q.input;if(!(t.length>e)){m=!0;for(n=0;n<t.length;n++){var w=g._lctf.getInterval(h.cDef,b[a+1+n]);if(-1==l&&h.cDef[w+2]!=t[n]){m=!1;break}}if(m)for(m=q.substLookupRecords,q=0;q<m.length;q+=2);}}else if(6==c.ltype&&3==h.fmt&&g.U._glsCovered(b, | ||
h.backCvg,a-h.backCvg.length)&&g.U._glsCovered(b,h.inptCvg,a)&&g.U._glsCovered(b,h.ahedCvg,a+h.inptCvg.length))for(m=h.lookupRec,u=0;u<m.length;u+=2)l=m[u],g.U._applySubs(b,a+l,d[m[u+1]],d)}};g.U._glsCovered=function(b,a,c){for(var d=0;d<a.length;d++)if(-1==g._lctf.coverageIndex(a[d],b[c+d]))return!1;return!0};g.U.glyphsToPath=function(b,a,c){for(var d={cmds:[],crds:[]},e=0,f=0;f<a.length;f++){var h=a[f];if(-1!=h){for(var k=f<a.length-1&&-1!=a[f+1]?a[f+1]:0,l=g.U.glyphToPath(b,h),q=0;q<l.crds.length;q+= | ||
2)d.crds.push(l.crds[q]+e),d.crds.push(l.crds[q+1]);c&&d.cmds.push(c);for(q=0;q<l.cmds.length;q++)d.cmds.push(l.cmds[q]);c&&d.cmds.push("X");e+=b.hmtx.aWidth[h];f<a.length-1&&(e+=g.U.getPairAdjustment(b,h,k))}}return d};g.U.pathToSVG=function(b,a){null==a&&(a=5);for(var c=[],d=0,e={M:2,L:2,Q:4,C:6},f=0;f<b.cmds.length;f++){var g=b.cmds[f],k=d+(e[g]?e[g]:0);for(c.push(g);d<k;)g=b.crds[d++],c.push(parseFloat(g.toFixed(a))+(d==k?"":" "))}return c.join("")};g.U.pathToContext=function(b,a){for(var c=0, | ||
d=b.crds,e=0;e<b.cmds.length;e++){var f=b.cmds[e];"M"==f?(a.moveTo(d[c],d[c+1]),c+=2):"L"==f?(a.lineTo(d[c],d[c+1]),c+=2):"C"==f?(a.bezierCurveTo(d[c],d[c+1],d[c+2],d[c+3],d[c+4],d[c+5]),c+=6):"Q"==f?(a.quadraticCurveTo(d[c],d[c+1],d[c+2],d[c+3]),c+=4):"#"==f.charAt(0)?(a.beginPath(),a.fillStyle=f):"Z"==f?a.closePath():"X"==f&&a.fill()}};g.U.P={};g.U.P.moveTo=function(b,a,c){b.cmds.push("M");b.crds.push(a,c)};g.U.P.lineTo=function(b,a,c){b.cmds.push("L");b.crds.push(a,c)};g.U.P.curveTo=function(b, | ||
a,c,d,e,f,g){b.cmds.push("C");b.crds.push(a,c,d,e,f,g)};g.U.P.qcurveTo=function(b,a,c,d,e){b.cmds.push("Q");b.crds.push(a,c,d,e)};g.U.P.closePath=function(b){b.cmds.push("Z")};g.U._drawCFF=function(b,a,c,d,e){for(var f=a.stack,h=a.nStems,k=a.haveWidth,l=a.width,q=a.open,t=0,m=a.x,p=a.y,n,r,w,v,y,A,B,D,E,u,z={val:0,size:0};t<b.length;){g.CFF.getCharString(b,t,z);var x=z.val;t+=z.size;if("o1"==x||"o18"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length=0,k=!0;else if("o3"== | ||
x||"o23"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length=0,k=!0;else if("o4"==x)1<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),q&&g.U.P.closePath(e),p+=f.pop(),g.U.P.moveTo(e,m,p),q=!0;else if("o5"==x)for(;0<f.length;)m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p);else if("o6"==x||"o7"==x)for(y=f.length,n="o6"==x,r=0;r<y;r++)w=f.shift(),n?m+=w:p+=w,n=!n,g.U.P.lineTo(e,m,p);else if("o8"==x||"o24"==x){y=f.length;for(A=0;A+6<=y;)n=m+f.shift(),r=p+f.shift(),w=n+f.shift(), | ||
v=r+f.shift(),m=w+f.shift(),p=v+f.shift(),g.U.P.curveTo(e,n,r,w,v,m,p),A+=6;"o24"==x&&(m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p))}else if("o11"==x)break;else if("o1234"==x||"o1235"==x||"o1236"==x||"o1237"==x)"o1234"==x&&(n=m+f.shift(),r=p,w=n+f.shift(),v=r+f.shift(),E=w+f.shift(),u=v,y=E+f.shift(),A=v,B=y+f.shift(),D=p,m=B+f.shift(),g.U.P.curveTo(e,n,r,w,v,E,u),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1235"==x&&(n=m+f.shift(),r=p+f.shift(),w=n+f.shift(),v=r+f.shift(),E=w+f.shift(),u=v+f.shift(),y=E+f.shift(), | ||
A=u+f.shift(),B=y+f.shift(),D=A+f.shift(),m=B+f.shift(),p=D+f.shift(),f.shift(),g.U.P.curveTo(e,n,r,w,v,E,u),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1236"==x&&(n=m+f.shift(),r=p+f.shift(),w=n+f.shift(),v=r+f.shift(),E=w+f.shift(),u=v,y=E+f.shift(),A=v,B=y+f.shift(),D=A+f.shift(),m=B+f.shift(),g.U.P.curveTo(e,n,r,w,v,E,u),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1237"==x&&(n=m+f.shift(),r=p+f.shift(),w=n+f.shift(),v=r+f.shift(),E=w+f.shift(),u=v+f.shift(),y=E+f.shift(),A=u+f.shift(),B=y+f.shift(),D=A+f.shift(),Math.abs(B- | ||
m)>Math.abs(D-p)?m=B+f.shift():p=D+f.shift(),g.U.P.curveTo(e,n,r,w,v,E,u),g.U.P.curveTo(e,y,A,B,D,m,p));else if("o14"==x)0<f.length&&!k&&(l=f.shift()+c.nominalWidthX,k=!0),4==f.length&&(n=f.shift(),r=f.shift(),v=f.shift(),w=f.shift(),v=g.CFF.glyphBySE(c,v),w=g.CFF.glyphBySE(c,w),g.U._drawCFF(c.CharStrings[v],a,c,d,e),a.x=n,a.y=r,g.U._drawCFF(c.CharStrings[w],a,c,d,e)),q&&(g.U.P.closePath(e),q=!1);else if("o19"==x||"o20"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length= | ||
0,k=!0,t+=h+7>>3;else if("o21"==x)2<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),p+=f.pop(),m+=f.pop(),q&&g.U.P.closePath(e),g.U.P.moveTo(e,m,p),q=!0;else if("o22"==x)1<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),m+=f.pop(),q&&g.U.P.closePath(e),g.U.P.moveTo(e,m,p),q=!0;else if("o25"==x){for(;6<f.length;)m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p);n=m+f.shift();r=p+f.shift();w=n+f.shift();v=r+f.shift();m=w+f.shift();p=v+f.shift();g.U.P.curveTo(e,n,r,w,v,m,p)}else if("o26"==x)for(f.length% | ||
2&&(m+=f.shift());0<f.length;)n=m,r=p+f.shift(),w=n+f.shift(),v=r+f.shift(),m=w,p=v+f.shift(),g.U.P.curveTo(e,n,r,w,v,m,p);else if("o27"==x)for(f.length%2&&(p+=f.shift());0<f.length;)n=m+f.shift(),r=p,w=n+f.shift(),v=r+f.shift(),m=w+f.shift(),p=v,g.U.P.curveTo(e,n,r,w,v,m,p);else if("o10"==x||"o29"==x)n="o10"==x?d:c,0==f.length?console.log("error: empty stack"):(r=f.pop(),n=n.Subrs[r+n.Bias],a.x=m,a.y=p,a.nStems=h,a.haveWidth=k,a.width=l,a.open=q,g.U._drawCFF(n,a,c,d,e),m=a.x,p=a.y,h=a.nStems,k=a.haveWidth, | ||
l=a.width,q=a.open);else if("o30"==x||"o31"==x)for(n=f.length,A=0,x="o31"==x,y=n&-3,A+=n-y;A<y;)x?(n=m+f.shift(),r=p,w=n+f.shift(),v=r+f.shift(),p=v+f.shift(),5==y-A?(m=w+f.shift(),A++):m=w,x=!1):(n=m,r=p+f.shift(),w=n+f.shift(),v=r+f.shift(),m=w+f.shift(),5==y-A?(p=v+f.shift(),A++):p=v,x=!0),g.U.P.curveTo(e,n,r,w,v,m,p),A+=4;else{if("o"==(x+"").charAt(0))throw console.log("Unknown operation: "+x,b),x;f.push(x)}}a.x=m;a.y=p;a.nStems=h;a.haveWidth=k;a.width=l;a.open=q};return g},function(){function u(b, | ||
a){function c(){var a=g.getUint16(k);k+=2;return a}function d(){var a=g.getUint32(k);k+=4;return a}function e(a){y.setUint16(A,a);A+=2}function f(a){y.setUint32(A,a);A+=4}var g=new DataView(b),k=0;d();var l=d();d();var q=c();c();d();c();c();d();d();d();d();d();for(var t=0;Math.pow(2,t)<=q;)t++;t--;for(var m=16*Math.pow(2,t),p=16*q-m,n=12,r=[],w=0;w<q;w++)r.push({tag:d(),offset:d(),compLength:d(),origLength:d(),origChecksum:d()}),n+=16;var u=new Uint8Array(12+16*r.length+r.reduce(function(a,b){return a+ | ||
b.origLength+4},0));w=u.buffer;var y=new DataView(w),A=0;f(l);e(q);e(m);e(t);e(p);r.forEach(function(a){f(a.tag);f(a.origChecksum);f(n);f(a.origLength);a.outOffset=n;n+=a.origLength;0!=n%4&&(n+=4-n%4)});var B;r.forEach(function(c){var d=b.slice(c.offset,c.offset+c.compLength);if(c.compLength!=c.origLength){var e=new Uint8Array(c.origLength);a(new Uint8Array(d,2),e)}else e=new Uint8Array(d);u.set(e,c.outOffset);n=c.outOffset+c.origLength;d=0;0!=n%4&&(d=4-n%4);u.set((new Uint8Array(d)).buffer,c.outOffset+ | ||
c.origLength);B=n+d});return w.slice(0,B)}var g=function(){function b(){this.table=new Uint16Array(16);this.trans=new Uint16Array(288)}function a(a,c){this.source=a;this.bitcount=this.tag=this.sourceIndex=0;this.dest=c;this.destLen=0;this.ltree=new b;this.dtree=new b}function c(a,b,c,d){var e;for(e=0;e<c;++e)a[e]=0;for(e=0;e<30-c;++e)a[e+c]=e/c|0;c=d;for(e=0;30>e;++e)b[e]=c,c+=1<<a[e]}function d(a,b,c,d){var e,f;for(e=0;16>e;++e)a.table[e]=0;for(e=0;e<d;++e)a.table[b[c+e]]++;for(e=f=a.table[0]=0;16> | ||
e;++e)u[e]=f,f+=a.table[e];for(e=0;e<d;++e)b[c+e]&&(a.trans[u[b[c+e]]++]=e)}function e(a,b,c){if(!b)return c;for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var d=a.tag&65535>>>16-b;a.tag>>>=b;a.bitcount-=b;return d+c}function f(a,b){for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var c=0,d=0,e=0,f=a.tag;do d=2*d+(f&1),f>>>=1,++e,c+=b.table[e],d-=b.table[e];while(0<=d);a.tag=f;a.bitcount-=e;return b.trans[c+d]}function g(a,b,c){for(;;){var d= | ||
f(a,b);if(256===d)return 0;if(256>d)a.dest[a.destLen++]=d;else{var g;d-=257;d=e(a,q[d],t[d]);var h=f(a,c);for(g=h=a.destLen-e(a,m[h],p[h]);g<h+d;++g)a.dest[a.destLen++]=a.dest[g]}}}var k=new b,l=new b,q=new Uint8Array(30),t=new Uint16Array(30),m=new Uint8Array(30),p=new Uint16Array(30),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new b,w=new Uint8Array(320),u=new Uint16Array(16);(function(a,b){var c;for(c=0;7>c;++c)a.table[c]=0;a.table[7]=24;a.table[8]=152;a.table[9]=112;for(c= | ||
0;24>c;++c)a.trans[c]=256+c;for(c=0;144>c;++c)a.trans[24+c]=c;for(c=0;8>c;++c)a.trans[168+c]=280+c;for(c=0;112>c;++c)a.trans[176+c]=144+c;for(c=0;5>c;++c)b.table[c]=0;b.table[5]=32;for(c=0;32>c;++c)b.trans[c]=c})(k,l);c(q,t,4,3);c(m,p,2,1);q[28]=0;t[28]=258;return function(b,c){b=new a(b,c);do{c=b;c.bitcount--||(c.tag=c.source[c.sourceIndex++],c.bitcount=7);var h=c.tag&1;c.tag>>>=1;c=h;h=e(b,2,0);switch(h){case 0:for(h=b;8<h.bitcount;)h.sourceIndex--,h.bitcount-=8;var m=h.source[h.sourceIndex+1]; | ||
m=256*m+h.source[h.sourceIndex];var q=h.source[h.sourceIndex+3];q=256*q+h.source[h.sourceIndex+2];if(m!==(~q&65535))h=-3;else{h.sourceIndex+=4;for(q=m;q;--q)h.dest[h.destLen++]=h.source[h.sourceIndex++];h=h.bitcount=0}break;case 1:h=g(b,k,l);break;case 2:var p;m=b;var t=b.ltree,u=b.dtree;q=e(m,5,257);h=e(m,5,1);var v=e(m,4,4);for(p=0;19>p;++p)w[p]=0;for(p=0;p<v;++p){var y=e(m,3,0);w[n[p]]=y}d(r,w,0,19);for(p=0;p<q+h;)switch(v=f(m,r),v){case 16:y=w[p-1];for(v=e(m,2,3);v;--v)w[p++]=y;break;case 17:for(v= | ||
e(m,3,3);v;--v)w[p++]=0;break;case 18:for(v=e(m,7,11);v;--v)w[p++]=0;break;default:w[p++]=v}d(t,w,0,q);d(u,w,q,h);h=g(b,b.ltree,b.dtree);break;default:h=-3}if(0!==h)throw Error("Data error");}while(!c);return b.destLen<b.dest.length?"function"===typeof b.dest.slice?b.dest.slice(0,b.destLen):b.dest.subarray(0,b.destLen):b.dest}}();return function(b){return u(b,g)}},function(u,g){function b(b){var d=b[0],f=Object.create(null),g={unitsPerEm:d.head.unitsPerEm,ascender:d.hhea.ascender,descender:d.hhea.descender, | ||
forEachGlyph:function(b,e,h,t){var k=0,l=1/g.unitsPerEm*e;u.U.stringToGlyphs(d,b).forEach(function(b){if(-1!==b){var g=f[b];if(!g){g=u.glyf._parseGlyf(d,b)||{xMin:0,xMax:0,yMin:0,yMax:0};var m=u.U.glyphToPath(d,b),q=m.cmds,p=m.crds;g=f[b]={index:b,unicode:a(d,b),advanceWidth:d.hmtx.aWidth[b],xMin:g.xMin,yMin:g.yMin,xMax:g.xMax,yMax:g.yMax,pathCommandCount:q.length,forEachPathCommand:function(a){for(var b=0,d=[],e=0,f=q.length;e<f;e++){var g=c[q[e]];d.length=1+g;d[0]=q[e];for(var h=1;h<=g;h++)d[h]= | ||
p[b++];a.apply(null,d)}}}}t.call(null,g,k);g.advanceWidth&&(k+=g.advanceWidth*l);h&&(k+=h*e)}});return k}};return g}function a(a,b){var c=a.glyphToUnicodeMap;if(!c){c=a.glyphToUnicodeMap=Object.create(null);var d=a.cmap,e=-1;null!=d.p0e4?e=d.p0e4:null!=d.p3e1?e=d.p3e1:null!=d.p1e0?e=d.p1e0:null!=d.p0e3&&(e=d.p0e3);if(-1===e)throw"no familiar platform and encoding!";e=d.tables[e];if(0===e.format)for(a=0;a<e.map.length;a++)c[e.map[a]]=a;else if(4===e.format){d=e.startCount;e=e.endCount;for(var g=0;g< | ||
d.length;g++)for(var q=d[g];q<=e[g];q++)c[u.U.codeToGlyph(a,q)]=q}else if(12===e.format)e.groups.forEach(function(a){var b=a[1],d=a[2];for(a=a[0];a<=b;a++)c[d++]=a});else throw"unknown cmap table format "+e.format;}return c[b]||0}var c={M:2,L:2,Q:4,C:6,Z:0};return function(a){var c=new Uint8Array(a,0,4);c=u._bin.readASCII(c,0,4);if("wOFF"===c)a=g(a);else if("wOF2"===c)throw Error("woff2 fonts not supported");return b(u.parse(a))}}],init:function(u,g,b){u=u();g=g();return b(u,g)}}),H={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff", | ||
sdfGlyphSize:64},K=document.createElement("a"),L=Object.create(null);G=F.defineWorkerModule({dependencies:[H,.125,G,function(u){function g(a){return a*a}var b=u.sdfTextureSize,a=u.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,t=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 m=b.data;if(m)if(m.cx===q&&m.cy===t){for(;m.next;)m=m.next;m.next=a}else b.data=null,this._insertSegment(m,b),this._insertSegment(a,b);else q=(t<b.cy? | ||
a,c,d,e,f,g){b.cmds.push("C");b.crds.push(a,c,d,e,f,g)};g.U.P.qcurveTo=function(b,a,c,d,e){b.cmds.push("Q");b.crds.push(a,c,d,e)};g.U.P.closePath=function(b){b.cmds.push("Z")};g.U._drawCFF=function(b,a,c,d,e){for(var f=a.stack,h=a.nStems,k=a.haveWidth,l=a.width,q=a.open,u=0,m=a.x,p=a.y,n,t,w,v,y,A,B,D,E,r,z={val:0,size:0};u<b.length;){g.CFF.getCharString(b,u,z);var x=z.val;u+=z.size;if("o1"==x||"o18"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length=0,k=!0;else if("o3"== | ||
x||"o23"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length=0,k=!0;else if("o4"==x)1<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),q&&g.U.P.closePath(e),p+=f.pop(),g.U.P.moveTo(e,m,p),q=!0;else if("o5"==x)for(;0<f.length;)m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p);else if("o6"==x||"o7"==x)for(y=f.length,n="o6"==x,t=0;t<y;t++)w=f.shift(),n?m+=w:p+=w,n=!n,g.U.P.lineTo(e,m,p);else if("o8"==x||"o24"==x){y=f.length;for(A=0;A+6<=y;)n=m+f.shift(),t=p+f.shift(),w=n+f.shift(), | ||
v=t+f.shift(),m=w+f.shift(),p=v+f.shift(),g.U.P.curveTo(e,n,t,w,v,m,p),A+=6;"o24"==x&&(m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p))}else if("o11"==x)break;else if("o1234"==x||"o1235"==x||"o1236"==x||"o1237"==x)"o1234"==x&&(n=m+f.shift(),t=p,w=n+f.shift(),v=t+f.shift(),E=w+f.shift(),r=v,y=E+f.shift(),A=v,B=y+f.shift(),D=p,m=B+f.shift(),g.U.P.curveTo(e,n,t,w,v,E,r),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1235"==x&&(n=m+f.shift(),t=p+f.shift(),w=n+f.shift(),v=t+f.shift(),E=w+f.shift(),r=v+f.shift(),y=E+f.shift(), | ||
A=r+f.shift(),B=y+f.shift(),D=A+f.shift(),m=B+f.shift(),p=D+f.shift(),f.shift(),g.U.P.curveTo(e,n,t,w,v,E,r),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1236"==x&&(n=m+f.shift(),t=p+f.shift(),w=n+f.shift(),v=t+f.shift(),E=w+f.shift(),r=v,y=E+f.shift(),A=v,B=y+f.shift(),D=A+f.shift(),m=B+f.shift(),g.U.P.curveTo(e,n,t,w,v,E,r),g.U.P.curveTo(e,y,A,B,D,m,p)),"o1237"==x&&(n=m+f.shift(),t=p+f.shift(),w=n+f.shift(),v=t+f.shift(),E=w+f.shift(),r=v+f.shift(),y=E+f.shift(),A=r+f.shift(),B=y+f.shift(),D=A+f.shift(),Math.abs(B- | ||
m)>Math.abs(D-p)?m=B+f.shift():p=D+f.shift(),g.U.P.curveTo(e,n,t,w,v,E,r),g.U.P.curveTo(e,y,A,B,D,m,p));else if("o14"==x)0<f.length&&!k&&(l=f.shift()+c.nominalWidthX,k=!0),4==f.length&&(n=f.shift(),t=f.shift(),v=f.shift(),w=f.shift(),v=g.CFF.glyphBySE(c,v),w=g.CFF.glyphBySE(c,w),g.U._drawCFF(c.CharStrings[v],a,c,d,e),a.x=n,a.y=t,g.U._drawCFF(c.CharStrings[w],a,c,d,e)),q&&(g.U.P.closePath(e),q=!1);else if("o19"==x||"o20"==x)(n=0!==f.length%2)&&!k&&(l=f.shift()+d.nominalWidthX),h+=f.length>>1,f.length= | ||
0,k=!0,u+=h+7>>3;else if("o21"==x)2<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),p+=f.pop(),m+=f.pop(),q&&g.U.P.closePath(e),g.U.P.moveTo(e,m,p),q=!0;else if("o22"==x)1<f.length&&!k&&(l=f.shift()+d.nominalWidthX,k=!0),m+=f.pop(),q&&g.U.P.closePath(e),g.U.P.moveTo(e,m,p),q=!0;else if("o25"==x){for(;6<f.length;)m+=f.shift(),p+=f.shift(),g.U.P.lineTo(e,m,p);n=m+f.shift();t=p+f.shift();w=n+f.shift();v=t+f.shift();m=w+f.shift();p=v+f.shift();g.U.P.curveTo(e,n,t,w,v,m,p)}else if("o26"==x)for(f.length% | ||
2&&(m+=f.shift());0<f.length;)n=m,t=p+f.shift(),w=n+f.shift(),v=t+f.shift(),m=w,p=v+f.shift(),g.U.P.curveTo(e,n,t,w,v,m,p);else if("o27"==x)for(f.length%2&&(p+=f.shift());0<f.length;)n=m+f.shift(),t=p,w=n+f.shift(),v=t+f.shift(),m=w+f.shift(),p=v,g.U.P.curveTo(e,n,t,w,v,m,p);else if("o10"==x||"o29"==x)n="o10"==x?d:c,0==f.length?console.log("error: empty stack"):(t=f.pop(),n=n.Subrs[t+n.Bias],a.x=m,a.y=p,a.nStems=h,a.haveWidth=k,a.width=l,a.open=q,g.U._drawCFF(n,a,c,d,e),m=a.x,p=a.y,h=a.nStems,k=a.haveWidth, | ||
l=a.width,q=a.open);else if("o30"==x||"o31"==x)for(n=f.length,A=0,x="o31"==x,y=n&-3,A+=n-y;A<y;)x?(n=m+f.shift(),t=p,w=n+f.shift(),v=t+f.shift(),p=v+f.shift(),5==y-A?(m=w+f.shift(),A++):m=w,x=!1):(n=m,t=p+f.shift(),w=n+f.shift(),v=t+f.shift(),m=w+f.shift(),5==y-A?(p=v+f.shift(),A++):p=v,x=!0),g.U.P.curveTo(e,n,t,w,v,m,p),A+=4;else{if("o"==(x+"").charAt(0))throw console.log("Unknown operation: "+x,b),x;f.push(x)}}a.x=m;a.y=p;a.nStems=h;a.haveWidth=k;a.width=l;a.open=q};return g},function(){function r(b, | ||
a){function c(){var a=g.getUint16(k);k+=2;return a}function d(){var a=g.getUint32(k);k+=4;return a}function e(a){y.setUint16(A,a);A+=2}function f(a){y.setUint32(A,a);A+=4}var g=new DataView(b),k=0;d();var l=d();d();var q=c();c();d();c();c();d();d();d();d();d();for(var u=0;Math.pow(2,u)<=q;)u++;u--;for(var m=16*Math.pow(2,u),p=16*q-m,n=12,t=[],r=0;r<q;r++)t.push({tag:d(),offset:d(),compLength:d(),origLength:d(),origChecksum:d()}),n+=16;var v=new Uint8Array(12+16*t.length+t.reduce(function(a,b){return a+ | ||
b.origLength+4},0));r=v.buffer;var y=new DataView(r),A=0;f(l);e(q);e(m);e(u);e(p);t.forEach(function(a){f(a.tag);f(a.origChecksum);f(n);f(a.origLength);a.outOffset=n;n+=a.origLength;0!=n%4&&(n+=4-n%4)});var B;t.forEach(function(c){var d=b.slice(c.offset,c.offset+c.compLength);if(c.compLength!=c.origLength){var e=new Uint8Array(c.origLength);a(new Uint8Array(d,2),e)}else e=new Uint8Array(d);v.set(e,c.outOffset);n=c.outOffset+c.origLength;d=0;0!=n%4&&(d=4-n%4);v.set((new Uint8Array(d)).buffer,c.outOffset+ | ||
c.origLength);B=n+d});return r.slice(0,B)}var g=function(){function b(){this.table=new Uint16Array(16);this.trans=new Uint16Array(288)}function a(a,c){this.source=a;this.bitcount=this.tag=this.sourceIndex=0;this.dest=c;this.destLen=0;this.ltree=new b;this.dtree=new b}function c(a,b,c,d){var e;for(e=0;e<c;++e)a[e]=0;for(e=0;e<30-c;++e)a[e+c]=e/c|0;c=d;for(e=0;30>e;++e)b[e]=c,c+=1<<a[e]}function d(a,b,c,d){var e,f;for(e=0;16>e;++e)a.table[e]=0;for(e=0;e<d;++e)a.table[b[c+e]]++;for(e=f=a.table[0]=0;16> | ||
e;++e)v[e]=f,f+=a.table[e];for(e=0;e<d;++e)b[c+e]&&(a.trans[v[b[c+e]]++]=e)}function e(a,b,c){if(!b)return c;for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var d=a.tag&65535>>>16-b;a.tag>>>=b;a.bitcount-=b;return d+c}function f(a,b){for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var c=0,d=0,e=0,f=a.tag;do d=2*d+(f&1),f>>>=1,++e,c+=b.table[e],d-=b.table[e];while(0<=d);a.tag=f;a.bitcount-=e;return b.trans[c+d]}function g(a,b,c){for(;;){var d= | ||
f(a,b);if(256===d)return 0;if(256>d)a.dest[a.destLen++]=d;else{var g;d-=257;d=e(a,q[d],u[d]);var h=f(a,c);for(g=h=a.destLen-e(a,m[h],p[h]);g<h+d;++g)a.dest[a.destLen++]=a.dest[g]}}}var k=new b,l=new b,q=new Uint8Array(30),u=new Uint16Array(30),m=new Uint8Array(30),p=new Uint16Array(30),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t=new b,r=new Uint8Array(320),v=new Uint16Array(16);(function(a,b){var c;for(c=0;7>c;++c)a.table[c]=0;a.table[7]=24;a.table[8]=152;a.table[9]=112;for(c= | ||
0;24>c;++c)a.trans[c]=256+c;for(c=0;144>c;++c)a.trans[24+c]=c;for(c=0;8>c;++c)a.trans[168+c]=280+c;for(c=0;112>c;++c)a.trans[176+c]=144+c;for(c=0;5>c;++c)b.table[c]=0;b.table[5]=32;for(c=0;32>c;++c)b.trans[c]=c})(k,l);c(q,u,4,3);c(m,p,2,1);q[28]=0;u[28]=258;return function(b,c){b=new a(b,c);do{c=b;c.bitcount--||(c.tag=c.source[c.sourceIndex++],c.bitcount=7);var h=c.tag&1;c.tag>>>=1;c=h;h=e(b,2,0);switch(h){case 0:for(h=b;8<h.bitcount;)h.sourceIndex--,h.bitcount-=8;var m=h.source[h.sourceIndex+1]; | ||
m=256*m+h.source[h.sourceIndex];var q=h.source[h.sourceIndex+3];q=256*q+h.source[h.sourceIndex+2];if(m!==(~q&65535))h=-3;else{h.sourceIndex+=4;for(q=m;q;--q)h.dest[h.destLen++]=h.source[h.sourceIndex++];h=h.bitcount=0}break;case 1:h=g(b,k,l);break;case 2:var p;m=b;var u=b.ltree,v=b.dtree;q=e(m,5,257);h=e(m,5,1);var w=e(m,4,4);for(p=0;19>p;++p)r[p]=0;for(p=0;p<w;++p){var y=e(m,3,0);r[n[p]]=y}d(t,r,0,19);for(p=0;p<q+h;)switch(w=f(m,t),w){case 16:y=r[p-1];for(w=e(m,2,3);w;--w)r[p++]=y;break;case 17:for(w= | ||
e(m,3,3);w;--w)r[p++]=0;break;case 18:for(w=e(m,7,11);w;--w)r[p++]=0;break;default:r[p++]=w}d(u,r,0,q);d(v,r,q,h);h=g(b,b.ltree,b.dtree);break;default:h=-3}if(0!==h)throw Error("Data error");}while(!c);return b.destLen<b.dest.length?"function"===typeof b.dest.slice?b.dest.slice(0,b.destLen):b.dest.subarray(0,b.destLen):b.dest}}();return function(b){return r(b,g)}},function(r,g){function b(b){var d=b[0],f=Object.create(null),g={unitsPerEm:d.head.unitsPerEm,ascender:d.hhea.ascender,descender:d.hhea.descender, | ||
forEachGlyph:function(b,e,h,u){var k=0,l=1/g.unitsPerEm*e;r.U.stringToGlyphs(d,b).forEach(function(b){if(-1!==b){var g=f[b];if(!g){g=r.glyf._parseGlyf(d,b)||{xMin:0,xMax:0,yMin:0,yMax:0};var m=r.U.glyphToPath(d,b),q=m.cmds,p=m.crds;g=f[b]={index:b,unicode:a(d,b),advanceWidth:d.hmtx.aWidth[b],xMin:g.xMin,yMin:g.yMin,xMax:g.xMax,yMax:g.yMax,pathCommandCount:q.length,forEachPathCommand:function(a){for(var b=0,d=[],e=0,f=q.length;e<f;e++){var g=c[q[e]];d.length=1+g;d[0]=q[e];for(var h=1;h<=g;h++)d[h]= | ||
p[b++];a.apply(null,d)}}}}u.call(null,g,k);g.advanceWidth&&(k+=g.advanceWidth*l);h&&(k+=h*e)}});return k}};return g}function a(a,b){var c=a.glyphToUnicodeMap;if(!c){c=a.glyphToUnicodeMap=Object.create(null);var d=a.cmap,e=-1;null!=d.p0e4?e=d.p0e4:null!=d.p3e1?e=d.p3e1:null!=d.p1e0?e=d.p1e0:null!=d.p0e3&&(e=d.p0e3);if(-1===e)throw"no familiar platform and encoding!";e=d.tables[e];if(0===e.format)for(a=0;a<e.map.length;a++)c[e.map[a]]=a;else if(4===e.format){d=e.startCount;e=e.endCount;for(var g=0;g< | ||
d.length;g++)for(var q=d[g];q<=e[g];q++)c[r.U.codeToGlyph(a,q)]=q}else if(12===e.format)e.groups.forEach(function(a){var b=a[1],d=a[2];for(a=a[0];a<=b;a++)c[d++]=a});else throw"unknown cmap table format "+e.format;}return c[b]||0}var c={M:2,L:2,Q:4,C:6,Z:0};return function(a){var c=new Uint8Array(a,0,4);c=r._bin.readASCII(c,0,4);if("wOFF"===c)a=g(a);else if("wOF2"===c)throw Error("woff2 fonts not supported");return b(r.parse(a))}}],init:function(r,g,b){r=r();g=g();return b(r,g)}}),H={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff", | ||
sdfGlyphSize:64},K=document.createElement("a"),L=Object.create(null);G=F.defineWorkerModule({dependencies:[H,.125,G,function(r){function g(a){return a*a}var b=r.sdfTextureSize,a=r.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,u=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 m=b.data;if(m)if(m.cx===q&&m.cy===u){for(;m.next;)m=m.next;m.next=a}else b.data=null,this._insertSegment(m,b),this._insertSegment(a,b);else q=(u<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,p=c.x1-h,n=c.y1-k,r=p*p+n*n;r=r?Math.max(0,Math.min(1,((e-h)*p+(f-k)*n)/r)):0;e=Math.sqrt(g(e-(h+r*p))+g(f-(k+r*n)));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,q=(g+2*k)/b;g=d.xMin-k-l;f=d.yMin-k-q;l=d.xMax+k+l;q=d.yMax+k+q;if(d.pathCommandCount){var t=new c(d),m,p,n,r;d.forEachPathCommand(function(a,b,c,d,e,f,g){switch(a){case "M":n=m=b;r=p=c;break;case "L":b===n&&c===r||t.addLineSegment(n,r,n=b,r=c);break;case "Q":f={x:n,y:r};for(g=1;16>g;g++){a=g/15;var h=1-a;a={x:h*h*n+2*h*a*b+a*a*d,y:h*h*r+2*h*a*c+a*a*e};t.addLineSegment(f.x, | ||
f.y,a.x,a.y);f=a}n=d;r=e;break;case "C":a={x:n,y:r};for(h=1;16>h;h++){var k=h/15;var l=1-k;k={x:l*l*l*n+3*l*l*k*b+3*l*k*k*d+k*k*k*f,y:l*l*l*r+3*l*l*k*c+3*l*k*k*e+k*k*k*g};t.addLineSegment(a.x,a.y,k.x,k.y);a=k}n=f;r=g;break;case "Z":n===m&&r===p||t.addLineSegment(n,r,m,p)}});for(d=0;d<b;d++)for(var u=0;u<b;u++){var v=t.findNearestSignedDistance(g+(l-g)*(d+.5)/b,f+(q-f)*(u+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[u*b+d]=v}}return{textureData:e,renderingBounds:[g, | ||
f,l,q]}}},function(u,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(){try{var a=u(e.response);b(a)}catch(n){d(n)}};e.onerror=d;e.send()}catch(p){d(p)}}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 q=a.lineHeight;void 0===q&&(q="normal");var u=a.maxWidth;void 0===u&&(u=Infinity);var v=a.textAlign;void 0===v&&(v="left");var y=a.whiteSpace;void 0===y&&(y="normal");var A=a.overflowWrap;void 0===A&&(A="normal");var z=a.anchor;void 0===c&&(c=!1); | ||
d(h,function(a){var d=a.fontObj,f=isFinite(u),h=null,m=null,n=null,p=null,r=0,t=0,w="nowrap"!==y,B=k/d.unitsPerEm;"normal"===q&&(q=(d.ascender-d.descender)/d.unitsPerEm);q*=k;var C=(q-(d.ascender-d.descender)*B)/2,D=e.split(/\r?\n/).map(function(a){var b=0,c=[],e=[c];d.forEachGlyph(a,k,l,function(a,d){var g=a.unicode;g="number"===typeof g&&String.fromCharCode(g);var h=a.advanceWidth*B,k=!!g&&/\s/.test(g);if(w&&f&&!k&&d+h+b>u&&c.length){if(c[c.length-1].isWhitespace){var l=[];b=-d}else for(var m=c.length;m--;)if(0=== | ||
m&&"break-word"===A){l=[];b=-d;break}else if(c[m].isWhitespace){l=c.splice(m+1);m=l[0].x;b-=m;for(var n=0;n<l.length;n++)l[n].x-=m;break}if(l){for(;c[c.length-1].isWhitespace;)c.pop();e.push(c=l);t=u}}c.push({glyphObj:a,x:d+b,y:0,width:h,char:g,isWhitespace:k,isEmpty:a.xMin===a.xMax||a.yMin===a.yMax,atlasInfo:null})});for(a=0;a<e.length&&t<u;a++){var g=e[a];g.length&&(g=g[g.length-1],t=Math.max(t,g.x+g.width))}r+=e.length;return e});if(!c){var F=[],H=-(k+C);D.forEach(function(b){for(var c=0;c<b.length;c++){var d= | ||
b[c];if(d.length){var e=0,f=d[d.length-1];f=f.x+f.width;var k=0;if("center"===v)e=(t-f)/2;else if("right"===v)e=t-f;else if("justify"===v)for(var l=0,m=d.length;l<m;l++)d[l].isWhitespace&&k++;l=0;for(m=d.length;l<m;l++){var n=d[l];n.isWhitespace&&"justify"===v&&c!==b.length-1&&(e+=(t-f)/k);if(!n.isWhitespace&&!n.isEmpty){var p=n.glyphObj,r=a.glyphs[p.index];r||(r=g(p),r.atlasIndex=a.glyphCount++,h||(h=[]),h.push(r),r=a.glyphs[p.index]={atlasIndex:r.atlasIndex,glyphObj:p,renderingBounds:r.renderingBounds}); | ||
n.atlasInfo=r;e&&(n.x+=e);n.y=H;F.push(n)}}}H-=q}});var G=0,I=0;z&&(z[0]&&(G=-t*z[0]),z[1]&&(I=r*q*z[1]));m=new Float32Array(4*F.length);n=new Float32Array(F.length);p=[Infinity,Infinity,-Infinity,-Infinity];F.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=m[4*b]=a.x+d[0]*B+G,f=m[4*b+1]=a.y+d[1]*B+I,g=m[4*b+2]=a.x+d[2]*B+G;a=m[4*b+3]=a.y+d[3]*B+I;e<p[0]&&(p[0]=e);f<p[1]&&(p[1]=f);g>p[2]&&(p[2]=g);a>p[3]&&(p[3]=a);n[b]=c})}b({glyphBounds:m,glyphIndices:n,totalBounds:p, | ||
totalBlockSize:[t,r*q],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]})},!0)},loadFont:c}}],init:function(u,g,b,a,c){g=a({sdfTextureSize:u.sdfGlyphSize,sdfDistancePercent:g});return c(b,g,{defaultFontUrl:u.defaultFontURL})}});var T=F.defineWorkerModule({dependencies:[G,F.ThenableWorkerModule],init:function(u,g){return function(b){var a=new g;u.process(b,a.resolve);return a}}, | ||
getTransferables:function(u){var g=[u.glyphBounds.buffer,u.glyphIndices.buffer];u.newGlyphSDFs&&u.newGlyphSDFs.forEach(function(b){g.push(b.textureData.buffer)});return g}}),U=(new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),V=new z.Vector3,N=function(u){function g(){u.call(this);this.copy(U);this.addAttribute("aTroikaGlyphBounds",new z.InstancedBufferAttribute(new Float32Array(0),4));this.addAttribute("aTroikaGlyphIndex",new z.InstancedBufferAttribute(new Float32Array(0),1));this.boundingSphere= | ||
new z.Sphere}u&&(g.__proto__=u);g.prototype=Object.create(u&&u.prototype);g.prototype.constructor=g;g.prototype.computeBoundingSphere=function(){};g.prototype.updateGlyphs=function(b,a,c){M(this.attributes.aTroikaGlyphBounds,b);M(this.attributes.aTroikaGlyphIndex,a);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(V.set(c[0],c[1],0))};return g}(z.InstancedBufferGeometry),O=new z.MeshBasicMaterial({color:16777215,side:z.DoubleSide, | ||
transparent:!0}),W=Object.freeze([0,0,0,0]),X=new z.Matrix4,P=new z.Mesh((new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),O),Q=function(u){function g(a){a=new N;u.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.debugSDF=!1}u&&(g.__proto__=u);g.prototype=Object.create(u&& | ||
u.prototype);g.prototype.constructor=g;var b={material:{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,S({text:this.text,font:this.font,fontSize:this.fontSize,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,maxWidth:this.maxWidth,textAlign:this.textAlign,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchor:this.anchor},function(c){b._isSyncing= | ||
!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphIndices,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(){var a=this._derivedMaterial;a&&a.dispose();this.geometry.dispose()};b.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||O;a&&a.baseMaterial===b||(a&& | ||
a.dispose(),a=R.createDerivedMaterial(b,{extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFMinDistancePct:{value:0},uTroikaGlyphVSize:{value:0},uTroikaTotalBounds:{value:new z.Vector4},uTroikaClipRect:{value:new z.Vector4},uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaTotalBounds;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n",vertexTransform:"\nvTroikaGlyphUV = vec2(\n position.x,\n uTroikaGlyphVSize * (aTroikaGlyphIndex + position.y)\n);\n\nposition = vec3(\n position.x == 1.0 ? aTroikaGlyphBounds.z : aTroikaGlyphBounds.x,\n position.y == 1.0 ? aTroikaGlyphBounds.w : aTroikaGlyphBounds.y,\n 0.0\n);\nvTroikaLocalPos = vec3(position);\n\nuv = vec2(\n (position.x - uTroikaTotalBounds.x) / (uTroikaTotalBounds.z - uTroikaTotalBounds.x),\n (position.y - uTroikaTotalBounds.y) / (uTroikaTotalBounds.w - uTroikaTotalBounds.y)\n);\n", | ||
fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform float uTroikaSDFMinDistancePct;\nuniform bool uTroikaSDFDebug;\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaClipRect;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n\nvoid troikaApplyClipping() {\n vec4 rect = uTroikaClipRect;\n vec3 pos = vTroikaLocalPos;\n if (rect != vec4(.0,.0,.0,.0) && (\n pos.x < min(rect.x, rect.z) || \n pos.y < min(rect.y, rect.w) ||\n pos.x > max(rect.x, rect.z) ||\n pos.y > max(rect.y, rect.w)\n )) {\n discard;\n }\n}\n", | ||
fragmentColorTransform:"\ntroikaApplyClipping();\n\nfloat troikaSDFValue = texture2D(uTroikaSDFTexture, vTroikaGlyphUV).r;\n\n\n#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n float troikaAntiAliasDist = min(\n 0.5,\n 0.5 * min(\n fwidth(vTroikaGlyphUV.x), \n fwidth(vTroikaGlyphUV.y / uTroikaGlyphVSize)\n )\n ) / uTroikaSDFMinDistancePct;\n#else\n float troikaAntiAliasDist = 0.01;\n#endif\n\nfloat textAlphaMult = uTroikaSDFDebug ? troikaSDFValue : smoothstep(\n 0.5 - troikaAntiAliasDist,\n 0.5 + troikaAntiAliasDist,\n troikaSDFValue\n);\nif (textAlphaMult == 0.0) {\n if (uTroikaSDFDebug) {\n gl_FragColor *= 0.5;\n } else {\n discard;\n }\n} else {\n gl_FragColor.a *= textAlphaMult;\n}\n"}), | ||
a.transparent=!0,a=this._derivedMaterial=a);return a};b.material.set=function(a){this._baseMaterial=a};g.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=this._textRenderInfo,d=a.uniforms;if(b){var e=b.sdfTexture;d.uTroikaSDFTexture.value=e;d.uTroikaSDFMinDistancePct.value=b.sdfMinDistancePercent;d.uTroikaGlyphVSize.value=e.image.width/e.image.height;d.uTroikaTotalBounds.value.fromArray(b.totalBounds)}d.uTroikaSDFDebug.value=!!this.debugSDF;(b=this.clipRect)&&Array.isArray(b)&& | ||
4===b.length||(b=W);d.uTroikaClipRect.value.fromArray(b);a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;d=this.color;null!=d&&a.color&&a.color.isColor&&d!==a._troikaColor&&a.color.set(a._troikaColor=d)};g.prototype.raycast=function(a,b){var c=this._textRenderInfo;c&&(c=c.totalBounds,P.matrixWorld.multiplyMatrices(this.matrixWorld,X.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)),P.raycast(a,b))};Object.defineProperties(g.prototype,b); | ||
return g}(z.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(u){var g="_private_"+u;Object.defineProperty(Q.prototype,u,{get:function(){return this[g]},set:"anchor"===u?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)}})});C.GlyphsGeometry=N;C.TextMesh=Q;C.configureTextBuilder=function(u){J(H,u)};C.fontProcessorWorkerModule= | ||
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,p=c.x1-h,n=c.y1-k,t=p*p+n*n;t=t?Math.max(0,Math.min(1,((e-h)*p+(f-k)*n)/t)):0;e=Math.sqrt(g(e-(h+t*p))+g(f-(k+t*n)));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,q=(g+2*k)/b;g=d.xMin-k-l;f=d.yMin-k-q;l=d.xMax+k+l;q=d.yMax+k+q;if(d.pathCommandCount){var u=new c(d),m,p,n,t;d.forEachPathCommand(function(a,b,c,d,e,f,g){switch(a){case "M":n=m=b;t=p=c;break;case "L":b===n&&c===t||u.addLineSegment(n,t,n=b,t=c);break;case "Q":f={x:n,y:t};for(g=1;16>g;g++){a=g/15;var h=1-a;a={x:h*h*n+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}n=d;t=e;break;case "C":a={x:n,y:t};for(h=1;16>h;h++){var k=h/15;var l=1-k;k={x:l*l*l*n+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}n=f;t=g;break;case "Z":n===m&&t===p||u.addLineSegment(n,t,m,p)}});for(d=0;d<b;d++)for(var r=0;r<b;r++){var v=u.findNearestSignedDistance(g+(l-g)*(d+.5)/b,f+(q-f)*(r+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[r*b+d]=v}}return{textureData:e,renderingBounds:[g, | ||
f,l,q]}}},function(r,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(){try{var a=r(e.response);b(a)}catch(n){d(n)}};e.onerror=d;e.send()}catch(p){d(p)}}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 q=a.lineHeight;void 0===q&&(q="normal");var r=a.maxWidth;void 0===r&&(r=Infinity);var v=a.textAlign;void 0===v&&(v="left");var y=a.whiteSpace;void 0===y&&(y="normal");var A=a.overflowWrap;void 0===A&&(A="normal");var z=a.anchor;void 0===c&&(c=!1); | ||
d(h,function(a){var d=a.fontObj,f=isFinite(r),h=null,m=null,n=null,p=null,t=0,u=0,w="nowrap"!==y,B=k/d.unitsPerEm;"normal"===q&&(q=(d.ascender-d.descender)/d.unitsPerEm);q*=k;var C=(q-(d.ascender-d.descender)*B)/2,D=e.split(/\r?\n/).map(function(a){var b=0,c=[],e=[c];d.forEachGlyph(a,k,l,function(a,d){var g=a.unicode;g="number"===typeof g&&String.fromCharCode(g);var h=a.advanceWidth*B,k=!!g&&/\s/.test(g);if(w&&f&&!k&&d+h+b>r&&c.length){if(c[c.length-1].isWhitespace){var l=[];b=-d}else for(var m=c.length;m--;)if(0=== | ||
m&&"break-word"===A){l=[];b=-d;break}else if(c[m].isWhitespace){l=c.splice(m+1);m=l[0].x;b-=m;for(var n=0;n<l.length;n++)l[n].x-=m;break}if(l){for(;c[c.length-1].isWhitespace;)c.pop();e.push(c=l);u=r}}c.push({glyphObj:a,x:d+b,y:0,width:h,char:g,isWhitespace:k,isEmpty:a.xMin===a.xMax||a.yMin===a.yMax,atlasInfo:null})});for(a=0;a<e.length&&u<r;a++){var g=e[a];g.length&&(g=g[g.length-1],u=Math.max(u,g.x+g.width))}t+=e.length;return e});if(!c){var F=[],H=-(k+C);D.forEach(function(b){for(var c=0;c<b.length;c++){var d= | ||
b[c];if(d.length){var e=0,f=d[d.length-1];f=f.x+f.width;var k=0;if("center"===v)e=(u-f)/2;else if("right"===v)e=u-f;else if("justify"===v)for(var l=0,m=d.length;l<m;l++)d[l].isWhitespace&&k++;l=0;for(m=d.length;l<m;l++){var n=d[l];n.isWhitespace&&"justify"===v&&c!==b.length-1&&(e+=(u-f)/k);if(!n.isWhitespace&&!n.isEmpty){var p=n.glyphObj,r=a.glyphs[p.index];r||(r=g(p),r.atlasIndex=a.glyphCount++,h||(h=[]),h.push(r),r=a.glyphs[p.index]={atlasIndex:r.atlasIndex,glyphObj:p,renderingBounds:r.renderingBounds}); | ||
n.atlasInfo=r;e&&(n.x+=e);n.y=H;F.push(n)}}}H-=q}});var G=0,I=0;z&&(z[0]&&(G=-u*z[0]),z[1]&&(I=t*q*z[1]));m=new Float32Array(4*F.length);n=new Float32Array(F.length);p=[Infinity,Infinity,-Infinity,-Infinity];F.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=m[4*b]=a.x+d[0]*B+G,f=m[4*b+1]=a.y+d[1]*B+I,g=m[4*b+2]=a.x+d[2]*B+G;a=m[4*b+3]=a.y+d[3]*B+I;e<p[0]&&(p[0]=e);f<p[1]&&(p[1]=f);g>p[2]&&(p[2]=g);a>p[3]&&(p[3]=a);n[b]=c})}b({glyphBounds:m,glyphIndices:n,totalBounds:p, | ||
totalBlockSize:[u,t*q],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]})},!0)},loadFont:c}}],init:function(r,g,b,a,c){g=a({sdfTextureSize:r.sdfGlyphSize,sdfDistancePercent:g});return c(b,g,{defaultFontUrl:r.defaultFontURL})}});var T=F.defineWorkerModule({dependencies:[G,F.ThenableWorkerModule],init:function(r,g){return function(b){var a=new g;r.process(b,a.resolve);return a}}, | ||
getTransferables:function(r){var g=[r.glyphBounds.buffer,r.glyphIndices.buffer];r.newGlyphSDFs&&r.newGlyphSDFs.forEach(function(b){g.push(b.textureData.buffer)});return g}}),V=(new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),W=new z.Vector3,N=function(r){function g(){r.call(this);this.copy(V);this.addAttribute("aTroikaGlyphBounds",new z.InstancedBufferAttribute(new Float32Array(0),4));this.addAttribute("aTroikaGlyphIndex",new z.InstancedBufferAttribute(new Float32Array(0),1));this.boundingSphere= | ||
new z.Sphere}r&&(g.__proto__=r);g.prototype=Object.create(r&&r.prototype);g.prototype.constructor=g;g.prototype.computeBoundingSphere=function(){};g.prototype.updateGlyphs=function(b,a,c){M(this.attributes.aTroikaGlyphBounds,b);M(this.attributes.aTroikaGlyphIndex,a);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(W.set(c[0],c[1],0))};return g}(z.InstancedBufferGeometry),O=new z.MeshBasicMaterial({color:16777215,side:z.DoubleSide, | ||
transparent:!0}),X=Object.freeze([0,0,0,0]),Y=new z.Matrix4,P=new z.Mesh((new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),O),Q=function(r){function g(a){a=new N;r.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.debugSDF=!1}r&&(g.__proto__=r);g.prototype=Object.create(r&& | ||
r.prototype);g.prototype.constructor=g;var b={material:{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,S({text:this.text,font:this.font,fontSize:this.fontSize,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,maxWidth:this.maxWidth,textAlign:this.textAlign,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchor:this.anchor},function(c){b._isSyncing= | ||
!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphIndices,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.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||O;a&&a.baseMaterial===b||(a&&a.dispose(),a=this._derivedMaterial=U(b),b.addEventListener("dispose", | ||
function e(){b.removeEventListener("dispose",e);a.dispose()}));return a};b.material.set=function(a){this._baseMaterial=a};g.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=this._textRenderInfo,d=a.uniforms;if(b){var e=b.sdfTexture;d.uTroikaSDFTexture.value=e;d.uTroikaSDFMinDistancePct.value=b.sdfMinDistancePercent;d.uTroikaGlyphVSize.value=e.image.width/e.image.height;d.uTroikaTotalBounds.value.fromArray(b.totalBounds)}d.uTroikaSDFDebug.value=!!this.debugSDF;(b=this.clipRect)&& | ||
Array.isArray(b)&&4===b.length||(b=X);d.uTroikaClipRect.value.fromArray(b);a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;d=this.color;null!=d&&a.color&&a.color.isColor&&d!==a._troikaColor&&a.color.set(a._troikaColor=d)};g.prototype.raycast=function(a,b){var c=this._textRenderInfo;c&&(c=c.totalBounds,P.matrixWorld.multiplyMatrices(this.matrixWorld,Y.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)),P.raycast(a,b))};Object.defineProperties(g.prototype, | ||
b);return g}(z.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(r){var g="_private_"+r;Object.defineProperty(Q.prototype,r,{get:function(){return this[g]},set:"anchor"===r?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)}})});C.GlyphsGeometry=N;C.TextMesh=Q;C.configureTextBuilder=function(r){J(H,r)};C.fontProcessorWorkerModule= | ||
G;Object.defineProperty(C,"__esModule",{value:!0})}); |
@@ -1,50 +0,53 @@ | ||
'use strict';(function(C,z){"object"===typeof exports&&"undefined"!==typeof module?z(exports,require("three"),require("troika-worker-utils"),require("troika-three-utils"),require("troika-3d")):"function"===typeof define&&define.amd?define(["exports","three","troika-worker-utils","troika-three-utils","troika-3d"],z):(C=C||self,z(C.troika_3d_text={},C.THREE,C.troika_worker_utils,C.troika_three_utils,C.troika_3d))})(this,function(C,z,F,R,S){function T(l,f){l=K({},l);L.href=l.font||I.defaultFontURL;l.font= | ||
L.href;l.text=""+l.text;var b=I.sdfGlyphSize,a=M[l.font];a||(a=M[l.font]={sdfTexture:new z.DataTexture(new Uint8Array(b*b*64),b,64*b,z.LuminanceFormat,void 0,void 0,void 0,void 0,z.LinearFilter,z.LinearFilter)},a.sdfTexture.font=l.font);U(l).then(function(c){c.newGlyphSDFs&&(c.newGlyphSDFs.forEach(function(c){var d=c.textureData,g=a.sdfTexture.image;for(c=c.atlasIndex*b*b;c>g.data.length-1;){var f=new Uint8Array(2*g.data.length);f.set(g.data);g.data=f;g.height*=2}g.data.set(d,c)}),a.sdfTexture.needsUpdate= | ||
!0);f({sdfTexture:a.sdfTexture,sdfMinDistancePercent:.125,glyphBounds:c.glyphBounds,glyphIndices:c.glyphIndices,totalBounds:c.totalBounds,totalBlockSize:c.totalBlockSize})})}function K(l,f){for(var b in f)f.hasOwnProperty(b)&&(l[b]=f[b]);return l}function N(l,f){l.array.length===f.length?l.array.set(f):l.setArray(f);l.needsUpdate=!0}var H=F.defineWorkerModule({dependencies:[function(){var l=self,f={parse:function(b){var a=f._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=[],g=0;g<d;g++){var h=a.readUint(b,c);c+=4;e.push(f._readFont(b,h))}return e}return[f._readFont(b,0)]},_readFont:function(b,a){var c=f._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 g="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 m=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[m]={offset:q,length:u}}for(k=0;k<g.length;k++)a=g[k],h[a]&&(d[a.trim()]=f[a.trim()].parse(b,h[a].offset,h[a].length,d));return d},_tabOffset:function(b,a,c){var d=f._bin,e=d.readUshort(b,c+4);c+=12;for(var g=0;g<e;g++){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}};f._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 f._bin.readShort(b,a)/16384},readInt:function(b,a){var c=f._bin.t.uint8;c[0]=b[a+3];c[1]=b[a+2];c[2]=b[a+1];c[3]=b[a];return f._bin.t.int32[0]},readInt8:function(b,a){f._bin.t.uint8[0]=b[a];return f._bin.t.int8[0]},readShort:function(b,a){var c=f._bin.t.uint8;c[1]=b[a];c[0]=b[a+1];return f._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(f._bin.readUshort(b,a+2*e));return d},readUint:function(b, | ||
a){var c=f._bin.t.uint8;c[3]=b[a];c[2]=b[a+1];c[1]=b[a+2];c[0]=b[a+3];return f._bin.t.uint32[0]},readUint64:function(b,a){return 4294967296*f._bin.readUint(b,a)+f._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 g=b[a++]<<8|b[a++];d+=String.fromCharCode(g)}return d},_tdec:l.TextDecoder?new l.TextDecoder:null,readUTF8:function(b,a,c){var d=f._bin._tdec;return d&&0==a&&c==b.length? | ||
d.decode(b):f._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}};f._bin.t={buff:new ArrayBuffer(8)};f._bin.t.int8=new Int8Array(f._bin.t.buff);f._bin.t.uint8=new Uint8Array(f._bin.t.buff);f._bin.t.int16=new Int16Array(f._bin.t.buff);f._bin.t.uint16=new Uint16Array(f._bin.t.buff);f._bin.t.int32=new Int32Array(f._bin.t.buff);f._bin.t.uint32=new Uint32Array(f._bin.t.buff); | ||
f._lctf={};f._lctf.parse=function(b,a,c,d,e){var g=f._bin;c={};d=a;g.readFixed(b,a);a+=4;var h=g.readUshort(b,a);a+=2;var k=g.readUshort(b,a);a=g.readUshort(b,a+2);c.scriptList=f._lctf.readScriptList(b,d+h);c.featureList=f._lctf.readFeatureList(b,d+k);c.lookupList=f._lctf.readLookupList(b,d+a,e);return c};f._lctf.readLookupList=function(b,a,c){var d=f._bin,e=a,g=[],h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var m=d.readUshort(b,a);a+=2;m=f._lctf.readLookupTable(b,e+m,c);g.push(m)}return g};f._lctf.readLookupTable= | ||
function(b,a,c){var d=f._bin,e=a,g={tabs:[]};g.ltype=d.readUshort(b,a);a+=2;g.flag=d.readUshort(b,a);a+=2;var h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var m=d.readUshort(b,a);a+=2;m=c(b,g.ltype,e+m);g.tabs.push(m)}return g};f._lctf.numOfOnes=function(b){for(var a=0,c=0;32>c;c++)0!=(b>>>c&1)&&a++;return a};f._lctf.readClassDef=function(b,a){var c=f._bin,d=[],e=c.readUshort(b,a);a+=2;if(1==e){var g=c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++)d.push(g+k),d.push(g+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};f._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};f._lctf.readCoverage=function(b,a){var c=f._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};f._lctf.coverageIndex= | ||
function(b,a){var c=b.tab;return 1==b.fmt?c.indexOf(a):2==b.fmt&&(b=f._lctf.getInterval(c,a),-1!=b)?c[b+2]+(a-c[b]):-1};f._lctf.readFeatureList=function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+=4;var m=c.readUshort(b,a);a+=2;e.push({tag:k.trim(),tab:f._lctf.readFeatureTable(b,d+m)})}return e};f._lctf.readFeatureTable=function(b,a){var c=f._bin;c.readUshort(b,a);a+=2;var d=c.readUshort(b,a);a+=2;for(var e=[],g=0;g<d;g++)e.push(c.readUshort(b, | ||
a+2*g));return e};f._lctf.readScriptList=function(b,a){var c=f._bin,d=a,e={},g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+=4;var m=c.readUshort(b,a);a+=2;e[k.trim()]=f._lctf.readScriptTable(b,d+m)}return e};f._lctf.readScriptTable=function(b,a){var c=f._bin,d=a,e={},g=c.readUshort(b,a);a+=2;e.default=f._lctf.readLangSysTable(b,d+g);g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+=4;var m=c.readUshort(b,a);a+=2;e[k.trim()]=f._lctf.readLangSysTable(b, | ||
d+m)}return e};f._lctf.readLangSysTable=function(b,a){var c=f._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};f.CFF={};f.CFF.parse=function(b,a,c){var d=f._bin;b=new Uint8Array(b.buffer,a,c);a=0;a++;a++;a++;a++;var e=[];a=f.CFF.readIndex(b,a,e);var g=[];for(c=0;c<e.length-1;c++)g.push(d.readASCII(b,a+e[c],e[c+1]-e[c]));a+=e[e.length-1];e=[];a=f.CFF.readIndex(b,a,e);g=[];for(c=0;c<e.length-1;c++)g.push(f.CFF.readDict(b, | ||
a+e[c],a+e[c+1]));a+=e[e.length-1];e=g[0];var h=[];a=f.CFF.readIndex(b,a,h);g=[];for(c=0;c<h.length-1;c++)g.push(d.readASCII(b,a+h[c],h[c+1]-h[c]));a+=h[h.length-1];f.CFF.readSubrs(b,a,e);if(e.CharStrings){a=e.CharStrings;h=[];a=f.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=f.CFF.readIndex(b,a,h);e.FDArray=[];for(c=0;c<h.length-1;c++)k=f.CFF.readDict(b,a+h[c],a+h[c+1]),f.CFF._readFDict(b,k,g),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=f.CFF.readEncoding(b,e.Encoding,e.CharStrings.length));e.charset&&(e.charset=f.CFF.readCharset(b,e.charset,e.CharStrings.length));f.CFF._readFDict(b,e,g);return e};f.CFF._readFDict=function(b,a,c){if(a.Private){var d=a.Private[1];a.Private=f.CFF.readDict(b,d,d+a.Private[0]);a.Private.Subrs&&f.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])};f.CFF.readSubrs=function(b,a,c){var d=f._bin,e=[];a=f.CFF.readIndex(b,a,e);var g=e.length;c.Bias=1240>g?107:33900>g?1131:32768;c.Subrs=[];for(g=0;g<e.length-1;g++)c.Subrs.push(d.readBytes(b,a+e[g],e[g+1]-e[g]))};f.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];f.CFF.glyphByUnicode=function(b,a){for(var c=0;c<b.charset.length;c++)if(b.charset[c]==a)return c;return-1};f.CFF.glyphBySE=function(b,a){return 0>a||255<a?-1:f.CFF.glyphByUnicode(b,f.CFF.tableSE[a])};f.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};f.CFF.readCharset=function(b,a,c){var d=f._bin,e=[".notdef"],g=b[a]; | ||
a++;if(0==g)for(var h=0;h<c;h++){var k=d.readUshort(b,a);a+=2;e.push(k)}else if(1==g||2==g)for(;e.length<c;){k=d.readUshort(b,a);a+=2;if(1==g){var m=b[a];a++}else m=d.readUshort(b,a),a+=2;for(h=0;h<=m;h++)e.push(k),k++}else throw"error: format: "+g;return e};f.CFF.readIndex=function(b,a,c){var d=f._bin,e=d.readUshort(b,a)+1;a+=2;var g=b[a];a++;if(1==g)for(var h=0;h<e;h++)c.push(b[a+h]);else if(2==g)for(h=0;h<e;h++)c.push(d.readUshort(b,a+2*h));else if(3==g)for(h=0;h<e;h++)c.push(d.readUint(b,a+3* | ||
h-1)&16777215);else if(1!=e)throw"unsupported offset size: "+g+", count: "+e;return a+e*g-1};f.CFF.getCharString=function(b,a,c){var d=f._bin,e=b[a],g=b[a+1],h=1,k=null,m=null;20>=e&&(k=e,h=1);12==e&&(k=100*e+g,h=2);21<=e&&27>=e&&(k=e,h=1);28==e&&(m=d.readShort(b,a+1),h=3);29<=e&&31>=e&&(k=e,h=1);32<=e&&246>=e&&(m=e-139,h=1);247<=e&&250>=e&&(m=256*(e-247)+g+108,h=2);251<=e&&254>=e&&(m=256*-(e-251)-g-108,h=2);255==e&&(m=d.readInt(b,a+1)/65535,h=5);c.val=null!=m?m:"o"+k;c.size=h};f.CFF.readCharString= | ||
function(b,a,c){c=a+c;for(var d=f._bin,e=[];a<c;){var g=b[a],h=b[a+1],k=1,m=null,q=null;20>=g&&(m=g,k=1);12==g&&(m=100*g+h,k=2);if(19==g||20==g)m=g,k=2;21<=g&&27>=g&&(m=g,k=1);28==g&&(q=d.readShort(b,a+1),k=3);29<=g&&31>=g&&(m=g,k=1);32<=g&&246>=g&&(q=g-139,k=1);247<=g&&250>=g&&(q=256*(g-247)+h+108,k=2);251<=g&&254>=g&&(q=256*-(g-251)-h-108,k=2);255==g&&(q=d.readInt(b,a+1)/65535,k=5);e.push(null!=q?q:"o"+m);a+=k}return e};f.CFF.readDict=function(b,a,c){for(var d=f._bin,e={},g=[];a<c;){var h=b[a], | ||
k=b[a+1],m=1,q=null,u=null;28==h&&(u=d.readShort(b,a+1),m=3);29==h&&(u=d.readInt(b,a+1),m=5);32<=h&&246>=h&&(u=h-139,m=1);247<=h&&250>=h&&(u=256*(h-247)+k+108,m=2);251<=h&&254>=h&&(u=256*-(h-251)-k-108,m=2);if(255==h)throw d.readInt(b,a+1),"unknown number";if(30==h){u=[];for(m=1;;){var n=b[a+m];m++;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&&(m= | ||
"version Notice FullName FamilyName Weight FontBBox BlueValues OtherBlues FamilyBlues FamilyOtherBlues StdHW StdVW escape UniqueID XUID charset Encoding CharStrings Private Subrs defaultWidthX nominalWidthX".split(" "),q=m[h],m=1,12==h&&(m=["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=m[k],m=2));null!=q?(e[q]=1==g.length?g[0]:g,g=[]):g.push(u);a+=m}return e};f.cmap={};f.cmap.parse=function(b,a,c){b=new Uint8Array(b.buffer,a,c);a=0;c=f._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;var g=[];d.tables=[];for(var h=0;h<e;h++){var k=c.readUshort(b,a);a+=2;var m=c.readUshort(b,a);a+=2; | ||
var q=c.readUint(b,a);a+=4;var u="p"+k+"e"+m,n=g.indexOf(q);if(-1==n){n=d.tables.length;var r;g.push(q);var p=c.readUshort(b,q);0==p?r=f.cmap.parse0(b,q):4==p?r=f.cmap.parse4(b,q):6==p?r=f.cmap.parse6(b,q):12==p?r=f.cmap.parse12(b,q):console.log("unknown format: "+p,k,m,q);d.tables.push(r)}if(null!=d[u])throw"multiple tables for one platform+encoding";d[u]=n}return d};f.cmap.parse0=function(b,a){var c=f._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};f.cmap.parse4=function(b,a){var c=f._bin,d=a,e={};e.format=c.readUshort(b,a);a+=2;var g=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+g;)e.glyphIdArray.push(c.readUshort(b,a)),a+=2;return e};f.cmap.parse6=function(b,a){var c=f._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 g=0;g<e;g++)d.glyphIdArray.push(c.readUshort(b,a)),a+=2;return d};f.cmap.parse12=function(b,a){var c=f._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 g=0;g<e;g++){var h=a+12*g,k=c.readUint(b,h+0),m=c.readUint(b,h+4);h=c.readUint(b,h+8);d.groups.push([k,m,h])}return d};f.glyf={};f.glyf.parse=function(b,a,c,d){b=[];for(a=0;a<d.maxp.numGlyphs;a++)b.push(null);return b};f.glyf._parseGlyf=function(b,a){var c=f._bin,d=b._data,e=f._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 g=b.endPts[b.noc-1]+1;b.flags=[];for(a=0;a<g;a++){var h=d[e];e++;b.flags.push(h);if(0!=(h&8)){var k=d[e];e++;for(var m=0;m<k;m++)b.flags.push(h),a++}}b.xs=[];for(a=0;a<g;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<g;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<g;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,g={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1},b.parts.push(g),g.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?(g.m.tx=h,g.m.ty=k):(g.p1=h,g.p2=k),a&8?(g.m.a=g.m.d=c.readF2dot14(d,e),e+=2):a&64?(g.m.a=c.readF2dot14(d,e),e+=2,g.m.d=c.readF2dot14(d,e),e+=2):a&128&&(g.m.a=c.readF2dot14(d,e),e+=2,g.m.b=c.readF2dot14(d,e),e+=2,g.m.c=c.readF2dot14(d,e),e+=2,g.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};f.GPOS={};f.GPOS.parse=function(b,a,c,d){return f._lctf.parse(b,a,c,d,f.GPOS.subt)};f.GPOS.subt= | ||
function(b,a,c){var d=f._bin,e=c,g={};g.fmt=d.readUshort(b,c);c+=2;if(1==a||2==a||3==a||7==a||8==a&&2>=g.fmt){var h=d.readUshort(b,c);c+=2;g.coverage=f._lctf.readCoverage(b,h+e)}if(1==a&&1==g.fmt){var k=d.readUshort(b,c);c+=2;f._lctf.numOfOnes(k);0!=k&&(g.pos=f.GPOS.readValueRecord(b,c,k))}else if(2==a){k=d.readUshort(b,c);c+=2;var m=d.readUshort(b,c);c+=2;a=f._lctf.numOfOnes(k);h=f._lctf.numOfOnes(m);if(1==g.fmt){g.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 y=d.readUshort(b,n);n+=2;if(0!=k){var l=f.GPOS.readValueRecord(b,n,k);n+=2*a}if(0!=m){var x=f.GPOS.readValueRecord(b,n,m);n+=2*h}p.push({gid2:y,val1:l,val2:x})}g.pairsets.push(p)}}if(2==g.fmt)for(l=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,g.classDef1=f._lctf.readClassDef(b,e+l),g.classDef2=f._lctf.readClassDef(b,e+x),g.matrix=[],u=0;u<k;u++){e=[];for(t=0;t<d;t++)x=l=null,0!= | ||
g.valFmt1&&(l=f.GPOS.readValueRecord(b,c,g.valFmt1),c+=2*a),0!=g.valFmt2&&(x=f.GPOS.readValueRecord(b,c,g.valFmt2),c+=2*h),e.push({val1:l,val2:x});g.matrix.push(e)}}return g};f.GPOS.readValueRecord=function(b,a,c){var d=f._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};f.GSUB={};f.GSUB.parse=function(b,a,c,d){return f._lctf.parse(b,a,c,d,f.GSUB.subt)};f.GSUB.subt=function(b, | ||
a,c){var d=f._bin,e=c,g={};g.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>=g.fmt||6==a&&2>=g.fmt){var h=d.readUshort(b,c);c+=2;g.coverage=f._lctf.readCoverage(b,e+h)}if(1==a)1==g.fmt?g.delta=d.readShort(b,c):2==g.fmt&&(h=d.readUshort(b,c),g.newg=d.readUshorts(b,c+2,h));else if(4==a)for(g.vals=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++){var k=d.readUshort(b,c);c+=2;g.vals.push(f.GSUB.readLigatureSet(b,e+k))}else if(5==a){if(2==g.fmt)for(a=d.readUshort(b,c),c+= | ||
2,g.cDef=f._lctf.readClassDef(b,e+a),g.scset=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++)k=d.readUshort(b,c),c+=2,g.scset.push(0==k?null:f.GSUB.readSubClassSet(b,e+k))}else if(6==a&&3==g.fmt){for(a=0;3>a;a++){h=d.readUshort(b,c);c+=2;k=[];for(var m=0;m<h;m++)k.push(f._lctf.readCoverage(b,e+d.readUshort(b,c+2*m)));c+=2*h;0==a&&(g.backCvg=k);1==a&&(g.inptCvg=k);2==a&&(g.ahedCvg=k)}h=d.readUshort(b,c);g.lookupRec=f.GSUB.readSubstLookupRecords(b,c+2,h)}return g};f.GSUB.readSubClassSet=function(b,a){var c= | ||
f._bin.readUshort,d=a,e=[],g=c(b,a);a+=2;for(var h=0;h<g;h++){var k=c(b,a);a+=2;e.push(f.GSUB.readSubClassRule(b,d+k))}return e};f.GSUB.readSubClassRule=function(b,a){var c=f._bin.readUshort,d={},e=c(b,a);a+=2;var g=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=f.GSUB.readSubstLookupRecords(b,a,g);return d};f.GSUB.readSubstLookupRecords=function(b,a,c){for(var d=f._bin.readUshort,e=[],g=0;g<c;g++)e.push(d(b,a),d(b,a+2)),a+=4;return e};f.GSUB.readChainSubClassSet= | ||
function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readUshort(b,a);a+=2;e.push(f.GSUB.readChainSubClassRule(b,d+k))}return e};f.GSUB.readChainSubClassRule=function(b,a){for(var c=f._bin,d={},e=["backtrack","input","lookahead"],g=0;g<e.length;g++){var h=c.readUshort(b,a);a+=2;1==g&&h--;d[e[g]]=c.readUshorts(b,a,h);a+=2*d[e[g]].length}h=c.readUshort(b,a);d.subst=c.readUshorts(b,a+2,2*h);return d};f.GSUB.readLigatureSet=function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b, | ||
a);a+=2;for(var h=0;h<g;h++){var k=c.readUshort(b,a);a+=2;e.push(f.GSUB.readLigature(b,d+k))}return e};f.GSUB.readLigature=function(b,a){var c=f._bin,d={chain:[]};d.nglyph=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;for(var g=0;g<e-1;g++)d.chain.push(c.readUshort(b,a)),a+=2;return d};f.head={};f.head.parse=function(b,a,c){c=f._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};f.hhea={};f.hhea.parse=function(b,a,c){c=f._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};f.hmtx={};f.hmtx.parse=function(b,a,c,d){c=f._bin;for(var e={aWidth:[], | ||
lsBearing:[]},g=0,h=0,k=0;k<d.maxp.numGlyphs;k++)k<d.hhea.numberOfHMetrics&&(g=c.readUshort(b,a),a+=2,h=c.readShort(b,a),a+=2),e.aWidth.push(g),e.lsBearing.push(h);return e};f.kern={};f.kern.parse=function(b,a,c,d){var e=f._bin,g=e.readUshort(b,a);a+=2;if(1==g)return f.kern.parseV1(b,a-2,c,d);c=e.readUshort(b,a);a+=2;d={glyph1:[],rval:[]};for(g=0;g<c;g++){a+=2;e.readUshort(b,a);a+=2;var h=e.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=f.kern.readFormat0(b,a,d);else throw"unknown kern table format: "+ | ||
h;}return d};f.kern.parseV1=function(b,a,c,d){c=f._bin;c.readFixed(b,a);a+=4;d=c.readUint(b,a);a+=4;for(var e={glyph1:[],rval:[]},g=0;g<d;g++){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=f.kern.readFormat0(b,a,e);else throw"unknown kern table format: "+h;}return e};f.kern.readFormat0=function(b,a,c){var d=f._bin,e=-1,g=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<g;h++){var k=d.readUshort(b, | ||
a);a+=2;var m=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(m);e.vals.push(q);e=k}return a};f.loca={};f.loca.parse=function(b,a,c,d){c=f._bin;var e=[],g=d.head.indexToLocFormat;d=d.maxp.numGlyphs+1;if(0==g)for(var h=0;h<d;h++)e.push(c.readUshort(b,a+(h<<1))<<1);if(1==g)for(h=0;h<d;h++)e.push(c.readUint(b,a+(h<<2)));return e};f.maxp={};f.maxp.parse=function(b,a,c){c=f._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};f.name={};f.name.parse=function(b,a,c){c=f._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 g="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 m=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=g[n];p=h+12*e+p;if(0==m)r=c.readUnicode(b,p,r/2);else if(3==m&&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==m)r=c.readASCII(b,p,r),console.log("reading unknown MAC encoding "+q+" as ASCII");else throw"unknown encoding "+ | ||
q+", platformID: "+m;m="p"+m+","+u.toString(16);null==d[m]&&(d[m]={});d[m][n]=r;d[m]._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 y=t;break}console.log("returning name table with languageID "+d[y]._lang);return d[y]};f["OS/2"]={};f["OS/2"].parse=function(b,a, | ||
'use strict';(function(C,y){"object"===typeof exports&&"undefined"!==typeof module?y(exports,require("three"),require("troika-worker-utils"),require("troika-three-utils"),require("troika-3d")):"function"===typeof define&&define.amd?define(["exports","three","troika-worker-utils","troika-three-utils","troika-3d"],y):(C=C||self,y(C.troika_3d_text={},C.THREE,C.troika_worker_utils,C.troika_three_utils,C.troika_3d))})(this,function(C,y,F,R,S){function T(l,f){l=K({},l);L.href=l.font||I.defaultFontURL;l.font= | ||
L.href;l.text=""+l.text;var b=I.sdfGlyphSize,a=M[l.font];a||(a=M[l.font]={sdfTexture:new y.DataTexture(new Uint8Array(b*b*64),b,64*b,y.LuminanceFormat,void 0,void 0,void 0,void 0,y.LinearFilter,y.LinearFilter)},a.sdfTexture.font=l.font);U(l).then(function(c){c.newGlyphSDFs&&(c.newGlyphSDFs.forEach(function(c){var d=c.textureData,g=a.sdfTexture.image;for(c=c.atlasIndex*b*b;c>g.data.length-1;){var f=new Uint8Array(2*g.data.length);f.set(g.data);g.data=f;g.height*=2}g.data.set(d,c)}),a.sdfTexture.needsUpdate= | ||
!0);f({sdfTexture:a.sdfTexture,sdfMinDistancePercent:.125,glyphBounds:c.glyphBounds,glyphIndices:c.glyphIndices,totalBounds:c.totalBounds,totalBlockSize:c.totalBlockSize})})}function K(l,f){for(var b in f)f.hasOwnProperty(b)&&(l[b]=f[b]);return l}function N(l,f){l.array.length===f.length?l.array.set(f):l.setArray(f);l.needsUpdate=!0}function V(l){l=R.createDerivedMaterial(l,{extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFMinDistancePct:{value:0},uTroikaGlyphVSize:{value:0}, | ||
uTroikaTotalBounds:{value:new y.Vector4},uTroikaClipRect:{value:new y.Vector4},uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaTotalBounds;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n",vertexTransform:"\nvTroikaGlyphUV = vec2(\n position.x,\n uTroikaGlyphVSize * (aTroikaGlyphIndex + position.y)\n);\n\nposition = vec3(\n mix(aTroikaGlyphBounds.x, aTroikaGlyphBounds.z, position.x),\n mix(aTroikaGlyphBounds.y, aTroikaGlyphBounds.w, position.y),\n position.z\n);\nvTroikaLocalPos = vec3(position);\n\nuv = vec2(\n (position.x - uTroikaTotalBounds.x) / (uTroikaTotalBounds.z - uTroikaTotalBounds.x),\n (position.y - uTroikaTotalBounds.y) / (uTroikaTotalBounds.w - uTroikaTotalBounds.y)\n);\n", | ||
fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform float uTroikaSDFMinDistancePct;\nuniform bool uTroikaSDFDebug;\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaClipRect;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n\nvoid troikaApplyClipping() {\n vec4 rect = uTroikaClipRect;\n vec3 pos = vTroikaLocalPos;\n if (rect != vec4(.0,.0,.0,.0) && (\n pos.x < min(rect.x, rect.z) || \n pos.y < min(rect.y, rect.w) ||\n pos.x > max(rect.x, rect.z) ||\n pos.y > max(rect.y, rect.w)\n )) {\n discard;\n }\n}\n", | ||
fragmentColorTransform:"\ntroikaApplyClipping();\n\nfloat troikaSDFValue = texture2D(uTroikaSDFTexture, vTroikaGlyphUV).r;\n\n\n#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n float troikaAntiAliasDist = min(\n 0.5,\n 0.5 * min(\n fwidth(vTroikaGlyphUV.x), \n fwidth(vTroikaGlyphUV.y / uTroikaGlyphVSize)\n )\n ) / uTroikaSDFMinDistancePct;\n#else\n float troikaAntiAliasDist = 0.01;\n#endif\n\nfloat textAlphaMult = uTroikaSDFDebug ? troikaSDFValue : smoothstep(\n 0.5 - troikaAntiAliasDist,\n 0.5 + troikaAntiAliasDist,\n troikaSDFValue\n);\nif (textAlphaMult == 0.0) {\n if (uTroikaSDFDebug) {\n gl_FragColor *= 0.5;\n } else {\n discard;\n }\n} else {\n gl_FragColor.a *= textAlphaMult;\n}\n"}); | ||
l.transparent=!0;return l}var H=F.defineWorkerModule({dependencies:[function(){var l=self,f={parse:function(b){var a=f._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=[],g=0;g<d;g++){var h=a.readUint(b,c);c+=4;e.push(f._readFont(b,h))}return e}return[f._readFont(b,0)]},_readFont:function(b,a){var c=f._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 g="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 n=c.readASCII(b,a,4);a+=4;c.readUint(b,a);a+=4;var t=c.readUint(b,a);a+=4;var u=c.readUint(b,a);a+=4;h[n]={offset:t,length:u}}for(k=0;k<g.length;k++)a=g[k],h[a]&&(d[a.trim()]=f[a.trim()].parse(b,h[a].offset,h[a].length,d));return d},_tabOffset:function(b,a,c){var d=f._bin,e=d.readUshort(b,c+4);c+=12;for(var g=0;g<e;g++){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}};f._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 f._bin.readShort(b,a)/16384},readInt:function(b,a){var c=f._bin.t.uint8;c[0]=b[a+3];c[1]=b[a+2];c[2]=b[a+1];c[3]=b[a];return f._bin.t.int32[0]},readInt8:function(b,a){f._bin.t.uint8[0]=b[a];return f._bin.t.int8[0]},readShort:function(b,a){var c=f._bin.t.uint8;c[1]=b[a]; | ||
c[0]=b[a+1];return f._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(f._bin.readUshort(b,a+2*e));return d},readUint:function(b,a){var c=f._bin.t.uint8;c[3]=b[a];c[2]=b[a+1];c[1]=b[a+2];c[0]=b[a+3];return f._bin.t.uint32[0]},readUint64:function(b,a){return 4294967296*f._bin.readUint(b,a)+f._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 g=b[a++]<<8|b[a++];d+=String.fromCharCode(g)}return d},_tdec:l.TextDecoder?new l.TextDecoder:null,readUTF8:function(b,a,c){var d=f._bin._tdec;return d&&0==a&&c==b.length?d.decode(b):f._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}};f._bin.t={buff:new ArrayBuffer(8)};f._bin.t.int8=new Int8Array(f._bin.t.buff);f._bin.t.uint8= | ||
new Uint8Array(f._bin.t.buff);f._bin.t.int16=new Int16Array(f._bin.t.buff);f._bin.t.uint16=new Uint16Array(f._bin.t.buff);f._bin.t.int32=new Int32Array(f._bin.t.buff);f._bin.t.uint32=new Uint32Array(f._bin.t.buff);f._lctf={};f._lctf.parse=function(b,a,c,d,e){var g=f._bin;c={};d=a;g.readFixed(b,a);a+=4;var h=g.readUshort(b,a);a+=2;var k=g.readUshort(b,a);a=g.readUshort(b,a+2);c.scriptList=f._lctf.readScriptList(b,d+h);c.featureList=f._lctf.readFeatureList(b,d+k);c.lookupList=f._lctf.readLookupList(b, | ||
d+a,e);return c};f._lctf.readLookupList=function(b,a,c){var d=f._bin,e=a,g=[],h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var n=d.readUshort(b,a);a+=2;n=f._lctf.readLookupTable(b,e+n,c);g.push(n)}return g};f._lctf.readLookupTable=function(b,a,c){var d=f._bin,e=a,g={tabs:[]};g.ltype=d.readUshort(b,a);a+=2;g.flag=d.readUshort(b,a);a+=2;var h=d.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var n=d.readUshort(b,a);a+=2;n=c(b,g.ltype,e+n);g.tabs.push(n)}return g};f._lctf.numOfOnes=function(b){for(var a= | ||
0,c=0;32>c;c++)0!=(b>>>c&1)&&a++;return a};f._lctf.readClassDef=function(b,a){var c=f._bin,d=[],e=c.readUshort(b,a);a+=2;if(1==e){var g=c.readUshort(b,a);a+=2;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++)d.push(g+k),d.push(g+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};f._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};f._lctf.readCoverage=function(b,a){var c=f._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};f._lctf.coverageIndex=function(b,a){var c=b.tab;return 1==b.fmt?c.indexOf(a):2==b.fmt&&(b=f._lctf.getInterval(c,a),-1!=b)?c[b+2]+(a-c[b]):-1};f._lctf.readFeatureList=function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+= | ||
4;var n=c.readUshort(b,a);a+=2;e.push({tag:k.trim(),tab:f._lctf.readFeatureTable(b,d+n)})}return e};f._lctf.readFeatureTable=function(b,a){var c=f._bin;c.readUshort(b,a);a+=2;var d=c.readUshort(b,a);a+=2;for(var e=[],g=0;g<d;g++)e.push(c.readUshort(b,a+2*g));return e};f._lctf.readScriptList=function(b,a){var c=f._bin,d=a,e={},g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+=4;var n=c.readUshort(b,a);a+=2;e[k.trim()]=f._lctf.readScriptTable(b,d+n)}return e};f._lctf.readScriptTable= | ||
function(b,a){var c=f._bin,d=a,e={},g=c.readUshort(b,a);a+=2;e.default=f._lctf.readLangSysTable(b,d+g);g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readASCII(b,a,4);a+=4;var n=c.readUshort(b,a);a+=2;e[k.trim()]=f._lctf.readLangSysTable(b,d+n)}return e};f._lctf.readLangSysTable=function(b,a){var c=f._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};f.CFF={};f.CFF.parse=function(b,a,c){var d=f._bin;b=new Uint8Array(b.buffer, | ||
a,c);a=0;a++;a++;a++;a++;var e=[];a=f.CFF.readIndex(b,a,e);var g=[];for(c=0;c<e.length-1;c++)g.push(d.readASCII(b,a+e[c],e[c+1]-e[c]));a+=e[e.length-1];e=[];a=f.CFF.readIndex(b,a,e);g=[];for(c=0;c<e.length-1;c++)g.push(f.CFF.readDict(b,a+e[c],a+e[c+1]));a+=e[e.length-1];e=g[0];var h=[];a=f.CFF.readIndex(b,a,h);g=[];for(c=0;c<h.length-1;c++)g.push(d.readASCII(b,a+h[c],h[c+1]-h[c]));a+=h[h.length-1];f.CFF.readSubrs(b,a,e);if(e.CharStrings){a=e.CharStrings;h=[];a=f.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=f.CFF.readIndex(b,a,h);e.FDArray=[];for(c=0;c<h.length-1;c++)k=f.CFF.readDict(b,a+h[c],a+h[c+1]),f.CFF._readFDict(b,k,g),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=f.CFF.readEncoding(b,e.Encoding,e.CharStrings.length));e.charset&&(e.charset=f.CFF.readCharset(b, | ||
e.charset,e.CharStrings.length));f.CFF._readFDict(b,e,g);return e};f.CFF._readFDict=function(b,a,c){if(a.Private){var d=a.Private[1];a.Private=f.CFF.readDict(b,d,d+a.Private[0]);a.Private.Subrs&&f.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])};f.CFF.readSubrs=function(b,a,c){var d=f._bin,e=[];a=f.CFF.readIndex(b,a,e);var g=e.length;c.Bias=1240>g?107:33900>g?1131:32768;c.Subrs=[]; | ||
for(g=0;g<e.length-1;g++)c.Subrs.push(d.readBytes(b,a+e[g],e[g+1]-e[g]))};f.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];f.CFF.glyphByUnicode=function(b,a){for(var c=0;c<b.charset.length;c++)if(b.charset[c]==a)return c;return-1};f.CFF.glyphBySE=function(b,a){return 0>a||255<a?-1:f.CFF.glyphByUnicode(b,f.CFF.tableSE[a])};f.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};f.CFF.readCharset=function(b,a,c){var d=f._bin,e=[".notdef"],g=b[a];a++;if(0==g)for(var h=0;h<c;h++){var k=d.readUshort(b,a);a+=2;e.push(k)}else if(1==g||2==g)for(;e.length<c;){k=d.readUshort(b,a);a+=2;if(1==g){var n=b[a];a++}else n=d.readUshort(b,a),a+=2;for(h=0;h<=n;h++)e.push(k),k++}else throw"error: format: "+g;return e};f.CFF.readIndex=function(b, | ||
a,c){var d=f._bin,e=d.readUshort(b,a)+1;a+=2;var g=b[a];a++;if(1==g)for(var h=0;h<e;h++)c.push(b[a+h]);else if(2==g)for(h=0;h<e;h++)c.push(d.readUshort(b,a+2*h));else if(3==g)for(h=0;h<e;h++)c.push(d.readUint(b,a+3*h-1)&16777215);else if(1!=e)throw"unsupported offset size: "+g+", count: "+e;return a+e*g-1};f.CFF.getCharString=function(b,a,c){var d=f._bin,e=b[a],g=b[a+1],h=1,k=null,n=null;20>=e&&(k=e,h=1);12==e&&(k=100*e+g,h=2);21<=e&&27>=e&&(k=e,h=1);28==e&&(n=d.readShort(b,a+1),h=3);29<=e&&31>=e&& | ||
(k=e,h=1);32<=e&&246>=e&&(n=e-139,h=1);247<=e&&250>=e&&(n=256*(e-247)+g+108,h=2);251<=e&&254>=e&&(n=256*-(e-251)-g-108,h=2);255==e&&(n=d.readInt(b,a+1)/65535,h=5);c.val=null!=n?n:"o"+k;c.size=h};f.CFF.readCharString=function(b,a,c){c=a+c;for(var d=f._bin,e=[];a<c;){var g=b[a],h=b[a+1],k=1,n=null,t=null;20>=g&&(n=g,k=1);12==g&&(n=100*g+h,k=2);if(19==g||20==g)n=g,k=2;21<=g&&27>=g&&(n=g,k=1);28==g&&(t=d.readShort(b,a+1),k=3);29<=g&&31>=g&&(n=g,k=1);32<=g&&246>=g&&(t=g-139,k=1);247<=g&&250>=g&&(t=256* | ||
(g-247)+h+108,k=2);251<=g&&254>=g&&(t=256*-(g-251)-h-108,k=2);255==g&&(t=d.readInt(b,a+1)/65535,k=5);e.push(null!=t?t:"o"+n);a+=k}return e};f.CFF.readDict=function(b,a,c){for(var d=f._bin,e={},g=[];a<c;){var h=b[a],k=b[a+1],n=1,t=null,u=null;28==h&&(u=d.readShort(b,a+1),n=3);29==h&&(u=d.readInt(b,a+1),n=5);32<=h&&246>=h&&(u=h-139,n=1);247<=h&&250>=h&&(u=256*(h-247)+k+108,n=2);251<=h&&254>=h&&(u=256*-(h-251)-k-108,n=2);if(255==h)throw d.readInt(b,a+1),"unknown number";if(30==h){u=[];for(n=1;;){var m= | ||
b[a+n];n++;var q=m>>4;m&=15;15!=q&&u.push(q);15!=m&&u.push(m);if(15==m)break}q="";m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"];for(var p=0;p<u.length;p++)q+=m[u[p]];u=parseFloat(q)}21>=h&&(n="version Notice FullName FamilyName Weight FontBBox BlueValues OtherBlues FamilyBlues FamilyOtherBlues StdHW StdVW escape UniqueID XUID charset Encoding CharStrings Private Subrs defaultWidthX nominalWidthX".split(" "),t=n[h],n=1,12==h&&(n=["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"],t=n[k],n=2));null!=t?(e[t]=1==g.length?g[0]:g,g=[]):g.push(u);a+=n}return e};f.cmap={};f.cmap.parse=function(b,a,c){b= | ||
new Uint8Array(b.buffer,a,c);a=0;c=f._bin;var d={};c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;var g=[];d.tables=[];for(var h=0;h<e;h++){var k=c.readUshort(b,a);a+=2;var n=c.readUshort(b,a);a+=2;var t=c.readUint(b,a);a+=4;var u="p"+k+"e"+n,m=g.indexOf(t);if(-1==m){m=d.tables.length;var q;g.push(t);var p=c.readUshort(b,t);0==p?q=f.cmap.parse0(b,t):4==p?q=f.cmap.parse4(b,t):6==p?q=f.cmap.parse6(b,t):12==p?q=f.cmap.parse12(b,t):console.log("unknown format: "+p,k,n,t);d.tables.push(q)}if(null!= | ||
d[u])throw"multiple tables for one platform+encoding";d[u]=m}return d};f.cmap.parse0=function(b,a){var c=f._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};f.cmap.parse4=function(b,a){var c=f._bin,d=a,e={};e.format=c.readUshort(b,a);a+=2;var g=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+g;)e.glyphIdArray.push(c.readUshort(b,a)),a+=2;return e};f.cmap.parse6=function(b,a){var c=f._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 g=0;g<e;g++)d.glyphIdArray.push(c.readUshort(b,a)),a+=2;return d};f.cmap.parse12=function(b,a){var c=f._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 g=0;g<e;g++){var h=a+12*g,k=c.readUint(b,h+0),n=c.readUint(b,h+4);h=c.readUint(b,h+8);d.groups.push([k,n,h])}return d};f.glyf={};f.glyf.parse=function(b,a,c,d){b=[];for(a=0;a<d.maxp.numGlyphs;a++)b.push(null);return b};f.glyf._parseGlyf= | ||
function(b,a){var c=f._bin,d=b._data,e=f._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 g=b.endPts[b.noc- | ||
1]+1;b.flags=[];for(a=0;a<g;a++){var h=d[e];e++;b.flags.push(h);if(0!=(h&8)){var k=d[e];e++;for(var n=0;n<k;n++)b.flags.push(h),a++}}b.xs=[];for(a=0;a<g;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<g;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<g;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,g={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1},b.parts.push(g),g.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?(g.m.tx=h,g.m.ty=k):(g.p1=h,g.p2=k),a&8?(g.m.a=g.m.d=c.readF2dot14(d,e),e+=2):a&64?(g.m.a=c.readF2dot14(d,e),e+=2,g.m.d=c.readF2dot14(d,e),e+=2):a&128&&(g.m.a=c.readF2dot14(d,e),e+=2,g.m.b=c.readF2dot14(d,e),e+=2,g.m.c=c.readF2dot14(d,e),e+=2,g.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};f.GPOS={};f.GPOS.parse=function(b,a,c,d){return f._lctf.parse(b,a,c,d,f.GPOS.subt)};f.GPOS.subt=function(b,a,c){var d=f._bin,e=c,g={};g.fmt=d.readUshort(b,c);c+=2;if(1==a||2==a||3==a||7==a||8==a&&2>=g.fmt){var h=d.readUshort(b,c);c+=2;g.coverage=f._lctf.readCoverage(b,h+e)}if(1==a&&1==g.fmt){var k=d.readUshort(b,c);c+=2;f._lctf.numOfOnes(k);0!=k&&(g.pos=f.GPOS.readValueRecord(b,c,k))}else if(2== | ||
a){k=d.readUshort(b,c);c+=2;var n=d.readUshort(b,c);c+=2;a=f._lctf.numOfOnes(k);h=f._lctf.numOfOnes(n);if(1==g.fmt){g.pairsets=[];var t=d.readUshort(b,c);c+=2;for(var u=0;u<t;u++){var m=e+d.readUshort(b,c);c+=2;var q=d.readUshort(b,m);m+=2;for(var p=[],r=0;r<q;r++){var A=d.readUshort(b,m);m+=2;if(0!=k){var l=f.GPOS.readValueRecord(b,m,k);m+=2*a}if(0!=n){var x=f.GPOS.readValueRecord(b,m,n);m+=2*h}p.push({gid2:A,val1:l,val2:x})}g.pairsets.push(p)}}if(2==g.fmt)for(l=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,g.classDef1=f._lctf.readClassDef(b,e+l),g.classDef2=f._lctf.readClassDef(b,e+x),g.matrix=[],u=0;u<k;u++){e=[];for(r=0;r<d;r++)x=l=null,0!=g.valFmt1&&(l=f.GPOS.readValueRecord(b,c,g.valFmt1),c+=2*a),0!=g.valFmt2&&(x=f.GPOS.readValueRecord(b,c,g.valFmt2),c+=2*h),e.push({val1:l,val2:x});g.matrix.push(e)}}return g};f.GPOS.readValueRecord=function(b,a,c){var d=f._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};f.GSUB={};f.GSUB.parse=function(b,a,c,d){return f._lctf.parse(b,a,c,d,f.GSUB.subt)};f.GSUB.subt=function(b,a,c){var d=f._bin,e=c,g={};g.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>=g.fmt||6==a&&2>=g.fmt){var h=d.readUshort(b,c);c+=2;g.coverage=f._lctf.readCoverage(b,e+h)}if(1==a)1==g.fmt?g.delta=d.readShort(b,c):2==g.fmt&&(h=d.readUshort(b,c),g.newg=d.readUshorts(b, | ||
c+2,h));else if(4==a)for(g.vals=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++){var k=d.readUshort(b,c);c+=2;g.vals.push(f.GSUB.readLigatureSet(b,e+k))}else if(5==a){if(2==g.fmt)for(a=d.readUshort(b,c),c+=2,g.cDef=f._lctf.readClassDef(b,e+a),g.scset=[],h=d.readUshort(b,c),c+=2,a=0;a<h;a++)k=d.readUshort(b,c),c+=2,g.scset.push(0==k?null:f.GSUB.readSubClassSet(b,e+k))}else if(6==a&&3==g.fmt){for(a=0;3>a;a++){h=d.readUshort(b,c);c+=2;k=[];for(var n=0;n<h;n++)k.push(f._lctf.readCoverage(b,e+d.readUshort(b,c+ | ||
2*n)));c+=2*h;0==a&&(g.backCvg=k);1==a&&(g.inptCvg=k);2==a&&(g.ahedCvg=k)}h=d.readUshort(b,c);g.lookupRec=f.GSUB.readSubstLookupRecords(b,c+2,h)}return g};f.GSUB.readSubClassSet=function(b,a){var c=f._bin.readUshort,d=a,e=[],g=c(b,a);a+=2;for(var h=0;h<g;h++){var k=c(b,a);a+=2;e.push(f.GSUB.readSubClassRule(b,d+k))}return e};f.GSUB.readSubClassRule=function(b,a){var c=f._bin.readUshort,d={},e=c(b,a);a+=2;var g=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= | ||
f.GSUB.readSubstLookupRecords(b,a,g);return d};f.GSUB.readSubstLookupRecords=function(b,a,c){for(var d=f._bin.readUshort,e=[],g=0;g<c;g++)e.push(d(b,a),d(b,a+2)),a+=4;return e};f.GSUB.readChainSubClassSet=function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readUshort(b,a);a+=2;e.push(f.GSUB.readChainSubClassRule(b,d+k))}return e};f.GSUB.readChainSubClassRule=function(b,a){for(var c=f._bin,d={},e=["backtrack","input","lookahead"],g=0;g<e.length;g++){var h=c.readUshort(b, | ||
a);a+=2;1==g&&h--;d[e[g]]=c.readUshorts(b,a,h);a+=2*d[e[g]].length}h=c.readUshort(b,a);d.subst=c.readUshorts(b,a+2,2*h);return d};f.GSUB.readLigatureSet=function(b,a){var c=f._bin,d=a,e=[],g=c.readUshort(b,a);a+=2;for(var h=0;h<g;h++){var k=c.readUshort(b,a);a+=2;e.push(f.GSUB.readLigature(b,d+k))}return e};f.GSUB.readLigature=function(b,a){var c=f._bin,d={chain:[]};d.nglyph=c.readUshort(b,a);a+=2;var e=c.readUshort(b,a);a+=2;for(var g=0;g<e-1;g++)d.chain.push(c.readUshort(b,a)),a+=2;return d};f.head= | ||
{};f.head.parse=function(b,a,c){c=f._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};f.hhea={};f.hhea.parse=function(b,a,c){c=f._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};f.hmtx={};f.hmtx.parse=function(b,a,c,d){c=f._bin;for(var e={aWidth:[],lsBearing:[]},g=0,h=0,k=0;k<d.maxp.numGlyphs;k++)k<d.hhea.numberOfHMetrics&&(g=c.readUshort(b,a),a+=2,h=c.readShort(b,a),a+=2),e.aWidth.push(g),e.lsBearing.push(h);return e};f.kern={};f.kern.parse=function(b,a,c,d){var e=f._bin,g=e.readUshort(b,a);a+=2;if(1==g)return f.kern.parseV1(b,a-2,c,d);c=e.readUshort(b, | ||
a);a+=2;d={glyph1:[],rval:[]};for(g=0;g<c;g++){a+=2;e.readUshort(b,a);a+=2;var h=e.readUshort(b,a);a+=2;h>>>=8;h&=15;if(0==h)a=f.kern.readFormat0(b,a,d);else throw"unknown kern table format: "+h;}return d};f.kern.parseV1=function(b,a,c,d){c=f._bin;c.readFixed(b,a);a+=4;d=c.readUint(b,a);a+=4;for(var e={glyph1:[],rval:[]},g=0;g<d;g++){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=f.kern.readFormat0(b,a,e);else throw"unknown kern table format: "+h;}return e}; | ||
f.kern.readFormat0=function(b,a,c){var d=f._bin,e=-1,g=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<g;h++){var k=d.readUshort(b,a);a+=2;var n=d.readUshort(b,a);a+=2;var t=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(n);e.vals.push(t);e=k}return a};f.loca={};f.loca.parse=function(b,a,c,d){c=f._bin;var e=[],g=d.head.indexToLocFormat;d=d.maxp.numGlyphs+1;if(0==g)for(var h= | ||
0;h<d;h++)e.push(c.readUshort(b,a+(h<<1))<<1);if(1==g)for(h=0;h<d;h++)e.push(c.readUint(b,a+(h<<2)));return e};f.maxp={};f.maxp.parse=function(b,a,c){c=f._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};f.name={};f.name.parse=function(b,a,c){c=f._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 g="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 n=c.readUshort(b,a);a+=2;var t=c.readUshort(b,a);a+=2;var u=c.readUshort(b,a);a+=2;var m=c.readUshort(b,a);a+=2;var q=c.readUshort(b,a);a+=2;var p=c.readUshort(b,a);a+=2;m=g[m];p=h+12*e+p;if(0==n)q=c.readUnicode(b,p,q/2);else if(3==n&&0==t)q=c.readUnicode(b,p,q/2);else if(0==t)q=c.readASCII(b,p,q);else if(1==t)q=c.readUnicode(b,p,q/2);else if(3==t)q=c.readUnicode(b,p,q/2);else if(1==n)q=c.readASCII(b,p,q),console.log("reading unknown MAC encoding "+t+" as ASCII");else throw"unknown encoding "+ | ||
t+", platformID: "+n;n="p"+n+","+u.toString(16);null==d[n]&&(d[n]={});d[n][m]=q;d[n]._lang=u}for(var r in d)if(null!=d[r].postScriptName&&1033==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName&&0==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName&&3084==d[r]._lang)return d[r];for(r in d)if(null!=d[r].postScriptName)return d[r];for(r in d){var l=r;break}console.log("returning name table with languageID "+d[l]._lang);return d[l]};f["OS/2"]={};f["OS/2"].parse=function(b,a, | ||
c){c=f._bin.readUshort(b,a);a+=2;var d={};if(0==c)f["OS/2"].version0(b,a,d);else if(1==c)f["OS/2"].version1(b,a,d);else if(2==c||3==c||4==c)f["OS/2"].version2(b,a,d);else if(5==c)f["OS/2"].version5(b,a,d);else throw"unknown OS/2 table version: "+c;return d};f["OS/2"].version0=function(b,a,c){var d=f._bin;c.xAvgCharWidth=d.readShort(b,a);a+=2;c.usWeightClass=d.readUshort(b,a);a+=2;c.usWidthClass=d.readUshort(b,a);a+=2;c.fsType=d.readUshort(b,a);a+=2;c.ySubscriptXSize=d.readShort(b,a);a+=2;c.ySubscriptYSize= | ||
@@ -54,65 +57,62 @@ d.readShort(b,a);a+=2;c.ySubscriptXOffset=d.readShort(b,a);a+=2;c.ySubscriptYOffset=d.readShort(b,a);a+=2;c.ySuperscriptXSize=d.readShort(b,a);a+=2;c.ySuperscriptYSize=d.readShort(b,a);a+=2;c.ySuperscriptXOffset=d.readShort(b,a);a+=2;c.ySuperscriptYOffset=d.readShort(b,a);a+=2;c.yStrikeoutSize=d.readShort(b,a);a+=2;c.yStrikeoutPosition=d.readShort(b,a);a+=2;c.sFamilyClass=d.readShort(b,a);a+=2;c.panose=d.readBytes(b,a,10);a+=10;c.ulUnicodeRange1=d.readUint(b,a);a+=4;c.ulUnicodeRange2=d.readUint(b, | ||
function(b,a,c){var d=f._bin;a=f["OS/2"].version0(b,a,c);c.ulCodePageRange1=d.readUint(b,a);a+=4;c.ulCodePageRange2=d.readUint(b,a);return a+4};f["OS/2"].version2=function(b,a,c){var d=f._bin;a=f["OS/2"].version1(b,a,c);c.sxHeight=d.readShort(b,a);a+=2;c.sCapHeight=d.readShort(b,a);a+=2;c.usDefault=d.readUshort(b,a);a+=2;c.usBreak=d.readUshort(b,a);a+=2;c.usMaxContext=d.readUshort(b,a);return a+2};f["OS/2"].version5=function(b,a,c){var d=f._bin;a=f["OS/2"].version2(b,a,c);c.usLowerOpticalPointSize= | ||
d.readUshort(b,a);a+=2;c.usUpperOpticalPointSize=d.readUshort(b,a);return a+2};f.post={};f.post.parse=function(b,a,c){c=f._bin;var d={};d.version=c.readFixed(b,a);a+=4;d.italicAngle=c.readFixed(b,a);a+=4;d.underlinePosition=c.readShort(b,a);d.underlineThickness=c.readShort(b,a+2);return d};f.SVG={};f.SVG.parse=function(b,a,c){c=f._bin;var d={entries:[]},e=a;c.readUshort(b,a);a+=2;var g=c.readUint(b,a);c.readUint(b,a+4);a=g+e;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var m=c.readUshort(b,a); | ||
a+=2;var q=c.readUshort(b,a);a+=2;var u=c.readUint(b,a);a+=4;var n=c.readUint(b,a);a+=4;u=new Uint8Array(b.buffer,e+u+g,n);for(u=c.readUTF8(u,0,u.length);m<=q;m++)d.entries[m]=u}return d};f.SVG.toPath=function(b){var a={cmds:[],crds:[]};if(null==b)return a;for(var c=(new DOMParser).parseFromString(b,"image/svg+xml").firstChild;"svg"!=c.tagName;)c=c.nextSibling;b=(b=c.getAttribute("viewBox"))?b.trim().split(" ").map(parseFloat):[0,0,1E3,1E3];f.SVG._toPath(c.children,a);for(c=0;c<a.crds.length;c+=2){var d= | ||
d.readUshort(b,a);a+=2;c.usUpperOpticalPointSize=d.readUshort(b,a);return a+2};f.post={};f.post.parse=function(b,a,c){c=f._bin;var d={};d.version=c.readFixed(b,a);a+=4;d.italicAngle=c.readFixed(b,a);a+=4;d.underlinePosition=c.readShort(b,a);d.underlineThickness=c.readShort(b,a+2);return d};f.SVG={};f.SVG.parse=function(b,a,c){c=f._bin;var d={entries:[]},e=a;c.readUshort(b,a);a+=2;var g=c.readUint(b,a);c.readUint(b,a+4);a=g+e;var h=c.readUshort(b,a);a+=2;for(var k=0;k<h;k++){var n=c.readUshort(b,a); | ||
a+=2;var t=c.readUshort(b,a);a+=2;var u=c.readUint(b,a);a+=4;var m=c.readUint(b,a);a+=4;u=new Uint8Array(b.buffer,e+u+g,m);for(u=c.readUTF8(u,0,u.length);n<=t;n++)d.entries[n]=u}return d};f.SVG.toPath=function(b){var a={cmds:[],crds:[]};if(null==b)return a;for(var c=(new DOMParser).parseFromString(b,"image/svg+xml").firstChild;"svg"!=c.tagName;)c=c.nextSibling;b=(b=c.getAttribute("viewBox"))?b.trim().split(" ").map(parseFloat):[0,0,1E3,1E3];f.SVG._toPath(c.children,a);for(c=0;c<a.crds.length;c+=2){var d= | ||
a.crds[c],e=a.crds[c+1];d-=b[0];e-=b[1];e=-e;a.crds[c]=d;a.crds[c+1]=e}return a};f.SVG._toPath=function(b,a,c){for(var d=0;d<b.length;d++){var e=b[d],g=e.tagName,h=e.getAttribute("fill");null==h&&(h=c);"g"==g?f.SVG._toPath(e.children,a,h):"path"==g?(a.cmds.push(h?h:"#000000"),e=e.getAttribute("d"),e=f.SVG._tokens(e),f.SVG._toksToPath(e,a),a.cmds.push("X")):"defs"!=g&&console.log(g,e)}};f.SVG._tokens=function(b){for(var a=[],c=0,d=!1,e="";c<b.length;){var g=b.charCodeAt(c),f=b.charAt(c);c++;g=48<= | ||
g&&57>=g||"."==f||"-"==f;d?"-"==f?(a.push(parseFloat(e)),e=f):g?e+=f:(a.push(parseFloat(e)),","!=f&&" "!=f&&a.push(f),d=!1):g?(e=f,d=!0):","!=f&&" "!=f&&a.push(f)}d&&a.push(parseFloat(e));return a};f.SVG._toksToPath=function(b,a){var c=0,d=0,e=0,g=0,h=0,k={M:2,L:2,H:1,V:1,S:4,C:6},m=a.cmds;for(a=a.crds;c<b.length;){var q=b[c];c++;if("z"==q)m.push("Z"),d=g,e=h;else for(var u=q.toUpperCase(),n=f.SVG._reps(b,c,k[u]),r=0;r<n;r++){var p=0,t=0;q!=u&&(p=d,t=e);if("M"==u)d=p+b[c++],e=t+b[c++],m.push("M"), | ||
a.push(d,e),g=d,h=e;else if("L"==u)d=p+b[c++],e=t+b[c++],m.push("L"),a.push(d,e);else if("H"==u)d=p+b[c++],m.push("L"),a.push(d,e);else if("V"==u)e=t+b[c++],m.push("L"),a.push(d,e);else if("C"==u){d=p+b[c++];e=t+b[c++];var y=p+b[c++],l=t+b[c++];p+=b[c++];t+=b[c++];m.push("C");a.push(d,e,y,l,p,t);d=p;e=t}else"S"==u?(y=Math.max(a.length-4,0),d=d+d-a[y],e=e+e-a[y+1],y=p+b[c++],l=t+b[c++],p+=b[c++],t+=b[c++],m.push("C"),a.push(d,e,y,l,p,t),d=p,e=t):console.log("Unknown SVG command "+q)}}};f.SVG._reps= | ||
g&&57>=g||"."==f||"-"==f;d?"-"==f?(a.push(parseFloat(e)),e=f):g?e+=f:(a.push(parseFloat(e)),","!=f&&" "!=f&&a.push(f),d=!1):g?(e=f,d=!0):","!=f&&" "!=f&&a.push(f)}d&&a.push(parseFloat(e));return a};f.SVG._toksToPath=function(b,a){var c=0,d=0,e=0,g=0,h=0,k={M:2,L:2,H:1,V:1,S:4,C:6},n=a.cmds;for(a=a.crds;c<b.length;){var t=b[c];c++;if("z"==t)n.push("Z"),d=g,e=h;else for(var u=t.toUpperCase(),m=f.SVG._reps(b,c,k[u]),q=0;q<m;q++){var p=0,r=0;t!=u&&(p=d,r=e);if("M"==u)d=p+b[c++],e=r+b[c++],n.push("M"), | ||
a.push(d,e),g=d,h=e;else if("L"==u)d=p+b[c++],e=r+b[c++],n.push("L"),a.push(d,e);else if("H"==u)d=p+b[c++],n.push("L"),a.push(d,e);else if("V"==u)e=r+b[c++],n.push("L"),a.push(d,e);else if("C"==u){d=p+b[c++];e=r+b[c++];var l=p+b[c++],v=r+b[c++];p+=b[c++];r+=b[c++];n.push("C");a.push(d,e,l,v,p,r);d=p;e=r}else"S"==u?(l=Math.max(a.length-4,0),d=d+d-a[l],e=e+e-a[l+1],l=p+b[c++],v=r+b[c++],p+=b[c++],r+=b[c++],n.push("C"),a.push(d,e,l,v,p,r),d=p,e=r):console.log("Unknown SVG command "+t)}}};f.SVG._reps= | ||
function(b,a,c){for(var d=a;d<b.length&&"string"!=typeof b[d];)d+=c;return(d-a)/c};null==f&&(f={});null==f.U&&(f.U={});f.U.codeToGlyph=function(b,a){b=b.cmap;var c=-1;null!=b.p0e4?c=b.p0e4:null!=b.p3e1?c=b.p3e1:null!=b.p1e0?c=b.p1e0:null!=b.p0e3&&(c=b.p0e3);if(-1==c)throw"no familiar platform and encoding!";b=b.tables[c];if(0==b.format)return a>=b.map.length?0:b.map[a];if(4==b.format){var d=-1;for(c=0;c<b.endCount.length;c++)if(a<=b.endCount[c]){d=c;break}return-1==d||b.startCount[d]>a?0:(0!=b.idRangeOffset[d]? | ||
b.glyphIdArray[a-b.startCount[d]+(b.idRangeOffset[d]>>1)-(b.idRangeOffset.length-d)]:a+b.idDelta[d])&65535}if(12==b.format){if(a>b.groups[b.groups.length-1][1])return 0;for(c=0;c<b.groups.length;c++)if(d=b.groups[c],d[0]<=a&&a<=d[1])return d[2]+(a-d[0]);return 0}throw"unknown cmap table format "+b.format;};f.U.glyphToPath=function(b,a){var c={cmds:[],crds:[]};if(b.SVG&&b.SVG.entries[a]){var d=b.SVG.entries[a];if(null==d)return c;"string"==typeof d&&(d=f.SVG.toPath(d),b.SVG.entries[a]=d);return d}if(b.CFF){d= | ||
{x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:b.CFF.Private?b.CFF.Private.defaultWidthX:0,open:!1};var e=b.CFF,g=b.CFF.Private;if(e.ROS){for(g=0;e.FDSelect[g+2]<=a;)g+=2;g=e.FDArray[e.FDSelect[g+1]].Private}f.U._drawCFF(b.CFF.CharStrings[a],d,e,g,c)}else b.glyf&&f.U._drawGlyf(a,b,c);return c};f.U._drawGlyf=function(b,a,c){var d=a.glyf[b];null==d&&(d=a.glyf[b]=f.glyf._parseGlyf(a,b));null!=d&&(-1<d.noc?f.U._simpleGlyph(d,c):f.U._compoGlyph(d,a,c))};f.U._simpleGlyph=function(b,a){for(var c=0;c<b.noc;c++){for(var d= | ||
0==c?0:b.endPts[c-1]+1,e=b.endPts[c],g=d;g<=e;g++){var h=g==d?e:g-1,k=g==e?d:g+1,m=b.flags[g]&1,q=b.flags[h]&1,u=b.flags[k]&1,n=b.xs[g],r=b.ys[g];if(g==d)if(m)if(q)f.U.P.moveTo(a,b.xs[h],b.ys[h]);else{f.U.P.moveTo(a,n,r);continue}else q?f.U.P.moveTo(a,b.xs[h],b.ys[h]):f.U.P.moveTo(a,(b.xs[h]+n)/2,(b.ys[h]+r)/2);m?q&&f.U.P.lineTo(a,n,r):u?f.U.P.qcurveTo(a,n,r,b.xs[k],b.ys[k]):f.U.P.qcurveTo(a,n,r,(n+b.xs[k])/2,(r+b.ys[k])/2)}f.U.P.closePath(a)}};f.U._compoGlyph=function(b,a,c){for(var d=0;d<b.parts.length;d++){var e= | ||
{cmds:[],crds:[]},g=b.parts[d];f.U._drawGlyf(g.glyphIndex,a,e);g=g.m;for(var h=0;h<e.crds.length;h+=2){var k=e.crds[h],m=e.crds[h+1];c.crds.push(k*g.a+m*g.b+g.tx);c.crds.push(k*g.c+m*g.d+g.ty)}for(h=0;h<e.cmds.length;h++)c.cmds.push(e.cmds[h])}};f.U._getGlyphClass=function(b,a){b=f._lctf.getInterval(a,b);return-1==b?0:a[b+2]};f.U.getPairAdjustment=function(b,a,c){if(b.GPOS){var d=b.GPOS,e=d.lookupList;d=d.featureList;for(var g=[],h=0;h<d.length;h++){var k=d[h];if("kern"==k.tag)for(var m=0;m<k.tab.length;m++)if(!g[k.tab[m]]){g[k.tab[m]]= | ||
!0;for(var q=e[k.tab[m]],u=0;u<q.tabs.length;u++)if(null!=q.tabs[h]){var n=q.tabs[u];if(n.coverage){var r=f._lctf.coverageIndex(n.coverage,a);if(-1==r)continue}if(1!=q.ltype&&2==q.ltype){var p;if(1==n.fmt)for(n=n.pairsets[r],h=0;h<n.length;h++)n[h].gid2==c&&(p=n[h]);else if(2==n.fmt){p=f.U._getGlyphClass(a,n.classDef1);var t=f.U._getGlyphClass(c,n.classDef2);p=n.matrix[p][t]}if(p&&p.val2)return p.val2[2]}}}}}return b.kern&&(a=b.kern.glyph1.indexOf(a),-1!=a&&(c=b.kern.rval[a].glyph2.indexOf(c),-1!= | ||
c))?b.kern.rval[a].vals[c]:0};f.U.stringToGlyphs=function(b,a){for(var c=[],d=0;d<a.length;d++){var e=a.codePointAt(d);65535<e&&d++;c.push(f.U.codeToGlyph(b,e))}for(d=0;d<a.length;d++){e=a.codePointAt(d);if(2367==e){var g=c[d-1];c[d-1]=c[d];c[d]=g}65535<e&&d++}d=b.GSUB;if(null==d)return c;b=d.lookupList;d=d.featureList;e="rlig liga mset isol init fina medi half pres blws".split(" ");g=[];for(var h=0;h<d.length;h++){var k=d[h];if(-1!=e.indexOf(k.tag))for(var m=0;m<k.tab.length;m++)if(!g[k.tab[m]]){g[k.tab[m]]= | ||
!0;for(var q=b[k.tab[m]],u=0;u<c.length;u++){var n=f.U._getWPfeature(a,u);-1!="isol,init,fina,medi".indexOf(k.tag)&&k.tag!=n||f.U._applySubs(c,u,q,b)}}}return c};f.U._getWPfeature=function(b,a){var c=0==a||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a-1]),d=a==b.length-1||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a+1]);c||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a- | ||
0==c?0:b.endPts[c-1]+1,e=b.endPts[c],g=d;g<=e;g++){var h=g==d?e:g-1,k=g==e?d:g+1,n=b.flags[g]&1,t=b.flags[h]&1,u=b.flags[k]&1,m=b.xs[g],q=b.ys[g];if(g==d)if(n)if(t)f.U.P.moveTo(a,b.xs[h],b.ys[h]);else{f.U.P.moveTo(a,m,q);continue}else t?f.U.P.moveTo(a,b.xs[h],b.ys[h]):f.U.P.moveTo(a,(b.xs[h]+m)/2,(b.ys[h]+q)/2);n?t&&f.U.P.lineTo(a,m,q):u?f.U.P.qcurveTo(a,m,q,b.xs[k],b.ys[k]):f.U.P.qcurveTo(a,m,q,(m+b.xs[k])/2,(q+b.ys[k])/2)}f.U.P.closePath(a)}};f.U._compoGlyph=function(b,a,c){for(var d=0;d<b.parts.length;d++){var e= | ||
{cmds:[],crds:[]},g=b.parts[d];f.U._drawGlyf(g.glyphIndex,a,e);g=g.m;for(var h=0;h<e.crds.length;h+=2){var k=e.crds[h],n=e.crds[h+1];c.crds.push(k*g.a+n*g.b+g.tx);c.crds.push(k*g.c+n*g.d+g.ty)}for(h=0;h<e.cmds.length;h++)c.cmds.push(e.cmds[h])}};f.U._getGlyphClass=function(b,a){b=f._lctf.getInterval(a,b);return-1==b?0:a[b+2]};f.U.getPairAdjustment=function(b,a,c){if(b.GPOS){var d=b.GPOS,e=d.lookupList;d=d.featureList;for(var g=[],h=0;h<d.length;h++){var k=d[h];if("kern"==k.tag)for(var n=0;n<k.tab.length;n++)if(!g[k.tab[n]]){g[k.tab[n]]= | ||
!0;for(var t=e[k.tab[n]],u=0;u<t.tabs.length;u++)if(null!=t.tabs[h]){var m=t.tabs[u];if(m.coverage){var q=f._lctf.coverageIndex(m.coverage,a);if(-1==q)continue}if(1!=t.ltype&&2==t.ltype){var p;if(1==m.fmt)for(m=m.pairsets[q],h=0;h<m.length;h++)m[h].gid2==c&&(p=m[h]);else if(2==m.fmt){p=f.U._getGlyphClass(a,m.classDef1);var r=f.U._getGlyphClass(c,m.classDef2);p=m.matrix[p][r]}if(p&&p.val2)return p.val2[2]}}}}}return b.kern&&(a=b.kern.glyph1.indexOf(a),-1!=a&&(c=b.kern.rval[a].glyph2.indexOf(c),-1!= | ||
c))?b.kern.rval[a].vals[c]:0};f.U.stringToGlyphs=function(b,a){for(var c=[],d=0;d<a.length;d++){var e=a.codePointAt(d);65535<e&&d++;c.push(f.U.codeToGlyph(b,e))}for(d=0;d<a.length;d++){e=a.codePointAt(d);if(2367==e){var g=c[d-1];c[d-1]=c[d];c[d]=g}65535<e&&d++}d=b.GSUB;if(null==d)return c;b=d.lookupList;d=d.featureList;e="rlig liga mset isol init fina medi half pres blws".split(" ");g=[];for(var h=0;h<d.length;h++){var k=d[h];if(-1!=e.indexOf(k.tag))for(var n=0;n<k.tab.length;n++)if(!g[k.tab[n]]){g[k.tab[n]]= | ||
!0;for(var t=b[k.tab[n]],u=0;u<c.length;u++){var m=f.U._getWPfeature(a,u);-1!="isol,init,fina,medi".indexOf(k.tag)&&k.tag!=m||f.U._applySubs(c,u,t,b)}}}return c};f.U._getWPfeature=function(b,a){var c=0==a||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a-1]),d=a==b.length-1||-1!='\n\t" ,.:;!?() \u060c'.indexOf(b[a+1]);c||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a- | ||
1])||(c=!0);d||-1=="\u0622\u0623\u0624\u0625\u0627\u0629\u062f\u0630\u0631\u0632\u0648\u0671\u0672\u0673\u0675\u0676\u0677\u0688\u0689\u068a\u068b\u068c\u068d\u068e\u068f\u0690\u0691\u0692\u0693\u0694\u0695\u0696\u0697\u0698\u0699\u06c0\u06c3\u06c4\u06c5\u06c6\u06c7\u06c8\u06c9\u06ca\u06cb\u06cd\u06cf\u06d2\u06d3\u06d5\u06ee\u06ef\u0710\u0715\u0716\u0717\u0718\u0719\u071e\u0728\u072a\u072c\u072f\u074d\u0759\u075a\u075b\u076b\u076c\u0771\u0773\u0774\u0778\u0779\u0840\u0846\u0847\u0849\u0854\u0867\u0869\u086a\u08aa\u08ab\u08ac\u08ae\u08b1\u08b2\u08b9\u0ac5\u0ac7\u0ac9\u0aca\u0ace\u0acf\u0ad0\u0ad1\u0ad2\u0add\u0ae1\u0ae4\u0aef\u0b81\u0b83\u0b84\u0b85\u0b89\u0b8c\u0b8e\u0b8f\u0b91\u0ba9\u0baa\u0bab\u0bac".indexOf(b[a])|| | ||
(d=!0);d||-1=="\ua872\u0acd\u0ad7".indexOf(b[a+1])||(d=!0);c||-1=="\ua872\u0acd\u0ad7".indexOf(b[a])||(c=!0);return c?d?"isol":"init":d?"fina":"medi"};f.U._applySubs=function(b,a,c,d){for(var e=b.length-a-1,g=0;g<c.tabs.length;g++)if(null!=c.tabs[g]){var h=c.tabs[g];if(h.coverage){var k=f._lctf.coverageIndex(h.coverage,b[a]);if(-1==k)continue}if(1==c.ltype)b[a]=1==h.fmt?b[a]+h.delta:h.newg[k];else if(4==c.ltype)for(var m=h.vals[k],q=0;q<m.length;q++){var u=m[q];h=u.chain.length;if(!(h>e)){for(var n= | ||
!0,r=0,p=0;p<h;p++){for(;-1==b[a+r+(1+p)];)r++;u.chain[p]!=b[a+r+(1+p)]&&(n=!1)}if(n){b[a]=u.nglyph;for(p=0;p<h+r;p++)b[a+p+1]=-1;break}}}else if(5==c.ltype&&2==h.fmt)for(m=f._lctf.getInterval(h.cDef,b[a]),r=h.scset[h.cDef[m+2]],u=0;u<r.length;u++){q=r[u];var t=q.input;if(!(t.length>e)){n=!0;for(p=0;p<t.length;p++){var l=f._lctf.getInterval(h.cDef,b[a+1+p]);if(-1==m&&h.cDef[l+2]!=t[p]){n=!1;break}}if(n)for(n=q.substLookupRecords,q=0;q<n.length;q+=2);}}else if(6==c.ltype&&3==h.fmt&&f.U._glsCovered(b, | ||
h.backCvg,a-h.backCvg.length)&&f.U._glsCovered(b,h.inptCvg,a)&&f.U._glsCovered(b,h.ahedCvg,a+h.inptCvg.length))for(n=h.lookupRec,u=0;u<n.length;u+=2)m=n[u],f.U._applySubs(b,a+m,d[n[u+1]],d)}};f.U._glsCovered=function(b,a,c){for(var d=0;d<a.length;d++)if(-1==f._lctf.coverageIndex(a[d],b[c+d]))return!1;return!0};f.U.glyphsToPath=function(b,a,c){for(var d={cmds:[],crds:[]},e=0,g=0;g<a.length;g++){var h=a[g];if(-1!=h){for(var k=g<a.length-1&&-1!=a[g+1]?a[g+1]:0,m=f.U.glyphToPath(b,h),q=0;q<m.crds.length;q+= | ||
2)d.crds.push(m.crds[q]+e),d.crds.push(m.crds[q+1]);c&&d.cmds.push(c);for(q=0;q<m.cmds.length;q++)d.cmds.push(m.cmds[q]);c&&d.cmds.push("X");e+=b.hmtx.aWidth[h];g<a.length-1&&(e+=f.U.getPairAdjustment(b,h,k))}}return d};f.U.pathToSVG=function(b,a){null==a&&(a=5);for(var c=[],d=0,e={M:2,L:2,Q:4,C:6},g=0;g<b.cmds.length;g++){var f=b.cmds[g],k=d+(e[f]?e[f]:0);for(c.push(f);d<k;)f=b.crds[d++],c.push(parseFloat(f.toFixed(a))+(d==k?"":" "))}return c.join("")};f.U.pathToContext=function(b,a){for(var c=0, | ||
(d=!0);d||-1=="\ua872\u0acd\u0ad7".indexOf(b[a+1])||(d=!0);c||-1=="\ua872\u0acd\u0ad7".indexOf(b[a])||(c=!0);return c?d?"isol":"init":d?"fina":"medi"};f.U._applySubs=function(b,a,c,d){for(var e=b.length-a-1,g=0;g<c.tabs.length;g++)if(null!=c.tabs[g]){var h=c.tabs[g];if(h.coverage){var k=f._lctf.coverageIndex(h.coverage,b[a]);if(-1==k)continue}if(1==c.ltype)b[a]=1==h.fmt?b[a]+h.delta:h.newg[k];else if(4==c.ltype)for(var n=h.vals[k],t=0;t<n.length;t++){var u=n[t];h=u.chain.length;if(!(h>e)){for(var m= | ||
!0,q=0,p=0;p<h;p++){for(;-1==b[a+q+(1+p)];)q++;u.chain[p]!=b[a+q+(1+p)]&&(m=!1)}if(m){b[a]=u.nglyph;for(p=0;p<h+q;p++)b[a+p+1]=-1;break}}}else if(5==c.ltype&&2==h.fmt)for(n=f._lctf.getInterval(h.cDef,b[a]),q=h.scset[h.cDef[n+2]],u=0;u<q.length;u++){t=q[u];var r=t.input;if(!(r.length>e)){m=!0;for(p=0;p<r.length;p++){var l=f._lctf.getInterval(h.cDef,b[a+1+p]);if(-1==n&&h.cDef[l+2]!=r[p]){m=!1;break}}if(m)for(m=t.substLookupRecords,t=0;t<m.length;t+=2);}}else if(6==c.ltype&&3==h.fmt&&f.U._glsCovered(b, | ||
h.backCvg,a-h.backCvg.length)&&f.U._glsCovered(b,h.inptCvg,a)&&f.U._glsCovered(b,h.ahedCvg,a+h.inptCvg.length))for(m=h.lookupRec,u=0;u<m.length;u+=2)n=m[u],f.U._applySubs(b,a+n,d[m[u+1]],d)}};f.U._glsCovered=function(b,a,c){for(var d=0;d<a.length;d++)if(-1==f._lctf.coverageIndex(a[d],b[c+d]))return!1;return!0};f.U.glyphsToPath=function(b,a,c){for(var d={cmds:[],crds:[]},e=0,g=0;g<a.length;g++){var h=a[g];if(-1!=h){for(var k=g<a.length-1&&-1!=a[g+1]?a[g+1]:0,n=f.U.glyphToPath(b,h),t=0;t<n.crds.length;t+= | ||
2)d.crds.push(n.crds[t]+e),d.crds.push(n.crds[t+1]);c&&d.cmds.push(c);for(t=0;t<n.cmds.length;t++)d.cmds.push(n.cmds[t]);c&&d.cmds.push("X");e+=b.hmtx.aWidth[h];g<a.length-1&&(e+=f.U.getPairAdjustment(b,h,k))}}return d};f.U.pathToSVG=function(b,a){null==a&&(a=5);for(var c=[],d=0,e={M:2,L:2,Q:4,C:6},g=0;g<b.cmds.length;g++){var f=b.cmds[g],k=d+(e[f]?e[f]:0);for(c.push(f);d<k;)f=b.crds[d++],c.push(parseFloat(f.toFixed(a))+(d==k?"":" "))}return c.join("")};f.U.pathToContext=function(b,a){for(var c=0, | ||
d=b.crds,e=0;e<b.cmds.length;e++){var g=b.cmds[e];"M"==g?(a.moveTo(d[c],d[c+1]),c+=2):"L"==g?(a.lineTo(d[c],d[c+1]),c+=2):"C"==g?(a.bezierCurveTo(d[c],d[c+1],d[c+2],d[c+3],d[c+4],d[c+5]),c+=6):"Q"==g?(a.quadraticCurveTo(d[c],d[c+1],d[c+2],d[c+3]),c+=4):"#"==g.charAt(0)?(a.beginPath(),a.fillStyle=g):"Z"==g?a.closePath():"X"==g&&a.fill()}};f.U.P={};f.U.P.moveTo=function(b,a,c){b.cmds.push("M");b.crds.push(a,c)};f.U.P.lineTo=function(b,a,c){b.cmds.push("L");b.crds.push(a,c)};f.U.P.curveTo=function(b, | ||
a,c,d,e,g,f){b.cmds.push("C");b.crds.push(a,c,d,e,g,f)};f.U.P.qcurveTo=function(b,a,c,d,e){b.cmds.push("Q");b.crds.push(a,c,d,e)};f.U.P.closePath=function(b){b.cmds.push("Z")};f.U._drawCFF=function(b,a,c,d,e){for(var g=a.stack,h=a.nStems,k=a.haveWidth,m=a.width,q=a.open,u=0,n=a.x,r=a.y,p,t,l,v,x,A,B,D,E,G,z={val:0,size:0};u<b.length;){f.CFF.getCharString(b,u,z);var w=z.val;u+=z.size;if("o1"==w||"o18"==w)(p=0!==g.length%2)&&!k&&(m=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length=0,k=!0;else if("o3"== | ||
w||"o23"==w)(p=0!==g.length%2)&&!k&&(m=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length=0,k=!0;else if("o4"==w)1<g.length&&!k&&(m=g.shift()+d.nominalWidthX,k=!0),q&&f.U.P.closePath(e),r+=g.pop(),f.U.P.moveTo(e,n,r),q=!0;else if("o5"==w)for(;0<g.length;)n+=g.shift(),r+=g.shift(),f.U.P.lineTo(e,n,r);else if("o6"==w||"o7"==w)for(x=g.length,p="o6"==w,t=0;t<x;t++)l=g.shift(),p?n+=l:r+=l,p=!p,f.U.P.lineTo(e,n,r);else if("o8"==w||"o24"==w){x=g.length;for(A=0;A+6<=x;)p=n+g.shift(),t=r+g.shift(),l=p+g.shift(), | ||
v=t+g.shift(),n=l+g.shift(),r=v+g.shift(),f.U.P.curveTo(e,p,t,l,v,n,r),A+=6;"o24"==w&&(n+=g.shift(),r+=g.shift(),f.U.P.lineTo(e,n,r))}else if("o11"==w)break;else if("o1234"==w||"o1235"==w||"o1236"==w||"o1237"==w)"o1234"==w&&(p=n+g.shift(),t=r,l=p+g.shift(),v=t+g.shift(),E=l+g.shift(),G=v,x=E+g.shift(),A=v,B=x+g.shift(),D=r,n=B+g.shift(),f.U.P.curveTo(e,p,t,l,v,E,G),f.U.P.curveTo(e,x,A,B,D,n,r)),"o1235"==w&&(p=n+g.shift(),t=r+g.shift(),l=p+g.shift(),v=t+g.shift(),E=l+g.shift(),G=v+g.shift(),x=E+g.shift(), | ||
A=G+g.shift(),B=x+g.shift(),D=A+g.shift(),n=B+g.shift(),r=D+g.shift(),g.shift(),f.U.P.curveTo(e,p,t,l,v,E,G),f.U.P.curveTo(e,x,A,B,D,n,r)),"o1236"==w&&(p=n+g.shift(),t=r+g.shift(),l=p+g.shift(),v=t+g.shift(),E=l+g.shift(),G=v,x=E+g.shift(),A=v,B=x+g.shift(),D=A+g.shift(),n=B+g.shift(),f.U.P.curveTo(e,p,t,l,v,E,G),f.U.P.curveTo(e,x,A,B,D,n,r)),"o1237"==w&&(p=n+g.shift(),t=r+g.shift(),l=p+g.shift(),v=t+g.shift(),E=l+g.shift(),G=v+g.shift(),x=E+g.shift(),A=G+g.shift(),B=x+g.shift(),D=A+g.shift(),Math.abs(B- | ||
n)>Math.abs(D-r)?n=B+g.shift():r=D+g.shift(),f.U.P.curveTo(e,p,t,l,v,E,G),f.U.P.curveTo(e,x,A,B,D,n,r));else if("o14"==w)0<g.length&&!k&&(m=g.shift()+c.nominalWidthX,k=!0),4==g.length&&(p=g.shift(),t=g.shift(),v=g.shift(),l=g.shift(),v=f.CFF.glyphBySE(c,v),l=f.CFF.glyphBySE(c,l),f.U._drawCFF(c.CharStrings[v],a,c,d,e),a.x=p,a.y=t,f.U._drawCFF(c.CharStrings[l],a,c,d,e)),q&&(f.U.P.closePath(e),q=!1);else if("o19"==w||"o20"==w)(p=0!==g.length%2)&&!k&&(m=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length= | ||
0,k=!0,u+=h+7>>3;else if("o21"==w)2<g.length&&!k&&(m=g.shift()+d.nominalWidthX,k=!0),r+=g.pop(),n+=g.pop(),q&&f.U.P.closePath(e),f.U.P.moveTo(e,n,r),q=!0;else if("o22"==w)1<g.length&&!k&&(m=g.shift()+d.nominalWidthX,k=!0),n+=g.pop(),q&&f.U.P.closePath(e),f.U.P.moveTo(e,n,r),q=!0;else if("o25"==w){for(;6<g.length;)n+=g.shift(),r+=g.shift(),f.U.P.lineTo(e,n,r);p=n+g.shift();t=r+g.shift();l=p+g.shift();v=t+g.shift();n=l+g.shift();r=v+g.shift();f.U.P.curveTo(e,p,t,l,v,n,r)}else if("o26"==w)for(g.length% | ||
2&&(n+=g.shift());0<g.length;)p=n,t=r+g.shift(),l=p+g.shift(),v=t+g.shift(),n=l,r=v+g.shift(),f.U.P.curveTo(e,p,t,l,v,n,r);else if("o27"==w)for(g.length%2&&(r+=g.shift());0<g.length;)p=n+g.shift(),t=r,l=p+g.shift(),v=t+g.shift(),n=l+g.shift(),r=v,f.U.P.curveTo(e,p,t,l,v,n,r);else if("o10"==w||"o29"==w)p="o10"==w?d:c,0==g.length?console.log("error: empty stack"):(t=g.pop(),p=p.Subrs[t+p.Bias],a.x=n,a.y=r,a.nStems=h,a.haveWidth=k,a.width=m,a.open=q,f.U._drawCFF(p,a,c,d,e),n=a.x,r=a.y,h=a.nStems,k=a.haveWidth, | ||
m=a.width,q=a.open);else if("o30"==w||"o31"==w)for(p=g.length,A=0,w="o31"==w,x=p&-3,A+=p-x;A<x;)w?(p=n+g.shift(),t=r,l=p+g.shift(),v=t+g.shift(),r=v+g.shift(),5==x-A?(n=l+g.shift(),A++):n=l,w=!1):(p=n,t=r+g.shift(),l=p+g.shift(),v=t+g.shift(),n=l+g.shift(),5==x-A?(r=v+g.shift(),A++):r=v,w=!0),f.U.P.curveTo(e,p,t,l,v,n,r),A+=4;else{if("o"==(w+"").charAt(0))throw console.log("Unknown operation: "+w,b),w;g.push(w)}}a.x=n;a.y=r;a.nStems=h;a.haveWidth=k;a.width=m;a.open=q};return f},function(){function l(b, | ||
a){function c(){var a=f.getUint16(k);k+=2;return a}function d(){var a=f.getUint32(k);k+=4;return a}function e(a){x.setUint16(A,a);A+=2}function g(a){x.setUint32(A,a);A+=4}var f=new DataView(b),k=0;d();var m=d();d();var q=c();c();d();c();c();d();d();d();d();d();for(var l=0;Math.pow(2,l)<=q;)l++;l--;for(var n=16*Math.pow(2,l),r=16*q-n,p=12,t=[],y=0;y<q;y++)t.push({tag:d(),offset:d(),compLength:d(),origLength:d(),origChecksum:d()}),p+=16;var v=new Uint8Array(12+16*t.length+t.reduce(function(a,b){return a+ | ||
b.origLength+4},0));y=v.buffer;var x=new DataView(y),A=0;g(m);e(q);e(n);e(l);e(r);t.forEach(function(a){g(a.tag);g(a.origChecksum);g(p);g(a.origLength);a.outOffset=p;p+=a.origLength;0!=p%4&&(p+=4-p%4)});var B;t.forEach(function(c){var d=b.slice(c.offset,c.offset+c.compLength);if(c.compLength!=c.origLength){var e=new Uint8Array(c.origLength);a(new Uint8Array(d,2),e)}else e=new Uint8Array(d);v.set(e,c.outOffset);p=c.outOffset+c.origLength;d=0;0!=p%4&&(d=4-p%4);v.set((new Uint8Array(d)).buffer,c.outOffset+ | ||
c.origLength);B=p+d});return y.slice(0,B)}var f=function(){function b(){this.table=new Uint16Array(16);this.trans=new Uint16Array(288)}function a(a,c){this.source=a;this.bitcount=this.tag=this.sourceIndex=0;this.dest=c;this.destLen=0;this.ltree=new b;this.dtree=new b}function c(a,b,c,d){var e;for(e=0;e<c;++e)a[e]=0;for(e=0;e<30-c;++e)a[e+c]=e/c|0;c=d;for(e=0;30>e;++e)b[e]=c,c+=1<<a[e]}function d(a,b,c,d){var e,g;for(e=0;16>e;++e)a.table[e]=0;for(e=0;e<d;++e)a.table[b[c+e]]++;for(e=g=a.table[0]=0;16> | ||
a,c,d,e,g,f){b.cmds.push("C");b.crds.push(a,c,d,e,g,f)};f.U.P.qcurveTo=function(b,a,c,d,e){b.cmds.push("Q");b.crds.push(a,c,d,e)};f.U.P.closePath=function(b){b.cmds.push("Z")};f.U._drawCFF=function(b,a,c,d,e){for(var g=a.stack,h=a.nStems,k=a.haveWidth,n=a.width,t=a.open,u=0,m=a.x,q=a.y,p,r,l,v,x,z,B,D,E,G,y={val:0,size:0};u<b.length;){f.CFF.getCharString(b,u,y);var w=y.val;u+=y.size;if("o1"==w||"o18"==w)(p=0!==g.length%2)&&!k&&(n=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length=0,k=!0;else if("o3"== | ||
w||"o23"==w)(p=0!==g.length%2)&&!k&&(n=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length=0,k=!0;else if("o4"==w)1<g.length&&!k&&(n=g.shift()+d.nominalWidthX,k=!0),t&&f.U.P.closePath(e),q+=g.pop(),f.U.P.moveTo(e,m,q),t=!0;else if("o5"==w)for(;0<g.length;)m+=g.shift(),q+=g.shift(),f.U.P.lineTo(e,m,q);else if("o6"==w||"o7"==w)for(x=g.length,p="o6"==w,r=0;r<x;r++)l=g.shift(),p?m+=l:q+=l,p=!p,f.U.P.lineTo(e,m,q);else if("o8"==w||"o24"==w){x=g.length;for(z=0;z+6<=x;)p=m+g.shift(),r=q+g.shift(),l=p+g.shift(), | ||
v=r+g.shift(),m=l+g.shift(),q=v+g.shift(),f.U.P.curveTo(e,p,r,l,v,m,q),z+=6;"o24"==w&&(m+=g.shift(),q+=g.shift(),f.U.P.lineTo(e,m,q))}else if("o11"==w)break;else if("o1234"==w||"o1235"==w||"o1236"==w||"o1237"==w)"o1234"==w&&(p=m+g.shift(),r=q,l=p+g.shift(),v=r+g.shift(),E=l+g.shift(),G=v,x=E+g.shift(),z=v,B=x+g.shift(),D=q,m=B+g.shift(),f.U.P.curveTo(e,p,r,l,v,E,G),f.U.P.curveTo(e,x,z,B,D,m,q)),"o1235"==w&&(p=m+g.shift(),r=q+g.shift(),l=p+g.shift(),v=r+g.shift(),E=l+g.shift(),G=v+g.shift(),x=E+g.shift(), | ||
z=G+g.shift(),B=x+g.shift(),D=z+g.shift(),m=B+g.shift(),q=D+g.shift(),g.shift(),f.U.P.curveTo(e,p,r,l,v,E,G),f.U.P.curveTo(e,x,z,B,D,m,q)),"o1236"==w&&(p=m+g.shift(),r=q+g.shift(),l=p+g.shift(),v=r+g.shift(),E=l+g.shift(),G=v,x=E+g.shift(),z=v,B=x+g.shift(),D=z+g.shift(),m=B+g.shift(),f.U.P.curveTo(e,p,r,l,v,E,G),f.U.P.curveTo(e,x,z,B,D,m,q)),"o1237"==w&&(p=m+g.shift(),r=q+g.shift(),l=p+g.shift(),v=r+g.shift(),E=l+g.shift(),G=v+g.shift(),x=E+g.shift(),z=G+g.shift(),B=x+g.shift(),D=z+g.shift(),Math.abs(B- | ||
m)>Math.abs(D-q)?m=B+g.shift():q=D+g.shift(),f.U.P.curveTo(e,p,r,l,v,E,G),f.U.P.curveTo(e,x,z,B,D,m,q));else if("o14"==w)0<g.length&&!k&&(n=g.shift()+c.nominalWidthX,k=!0),4==g.length&&(p=g.shift(),r=g.shift(),v=g.shift(),l=g.shift(),v=f.CFF.glyphBySE(c,v),l=f.CFF.glyphBySE(c,l),f.U._drawCFF(c.CharStrings[v],a,c,d,e),a.x=p,a.y=r,f.U._drawCFF(c.CharStrings[l],a,c,d,e)),t&&(f.U.P.closePath(e),t=!1);else if("o19"==w||"o20"==w)(p=0!==g.length%2)&&!k&&(n=g.shift()+d.nominalWidthX),h+=g.length>>1,g.length= | ||
0,k=!0,u+=h+7>>3;else if("o21"==w)2<g.length&&!k&&(n=g.shift()+d.nominalWidthX,k=!0),q+=g.pop(),m+=g.pop(),t&&f.U.P.closePath(e),f.U.P.moveTo(e,m,q),t=!0;else if("o22"==w)1<g.length&&!k&&(n=g.shift()+d.nominalWidthX,k=!0),m+=g.pop(),t&&f.U.P.closePath(e),f.U.P.moveTo(e,m,q),t=!0;else if("o25"==w){for(;6<g.length;)m+=g.shift(),q+=g.shift(),f.U.P.lineTo(e,m,q);p=m+g.shift();r=q+g.shift();l=p+g.shift();v=r+g.shift();m=l+g.shift();q=v+g.shift();f.U.P.curveTo(e,p,r,l,v,m,q)}else if("o26"==w)for(g.length% | ||
2&&(m+=g.shift());0<g.length;)p=m,r=q+g.shift(),l=p+g.shift(),v=r+g.shift(),m=l,q=v+g.shift(),f.U.P.curveTo(e,p,r,l,v,m,q);else if("o27"==w)for(g.length%2&&(q+=g.shift());0<g.length;)p=m+g.shift(),r=q,l=p+g.shift(),v=r+g.shift(),m=l+g.shift(),q=v,f.U.P.curveTo(e,p,r,l,v,m,q);else if("o10"==w||"o29"==w)p="o10"==w?d:c,0==g.length?console.log("error: empty stack"):(r=g.pop(),p=p.Subrs[r+p.Bias],a.x=m,a.y=q,a.nStems=h,a.haveWidth=k,a.width=n,a.open=t,f.U._drawCFF(p,a,c,d,e),m=a.x,q=a.y,h=a.nStems,k=a.haveWidth, | ||
n=a.width,t=a.open);else if("o30"==w||"o31"==w)for(p=g.length,z=0,w="o31"==w,x=p&-3,z+=p-x;z<x;)w?(p=m+g.shift(),r=q,l=p+g.shift(),v=r+g.shift(),q=v+g.shift(),5==x-z?(m=l+g.shift(),z++):m=l,w=!1):(p=m,r=q+g.shift(),l=p+g.shift(),v=r+g.shift(),m=l+g.shift(),5==x-z?(q=v+g.shift(),z++):q=v,w=!0),f.U.P.curveTo(e,p,r,l,v,m,q),z+=4;else{if("o"==(w+"").charAt(0))throw console.log("Unknown operation: "+w,b),w;g.push(w)}}a.x=m;a.y=q;a.nStems=h;a.haveWidth=k;a.width=n;a.open=t};return f},function(){function l(b, | ||
a){function c(){var a=f.getUint16(k);k+=2;return a}function d(){var a=f.getUint32(k);k+=4;return a}function e(a){x.setUint16(z,a);z+=2}function g(a){x.setUint32(z,a);z+=4}var f=new DataView(b),k=0;d();var n=d();d();var l=c();c();d();c();c();d();d();d();d();d();for(var u=0;Math.pow(2,u)<=l;)u++;u--;for(var m=16*Math.pow(2,u),q=16*l-m,p=12,r=[],A=0;A<l;A++)r.push({tag:d(),offset:d(),compLength:d(),origLength:d(),origChecksum:d()}),p+=16;var v=new Uint8Array(12+16*r.length+r.reduce(function(a,b){return a+ | ||
b.origLength+4},0));A=v.buffer;var x=new DataView(A),z=0;g(n);e(l);e(m);e(u);e(q);r.forEach(function(a){g(a.tag);g(a.origChecksum);g(p);g(a.origLength);a.outOffset=p;p+=a.origLength;0!=p%4&&(p+=4-p%4)});var B;r.forEach(function(c){var d=b.slice(c.offset,c.offset+c.compLength);if(c.compLength!=c.origLength){var e=new Uint8Array(c.origLength);a(new Uint8Array(d,2),e)}else e=new Uint8Array(d);v.set(e,c.outOffset);p=c.outOffset+c.origLength;d=0;0!=p%4&&(d=4-p%4);v.set((new Uint8Array(d)).buffer,c.outOffset+ | ||
c.origLength);B=p+d});return A.slice(0,B)}var f=function(){function b(){this.table=new Uint16Array(16);this.trans=new Uint16Array(288)}function a(a,c){this.source=a;this.bitcount=this.tag=this.sourceIndex=0;this.dest=c;this.destLen=0;this.ltree=new b;this.dtree=new b}function c(a,b,c,d){var e;for(e=0;e<c;++e)a[e]=0;for(e=0;e<30-c;++e)a[e+c]=e/c|0;c=d;for(e=0;30>e;++e)b[e]=c,c+=1<<a[e]}function d(a,b,c,d){var e,g;for(e=0;16>e;++e)a.table[e]=0;for(e=0;e<d;++e)a.table[b[c+e]]++;for(e=g=a.table[0]=0;16> | ||
e;++e)v[e]=g,g+=a.table[e];for(e=0;e<d;++e)b[c+e]&&(a.trans[v[b[c+e]]++]=e)}function e(a,b,c){if(!b)return c;for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var d=a.tag&65535>>>16-b;a.tag>>>=b;a.bitcount-=b;return d+c}function g(a,b){for(;24>a.bitcount;)a.tag|=a.source[a.sourceIndex++]<<a.bitcount,a.bitcount+=8;var c=0,d=0,e=0,g=a.tag;do d=2*d+(g&1),g>>>=1,++e,c+=b.table[e],d-=b.table[e];while(0<=d);a.tag=g;a.bitcount-=e;return b.trans[c+d]}function f(a,b,c){for(;;){var d= | ||
g(a,b);if(256===d)return 0;if(256>d)a.dest[a.destLen++]=d;else{var f;d-=257;d=e(a,q[d],l[d]);var h=g(a,c);for(f=h=a.destLen-e(a,n[h],r[h]);f<h+d;++f)a.dest[a.destLen++]=a.dest[f]}}}var k=new b,m=new b,q=new Uint8Array(30),l=new Uint16Array(30),n=new Uint8Array(30),r=new Uint16Array(30),p=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t=new b,y=new Uint8Array(320),v=new Uint16Array(16);(function(a,b){var c;for(c=0;7>c;++c)a.table[c]=0;a.table[7]=24;a.table[8]=152;a.table[9]=112;for(c= | ||
0;24>c;++c)a.trans[c]=256+c;for(c=0;144>c;++c)a.trans[24+c]=c;for(c=0;8>c;++c)a.trans[168+c]=280+c;for(c=0;112>c;++c)a.trans[176+c]=144+c;for(c=0;5>c;++c)b.table[c]=0;b.table[5]=32;for(c=0;32>c;++c)b.trans[c]=c})(k,m);c(q,l,4,3);c(n,r,2,1);q[28]=0;l[28]=258;return function(b,c){b=new a(b,c);do{c=b;c.bitcount--||(c.tag=c.source[c.sourceIndex++],c.bitcount=7);var h=c.tag&1;c.tag>>>=1;c=h;h=e(b,2,0);switch(h){case 0:for(h=b;8<h.bitcount;)h.sourceIndex--,h.bitcount-=8;var n=h.source[h.sourceIndex+1]; | ||
n=256*n+h.source[h.sourceIndex];var l=h.source[h.sourceIndex+3];l=256*l+h.source[h.sourceIndex+2];if(n!==(~l&65535))h=-3;else{h.sourceIndex+=4;for(l=n;l;--l)h.dest[h.destLen++]=h.source[h.sourceIndex++];h=h.bitcount=0}break;case 1:h=f(b,k,m);break;case 2:var q;n=b;var r=b.ltree,u=b.dtree;l=e(n,5,257);h=e(n,5,1);var v=e(n,4,4);for(q=0;19>q;++q)y[q]=0;for(q=0;q<v;++q){var x=e(n,3,0);y[p[q]]=x}d(t,y,0,19);for(q=0;q<l+h;)switch(v=g(n,t),v){case 16:x=y[q-1];for(v=e(n,2,3);v;--v)y[q++]=x;break;case 17:for(v= | ||
e(n,3,3);v;--v)y[q++]=0;break;case 18:for(v=e(n,7,11);v;--v)y[q++]=0;break;default:y[q++]=v}d(r,y,0,l);d(u,y,l,h);h=f(b,b.ltree,b.dtree);break;default:h=-3}if(0!==h)throw Error("Data error");}while(!c);return b.destLen<b.dest.length?"function"===typeof b.dest.slice?b.dest.slice(0,b.destLen):b.dest.subarray(0,b.destLen):b.dest}}();return function(b){return l(b,f)}},function(l,f){function b(b){var d=b[0],g=Object.create(null),f={unitsPerEm:d.head.unitsPerEm,ascender:d.hhea.ascender,descender:d.hhea.descender, | ||
forEachGlyph:function(b,e,h,u){var k=0,m=1/f.unitsPerEm*e;l.U.stringToGlyphs(d,b).forEach(function(b){if(-1!==b){var f=g[b];if(!f){f=l.glyf._parseGlyf(d,b)||{xMin:0,xMax:0,yMin:0,yMax:0};var n=l.U.glyphToPath(d,b),q=n.cmds,p=n.crds;f=g[b]={index:b,unicode:a(d,b),advanceWidth:d.hmtx.aWidth[b],xMin:f.xMin,yMin:f.yMin,xMax:f.xMax,yMax:f.yMax,pathCommandCount:q.length,forEachPathCommand:function(a){for(var b=0,d=[],e=0,g=q.length;e<g;e++){var f=c[q[e]];d.length=1+f;d[0]=q[e];for(var h=1;h<=f;h++)d[h]= | ||
p[b++];a.apply(null,d)}}}}u.call(null,f,k);f.advanceWidth&&(k+=f.advanceWidth*m);h&&(k+=h*e)}});return k}};return f}function a(a,b){var c=a.glyphToUnicodeMap;if(!c){c=a.glyphToUnicodeMap=Object.create(null);var d=a.cmap,e=-1;null!=d.p0e4?e=d.p0e4:null!=d.p3e1?e=d.p3e1:null!=d.p1e0?e=d.p1e0:null!=d.p0e3&&(e=d.p0e3);if(-1===e)throw"no familiar platform and encoding!";e=d.tables[e];if(0===e.format)for(a=0;a<e.map.length;a++)c[e.map[a]]=a;else if(4===e.format){d=e.startCount;e=e.endCount;for(var f=0;f< | ||
d.length;f++)for(var q=d[f];q<=e[f];q++)c[l.U.codeToGlyph(a,q)]=q}else if(12===e.format)e.groups.forEach(function(a){var b=a[1],d=a[2];for(a=a[0];a<=b;a++)c[d++]=a});else throw"unknown cmap table format "+e.format;}return c[b]||0}var c={M:2,L:2,Q:4,C:6,Z:0};return function(a){var c=new Uint8Array(a,0,4);c=l._bin.readASCII(c,0,4);if("wOFF"===c)a=f(a);else if("wOF2"===c)throw Error("woff2 fonts not supported");return b(l.parse(a))}}],init:function(l,f,b){l=l();f=f();return b(l,f)}}),I={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff", | ||
g(a,b);if(256===d)return 0;if(256>d)a.dest[a.destLen++]=d;else{var f;d-=257;d=e(a,l[d],u[d]);var h=g(a,c);for(f=h=a.destLen-e(a,m[h],q[h]);f<h+d;++f)a.dest[a.destLen++]=a.dest[f]}}}var k=new b,n=new b,l=new Uint8Array(30),u=new Uint16Array(30),m=new Uint8Array(30),q=new Uint16Array(30),p=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new b,A=new Uint8Array(320),v=new Uint16Array(16);(function(a,b){var c;for(c=0;7>c;++c)a.table[c]=0;a.table[7]=24;a.table[8]=152;a.table[9]=112;for(c= | ||
0;24>c;++c)a.trans[c]=256+c;for(c=0;144>c;++c)a.trans[24+c]=c;for(c=0;8>c;++c)a.trans[168+c]=280+c;for(c=0;112>c;++c)a.trans[176+c]=144+c;for(c=0;5>c;++c)b.table[c]=0;b.table[5]=32;for(c=0;32>c;++c)b.trans[c]=c})(k,n);c(l,u,4,3);c(m,q,2,1);l[28]=0;u[28]=258;return function(b,c){b=new a(b,c);do{c=b;c.bitcount--||(c.tag=c.source[c.sourceIndex++],c.bitcount=7);var h=c.tag&1;c.tag>>>=1;c=h;h=e(b,2,0);switch(h){case 0:for(h=b;8<h.bitcount;)h.sourceIndex--,h.bitcount-=8;var m=h.source[h.sourceIndex+1]; | ||
m=256*m+h.source[h.sourceIndex];var l=h.source[h.sourceIndex+3];l=256*l+h.source[h.sourceIndex+2];if(m!==(~l&65535))h=-3;else{h.sourceIndex+=4;for(l=m;l;--l)h.dest[h.destLen++]=h.source[h.sourceIndex++];h=h.bitcount=0}break;case 1:h=f(b,k,n);break;case 2:var q;m=b;var t=b.ltree,u=b.dtree;l=e(m,5,257);h=e(m,5,1);var v=e(m,4,4);for(q=0;19>q;++q)A[q]=0;for(q=0;q<v;++q){var x=e(m,3,0);A[p[q]]=x}d(r,A,0,19);for(q=0;q<l+h;)switch(v=g(m,r),v){case 16:x=A[q-1];for(v=e(m,2,3);v;--v)A[q++]=x;break;case 17:for(v= | ||
e(m,3,3);v;--v)A[q++]=0;break;case 18:for(v=e(m,7,11);v;--v)A[q++]=0;break;default:A[q++]=v}d(t,A,0,l);d(u,A,l,h);h=f(b,b.ltree,b.dtree);break;default:h=-3}if(0!==h)throw Error("Data error");}while(!c);return b.destLen<b.dest.length?"function"===typeof b.dest.slice?b.dest.slice(0,b.destLen):b.dest.subarray(0,b.destLen):b.dest}}();return function(b){return l(b,f)}},function(l,f){function b(b){var d=b[0],g=Object.create(null),f={unitsPerEm:d.head.unitsPerEm,ascender:d.hhea.ascender,descender:d.hhea.descender, | ||
forEachGlyph:function(b,e,h,u){var k=0,n=1/f.unitsPerEm*e;l.U.stringToGlyphs(d,b).forEach(function(b){if(-1!==b){var f=g[b];if(!f){f=l.glyf._parseGlyf(d,b)||{xMin:0,xMax:0,yMin:0,yMax:0};var m=l.U.glyphToPath(d,b),q=m.cmds,p=m.crds;f=g[b]={index:b,unicode:a(d,b),advanceWidth:d.hmtx.aWidth[b],xMin:f.xMin,yMin:f.yMin,xMax:f.xMax,yMax:f.yMax,pathCommandCount:q.length,forEachPathCommand:function(a){for(var b=0,d=[],e=0,g=q.length;e<g;e++){var f=c[q[e]];d.length=1+f;d[0]=q[e];for(var h=1;h<=f;h++)d[h]= | ||
p[b++];a.apply(null,d)}}}}u.call(null,f,k);f.advanceWidth&&(k+=f.advanceWidth*n);h&&(k+=h*e)}});return k}};return f}function a(a,b){var c=a.glyphToUnicodeMap;if(!c){c=a.glyphToUnicodeMap=Object.create(null);var d=a.cmap,e=-1;null!=d.p0e4?e=d.p0e4:null!=d.p3e1?e=d.p3e1:null!=d.p1e0?e=d.p1e0:null!=d.p0e3&&(e=d.p0e3);if(-1===e)throw"no familiar platform and encoding!";e=d.tables[e];if(0===e.format)for(a=0;a<e.map.length;a++)c[e.map[a]]=a;else if(4===e.format){d=e.startCount;e=e.endCount;for(var f=0;f< | ||
d.length;f++)for(var t=d[f];t<=e[f];t++)c[l.U.codeToGlyph(a,t)]=t}else if(12===e.format)e.groups.forEach(function(a){var b=a[1],d=a[2];for(a=a[0];a<=b;a++)c[d++]=a});else throw"unknown cmap table format "+e.format;}return c[b]||0}var c={M:2,L:2,Q:4,C:6,Z:0};return function(a){var c=new Uint8Array(a,0,4);c=l._bin.readASCII(c,0,4);if("wOFF"===c)a=f(a);else if("wOF2"===c)throw Error("woff2 fonts not supported");return b(l.parse(a))}}],init:function(l,f,b){l=l();f=f();return b(l,f)}}),I={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff", | ||
sdfGlyphSize:64},L=document.createElement("a"),M=Object.create(null);H=F.defineWorkerModule({dependencies:[I,.125,H,function(l){function f(a){return a*a}var b=l.sdfTextureSize,a=l.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,f){this._insertSegment({x0:a,y0:b,x1:c,y1:f,cx:(a+c)/2,cy:(b+f)/2,minX:Math.min(a,c),minY:Math.min(b,f),maxX:Math.max(a,c),maxY:Math.max(b,f),next:null},this._root)};c.prototype._insertSegment=function(a,b){var c=a.minX,d=a.minY,e=a.maxX,f=a.maxY,q=a.cx,l=a.cy;c<b.minX&&(b.minX=c);d<b.minY&&(b.minY=d);e>b.maxX&&(b.maxX=e);f>b.maxY&&(b.maxY=f);var n=b.data;if(n)if(n.cx===q&&n.cy===l){for(;n.next;)n=n.next;n.next=a}else b.data=null,this._insertSegment(n,b),this._insertSegment(a,b);else q=(l<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:f}};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 g=b,h=c.x0,k=c.y0,l=c.x1-h,p=c.y1-k,t=l*l+p*p;t=t?Math.max(0,Math.min(1,((e-h)*l+(g-k)*p)/t)):0;e=Math.sqrt(f(e-(h+t*l))+f(g-(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,g=d.y0,f=d.x1,h=d.y1;g>b!==h>b&&a<(f-e)*(b-g)/(h-g)+ | ||
e&&(c=!c)}});return c};return function(d){var e=new Uint8Array(b*b),g=d.xMax-d.xMin,f=d.yMax-d.yMin,k=Math.max(g,f)*a,m=(g+2*k)/b,l=(f+2*k)/b;f=d.xMin-k-m;g=d.yMin-k-l;m=d.xMax+k+m;l=d.yMax+k+l;if(d.pathCommandCount){var u=new c(d),n,r,p,t;d.forEachPathCommand(function(a,b,c,d,e,g,f){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":g={x:p,y:t};for(f=1;16>f;f++){a=f/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(g.x, | ||
g.y,a.x,a.y);g=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*g,y:l*l*l*t+3*l*l*k*c+3*l*k*k*e+k*k*k*f};u.addLineSegment(a.x,a.y,k.x,k.y);a=k}p=g;t=f;break;case "Z":p===n&&t===r||u.addLineSegment(p,t,n,r)}});for(d=0;d<b;d++)for(var y=0;y<b;y++){var v=u.findNearestSignedDistance(f+(m-f)*(d+.5)/b,g+(l-g)*(y+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[y*b+d]=v}}return{textureData:e,renderingBounds:[f, | ||
g,m,l]}}},function(l,f,b){function a(a,b){function c(){var d=function(b){console.error("Failure loading font "+a+(a===g?"":"; trying fallback"),b);a!==g&&(a=g,c())};try{var e=new XMLHttpRequest;e.open("get",a,!0);e.responseType="arraybuffer";e.onload=function(){try{var a=l(e.response);b(a)}catch(p){d(p)}};e.onerror=d;e.send()}catch(r){d(r)}}c()}function c(b,c){b||(b=g);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=g);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=g);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 z=a.anchor;void 0===c&&(c=!1); | ||
d(h,function(a){var d=a.fontObj,g=isFinite(q),h=null,n=null,p=null,r=null,t=0,u=0,y="nowrap"!==x,B=k/d.unitsPerEm;"normal"===m&&(m=(d.ascender-d.descender)/d.unitsPerEm);m*=k;var C=(m-(d.ascender-d.descender)*B)/2,D=e.split(/\r?\n/).map(function(a){var b=0,c=[],e=[c];d.forEachGlyph(a,k,l,function(a,d){var f=a.unicode;f="number"===typeof f&&String.fromCharCode(f);var h=a.advanceWidth*B,k=!!f&&/\s/.test(f);if(y&&g&&!k&&d+h+b>q&&c.length){if(c[c.length-1].isWhitespace){var l=[];b=-d}else for(var m=c.length;m--;)if(0=== | ||
m&&"break-word"===A){l=[];b=-d;break}else if(c[m].isWhitespace){l=c.splice(m+1);m=l[0].x;b-=m;for(var n=0;n<l.length;n++)l[n].x-=m;break}if(l){for(;c[c.length-1].isWhitespace;)c.pop();e.push(c=l);u=q}}c.push({glyphObj:a,x:d+b,y:0,width:h,char:f,isWhitespace:k,isEmpty:a.xMin===a.xMax||a.yMin===a.yMax,atlasInfo:null})});for(a=0;a<e.length&&u<q;a++){var f=e[a];f.length&&(f=f[f.length-1],u=Math.max(u,f.x+f.width))}t+=e.length;return e});if(!c){var F=[],I=-(k+C);D.forEach(function(b){for(var c=0;c<b.length;c++){var d= | ||
b[c];if(d.length){var e=0,g=d[d.length-1];g=g.x+g.width;var k=0;if("center"===v)e=(u-g)/2;else if("right"===v)e=u-g;else if("justify"===v)for(var l=0,n=d.length;l<n;l++)d[l].isWhitespace&&k++;l=0;for(n=d.length;l<n;l++){var p=d[l];p.isWhitespace&&"justify"===v&&c!==b.length-1&&(e+=(u-g)/k);if(!p.isWhitespace&&!p.isEmpty){var q=p.glyphObj,r=a.glyphs[q.index];r||(r=f(q),r.atlasIndex=a.glyphCount++,h||(h=[]),h.push(r),r=a.glyphs[q.index]={atlasIndex:r.atlasIndex,glyphObj:q,renderingBounds:r.renderingBounds}); | ||
p.atlasInfo=r;e&&(p.x+=e);p.y=I;F.push(p)}}}I-=m}});var H=0,J=0;z&&(z[0]&&(H=-u*z[0]),z[1]&&(J=t*m*z[1]));n=new Float32Array(4*F.length);p=new Float32Array(F.length);r=[Infinity,Infinity,-Infinity,-Infinity];F.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=n[4*b]=a.x+d[0]*B+H,g=n[4*b+1]=a.y+d[1]*B+J,f=n[4*b+2]=a.x+d[2]*B+H;a=n[4*b+3]=a.y+d[3]*B+J;e<r[0]&&(r[0]=e);g<r[1]&&(r[1]=g);f>r[2]&&(r[2]=f);a>r[3]&&(r[3]=a);p[b]=c})}b({glyphBounds:n,glyphIndices:p,totalBounds:r, | ||
totalBlockSize:[u,t*m],newGlyphSDFs:h})})}var g=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]})},!0)},loadFont:c}}],init:function(l,f,b,a,c){f=a({sdfTextureSize:l.sdfGlyphSize,sdfDistancePercent:f});return c(b,f,{defaultFontUrl:l.defaultFontURL})}});var U=F.defineWorkerModule({dependencies:[H,F.ThenableWorkerModule],init:function(l,f){return function(b){var a=new f;l.process(b,a.resolve);return a}}, | ||
getTransferables:function(l){var f=[l.glyphBounds.buffer,l.glyphIndices.buffer];l.newGlyphSDFs&&l.newGlyphSDFs.forEach(function(b){f.push(b.textureData.buffer)});return f}}),V=(new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),W=new z.Vector3,O=function(l){function f(){l.call(this);this.copy(V);this.addAttribute("aTroikaGlyphBounds",new z.InstancedBufferAttribute(new Float32Array(0),4));this.addAttribute("aTroikaGlyphIndex",new z.InstancedBufferAttribute(new Float32Array(0),1));this.boundingSphere= | ||
new z.Sphere}l&&(f.__proto__=l);f.prototype=Object.create(l&&l.prototype);f.prototype.constructor=f;f.prototype.computeBoundingSphere=function(){};f.prototype.updateGlyphs=function(b,a,c){N(this.attributes.aTroikaGlyphBounds,b);N(this.attributes.aTroikaGlyphIndex,a);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(W.set(c[0],c[1],0))};return f}(z.InstancedBufferGeometry),P=new z.MeshBasicMaterial({color:16777215,side:z.DoubleSide, | ||
transparent:!0}),X=Object.freeze([0,0,0,0]),Y=new z.Matrix4,Q=new z.Mesh((new z.PlaneBufferGeometry(1,1)).translate(.5,.5,0),P),J=function(l){function f(a){a=new O;l.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.debugSDF=!1}l&&(f.__proto__=l);f.prototype=Object.create(l&& | ||
b,c,f){this._insertSegment({x0:a,y0:b,x1:c,y1:f,cx:(a+c)/2,cy:(b+f)/2,minX:Math.min(a,c),minY:Math.min(b,f),maxX:Math.max(a,c),maxY:Math.max(b,f),next:null},this._root)};c.prototype._insertSegment=function(a,b){var c=a.minX,d=a.minY,e=a.maxX,f=a.maxY,l=a.cx,u=a.cy;c<b.minX&&(b.minX=c);d<b.minY&&(b.minY=d);e>b.maxX&&(b.maxX=e);f>b.maxY&&(b.maxY=f);var m=b.data;if(m)if(m.cx===l&&m.cy===u){for(;m.next;)m=m.next;m.next=a}else b.data=null,this._insertSegment(m,b),this._insertSegment(a,b);else l=(u<b.cy? | ||
0:2)+(l<b.cx?0:1),b[l]?this._insertSegment(a,b[l]):b[l]={0:null,1:null,2:null,3:null,data:a,cx:b.cx+b.r/2*(l%2?1:-1),cy:b.cy+b.r/2*(2>l?-1:1),r:b.r/2,minX:c,minY:d,maxX:e,maxY:f}};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 g=b,h=c.x0,k=c.y0,l=c.x1-h,p=c.y1-k,r=l*l+p*p;r=r?Math.max(0,Math.min(1,((e-h)*l+(g-k)*p)/r)):0;e=Math.sqrt(f(e-(h+r*l))+f(g-(k+r*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,g=d.y0,f=d.x1,h=d.y1;g>b!==h>b&&a<(f-e)*(b-g)/(h-g)+ | ||
e&&(c=!c)}});return c};return function(d){var e=new Uint8Array(b*b),g=d.xMax-d.xMin,f=d.yMax-d.yMin,k=Math.max(g,f)*a,l=(g+2*k)/b,t=(f+2*k)/b;f=d.xMin-k-l;g=d.yMin-k-t;l=d.xMax+k+l;t=d.yMax+k+t;if(d.pathCommandCount){var u=new c(d),m,q,p,r;d.forEachPathCommand(function(a,b,c,d,e,g,f){switch(a){case "M":p=m=b;r=q=c;break;case "L":b===p&&c===r||u.addLineSegment(p,r,p=b,r=c);break;case "Q":g={x:p,y:r};for(f=1;16>f;f++){a=f/15;var h=1-a;a={x:h*h*p+2*h*a*b+a*a*d,y:h*h*r+2*h*a*c+a*a*e};u.addLineSegment(g.x, | ||
g.y,a.x,a.y);g=a}p=d;r=e;break;case "C":a={x:p,y:r};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*g,y:l*l*l*r+3*l*l*k*c+3*l*k*k*e+k*k*k*f};u.addLineSegment(a.x,a.y,k.x,k.y);a=k}p=g;r=f;break;case "Z":p===m&&r===q||u.addLineSegment(p,r,m,q)}});for(d=0;d<b;d++)for(var A=0;A<b;A++){var v=u.findNearestSignedDistance(f+(l-f)*(d+.5)/b,g+(t-g)*(A+.5)/b,k);v=isFinite(v)?Math.round(127.5*(1+v/k)):v;v=Math.max(0,Math.min(255,v));e[A*b+d]=v}}return{textureData:e,renderingBounds:[f, | ||
g,l,t]}}},function(l,f,b){function a(a,b){function c(){var d=function(b){console.error("Failure loading font "+a+(a===g?"":"; trying fallback"),b);a!==g&&(a=g,c())};try{var e=new XMLHttpRequest;e.open("get",a,!0);e.responseType="arraybuffer";e.onload=function(){try{var a=l(e.response);b(a)}catch(p){d(p)}};e.onerror=d;e.send()}catch(q){d(q)}}c()}function c(b,c){b||(b=g);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=g);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=g);var k=a.fontSize;void 0===k&&(k=1);var l=a.letterSpacing;void 0===l&&(l=0);var n=a.lineHeight;void 0===n&&(n="normal");var t=a.maxWidth;void 0===t&&(t=Infinity);var v=a.textAlign;void 0===v&&(v="left");var x=a.whiteSpace;void 0===x&&(x="normal");var z=a.overflowWrap;void 0===z&&(z="normal");var y=a.anchor;void 0===c&&(c=!1); | ||
d(h,function(a){var d=a.fontObj,g=isFinite(t),h=null,m=null,p=null,q=null,r=0,u=0,A="nowrap"!==x,B=k/d.unitsPerEm;"normal"===n&&(n=(d.ascender-d.descender)/d.unitsPerEm);n*=k;var C=(n-(d.ascender-d.descender)*B)/2,D=e.split(/\r?\n/).map(function(a){var b=0,c=[],e=[c];d.forEachGlyph(a,k,l,function(a,d){var f=a.unicode;f="number"===typeof f&&String.fromCharCode(f);var h=a.advanceWidth*B,k=!!f&&/\s/.test(f);if(A&&g&&!k&&d+h+b>t&&c.length){if(c[c.length-1].isWhitespace){var l=[];b=-d}else for(var m=c.length;m--;)if(0=== | ||
m&&"break-word"===z){l=[];b=-d;break}else if(c[m].isWhitespace){l=c.splice(m+1);m=l[0].x;b-=m;for(var n=0;n<l.length;n++)l[n].x-=m;break}if(l){for(;c[c.length-1].isWhitespace;)c.pop();e.push(c=l);u=t}}c.push({glyphObj:a,x:d+b,y:0,width:h,char:f,isWhitespace:k,isEmpty:a.xMin===a.xMax||a.yMin===a.yMax,atlasInfo:null})});for(a=0;a<e.length&&u<t;a++){var f=e[a];f.length&&(f=f[f.length-1],u=Math.max(u,f.x+f.width))}r+=e.length;return e});if(!c){var F=[],I=-(k+C);D.forEach(function(b){for(var c=0;c<b.length;c++){var d= | ||
b[c];if(d.length){var e=0,g=d[d.length-1];g=g.x+g.width;var k=0;if("center"===v)e=(u-g)/2;else if("right"===v)e=u-g;else if("justify"===v)for(var l=0,m=d.length;l<m;l++)d[l].isWhitespace&&k++;l=0;for(m=d.length;l<m;l++){var p=d[l];p.isWhitespace&&"justify"===v&&c!==b.length-1&&(e+=(u-g)/k);if(!p.isWhitespace&&!p.isEmpty){var q=p.glyphObj,r=a.glyphs[q.index];r||(r=f(q),r.atlasIndex=a.glyphCount++,h||(h=[]),h.push(r),r=a.glyphs[q.index]={atlasIndex:r.atlasIndex,glyphObj:q,renderingBounds:r.renderingBounds}); | ||
p.atlasInfo=r;e&&(p.x+=e);p.y=I;F.push(p)}}}I-=n}});var H=0,J=0;y&&(y[0]&&(H=-u*y[0]),y[1]&&(J=r*n*y[1]));m=new Float32Array(4*F.length);p=new Float32Array(F.length);q=[Infinity,Infinity,-Infinity,-Infinity];F.forEach(function(a,b){var c=a.atlasInfo,d=c.renderingBounds;c=c.atlasIndex;var e=m[4*b]=a.x+d[0]*B+H,g=m[4*b+1]=a.y+d[1]*B+J,f=m[4*b+2]=a.x+d[2]*B+H;a=m[4*b+3]=a.y+d[3]*B+J;e<q[0]&&(q[0]=e);g<q[1]&&(q[1]=g);f>q[2]&&(q[2]=f);a>q[3]&&(q[3]=a);p[b]=c})}b({glyphBounds:m,glyphIndices:p,totalBounds:q, | ||
totalBlockSize:[u,r*n],newGlyphSDFs:h})})}var g=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]})},!0)},loadFont:c}}],init:function(l,f,b,a,c){f=a({sdfTextureSize:l.sdfGlyphSize,sdfDistancePercent:f});return c(b,f,{defaultFontUrl:l.defaultFontURL})}});var U=F.defineWorkerModule({dependencies:[H,F.ThenableWorkerModule],init:function(l,f){return function(b){var a=new f;l.process(b,a.resolve);return a}}, | ||
getTransferables:function(l){var f=[l.glyphBounds.buffer,l.glyphIndices.buffer];l.newGlyphSDFs&&l.newGlyphSDFs.forEach(function(b){f.push(b.textureData.buffer)});return f}}),W=(new y.PlaneBufferGeometry(1,1)).translate(.5,.5,0),X=new y.Vector3,O=function(l){function f(){l.call(this);this.copy(W);this.addAttribute("aTroikaGlyphBounds",new y.InstancedBufferAttribute(new Float32Array(0),4));this.addAttribute("aTroikaGlyphIndex",new y.InstancedBufferAttribute(new Float32Array(0),1));this.boundingSphere= | ||
new y.Sphere}l&&(f.__proto__=l);f.prototype=Object.create(l&&l.prototype);f.prototype.constructor=f;f.prototype.computeBoundingSphere=function(){};f.prototype.updateGlyphs=function(b,a,c){N(this.attributes.aTroikaGlyphBounds,b);N(this.attributes.aTroikaGlyphIndex,a);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(X.set(c[0],c[1],0))};return f}(y.InstancedBufferGeometry),P=new y.MeshBasicMaterial({color:16777215,side:y.DoubleSide, | ||
transparent:!0}),Y=Object.freeze([0,0,0,0]),Z=new y.Matrix4,Q=new y.Mesh((new y.PlaneBufferGeometry(1,1)).translate(.5,.5,0),P),J=function(l){function f(a){a=new O;l.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.debugSDF=!1}l&&(f.__proto__=l);f.prototype=Object.create(l&& | ||
l.prototype);f.prototype.constructor=f;var b={material:{configurable:!0}};f.prototype.sync=function(a){var b=this;this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(a):(this._isSyncing=!0,T({text:this.text,font:this.font,fontSize:this.fontSize,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,maxWidth:this.maxWidth,textAlign:this.textAlign,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchor:this.anchor},function(c){b._isSyncing= | ||
!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphIndices,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()})))};f.prototype.onBeforeRender=function(){this.sync();this._prepareMaterial()};f.prototype.dispose=function(){var a=this._derivedMaterial;a&&a.dispose();this.geometry.dispose()};b.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||P;a&&a.baseMaterial===b||(a&& | ||
a.dispose(),a=R.createDerivedMaterial(b,{extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFMinDistancePct:{value:0},uTroikaGlyphVSize:{value:0},uTroikaTotalBounds:{value:new z.Vector4},uTroikaClipRect:{value:new z.Vector4},uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaTotalBounds;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n",vertexTransform:"\nvTroikaGlyphUV = vec2(\n position.x,\n uTroikaGlyphVSize * (aTroikaGlyphIndex + position.y)\n);\n\nposition = vec3(\n position.x == 1.0 ? aTroikaGlyphBounds.z : aTroikaGlyphBounds.x,\n position.y == 1.0 ? aTroikaGlyphBounds.w : aTroikaGlyphBounds.y,\n 0.0\n);\nvTroikaLocalPos = vec3(position);\n\nuv = vec2(\n (position.x - uTroikaTotalBounds.x) / (uTroikaTotalBounds.z - uTroikaTotalBounds.x),\n (position.y - uTroikaTotalBounds.y) / (uTroikaTotalBounds.w - uTroikaTotalBounds.y)\n);\n", | ||
fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform float uTroikaSDFMinDistancePct;\nuniform bool uTroikaSDFDebug;\nuniform float uTroikaGlyphVSize;\nuniform vec4 uTroikaClipRect;\nvarying vec2 vTroikaGlyphUV;\nvarying vec3 vTroikaLocalPos;\n\nvoid troikaApplyClipping() {\n vec4 rect = uTroikaClipRect;\n vec3 pos = vTroikaLocalPos;\n if (rect != vec4(.0,.0,.0,.0) && (\n pos.x < min(rect.x, rect.z) || \n pos.y < min(rect.y, rect.w) ||\n pos.x > max(rect.x, rect.z) ||\n pos.y > max(rect.y, rect.w)\n )) {\n discard;\n }\n}\n", | ||
fragmentColorTransform:"\ntroikaApplyClipping();\n\nfloat troikaSDFValue = texture2D(uTroikaSDFTexture, vTroikaGlyphUV).r;\n\n\n#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n float troikaAntiAliasDist = min(\n 0.5,\n 0.5 * min(\n fwidth(vTroikaGlyphUV.x), \n fwidth(vTroikaGlyphUV.y / uTroikaGlyphVSize)\n )\n ) / uTroikaSDFMinDistancePct;\n#else\n float troikaAntiAliasDist = 0.01;\n#endif\n\nfloat textAlphaMult = uTroikaSDFDebug ? troikaSDFValue : smoothstep(\n 0.5 - troikaAntiAliasDist,\n 0.5 + troikaAntiAliasDist,\n troikaSDFValue\n);\nif (textAlphaMult == 0.0) {\n if (uTroikaSDFDebug) {\n gl_FragColor *= 0.5;\n } else {\n discard;\n }\n} else {\n gl_FragColor.a *= textAlphaMult;\n}\n"}), | ||
a.transparent=!0,a=this._derivedMaterial=a);return a};b.material.set=function(a){this._baseMaterial=a};f.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=this._textRenderInfo,d=a.uniforms;if(b){var e=b.sdfTexture;d.uTroikaSDFTexture.value=e;d.uTroikaSDFMinDistancePct.value=b.sdfMinDistancePercent;d.uTroikaGlyphVSize.value=e.image.width/e.image.height;d.uTroikaTotalBounds.value.fromArray(b.totalBounds)}d.uTroikaSDFDebug.value=!!this.debugSDF;(b=this.clipRect)&&Array.isArray(b)&& | ||
4===b.length||(b=X);d.uTroikaClipRect.value.fromArray(b);a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;d=this.color;null!=d&&a.color&&a.color.isColor&&d!==a._troikaColor&&a.color.set(a._troikaColor=d)};f.prototype.raycast=function(a,b){var c=this._textRenderInfo;c&&(c=c.totalBounds,Q.matrixWorld.multiplyMatrices(this.matrixWorld,Y.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)),Q.raycast(a,b))};Object.defineProperties(f.prototype,b); | ||
return f}(z.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(l){var f="_private_"+l;Object.defineProperty(J.prototype,l,{get:function(){return this[f]},set:"anchor"===l?function(b){JSON.stringify(b)!==JSON.stringify(this[f])&&(this[f]=b,this._needsSync=!0)}:function(b){b!==this[f]&&(this[f]=b,this._needsSync=!0)}})});var Z="text anchor font fontSize letterSpacing lineHeight maxWidth overflowWrap textAlign whiteSpace material color depthOffset clipRect debugSDF".split(" "); | ||
F=function(l){function f(b){var a=new J;a.geometry.boundingSphere.version=0;l.call(this,b,a)}l&&(f.__proto__=l);f.prototype=Object.create(l&&l.prototype);f.prototype.constructor=f;f.prototype.afterUpdate=function(){var b=this,a=this.threeObject;Z.forEach(function(c){a[c]=b[c]});a.sync(function(){b.isDestroying||(a.geometry.boundingSphere.version++,b.notifyWorld("needsRender"))});l.prototype.afterUpdate.call(this)};f.prototype.destructor=function(){this.threeObject.dispose();l.prototype.destructor.call(this)}; | ||
!1;b._textRenderInfo=c;b.geometry.updateGlyphs(c.glyphBounds,c.glyphIndices,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()})))};f.prototype.onBeforeRender=function(){this.sync();this._prepareMaterial()};f.prototype.dispose=function(){this.geometry.dispose()};b.material.get=function(){var a=this._derivedMaterial,b=this._baseMaterial||P;a&&a.baseMaterial===b||(a&&a.dispose(),a=this._derivedMaterial=V(b),b.addEventListener("dispose", | ||
function e(){b.removeEventListener("dispose",e);a.dispose()}));return a};b.material.set=function(a){this._baseMaterial=a};f.prototype._prepareMaterial=function(){var a=this._derivedMaterial,b=this._textRenderInfo,d=a.uniforms;if(b){var e=b.sdfTexture;d.uTroikaSDFTexture.value=e;d.uTroikaSDFMinDistancePct.value=b.sdfMinDistancePercent;d.uTroikaGlyphVSize.value=e.image.width/e.image.height;d.uTroikaTotalBounds.value.fromArray(b.totalBounds)}d.uTroikaSDFDebug.value=!!this.debugSDF;(b=this.clipRect)&& | ||
Array.isArray(b)&&4===b.length||(b=Y);d.uTroikaClipRect.value.fromArray(b);a.polygonOffset=!!this.depthOffset;a.polygonOffsetFactor=a.polygonOffsetUnits=this.depthOffset||0;d=this.color;null!=d&&a.color&&a.color.isColor&&d!==a._troikaColor&&a.color.set(a._troikaColor=d)};f.prototype.raycast=function(a,b){var c=this._textRenderInfo;c&&(c=c.totalBounds,Q.matrixWorld.multiplyMatrices(this.matrixWorld,Z.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)),Q.raycast(a,b))};Object.defineProperties(f.prototype, | ||
b);return f}(y.Mesh);"font fontSize letterSpacing lineHeight maxWidth overflowWrap text textAlign whiteSpace anchor".split(" ").forEach(function(l){var f="_private_"+l;Object.defineProperty(J.prototype,l,{get:function(){return this[f]},set:"anchor"===l?function(b){JSON.stringify(b)!==JSON.stringify(this[f])&&(this[f]=b,this._needsSync=!0)}:function(b){b!==this[f]&&(this[f]=b,this._needsSync=!0)}})});var aa="text anchor font fontSize letterSpacing lineHeight maxWidth overflowWrap textAlign whiteSpace material color depthOffset clipRect debugSDF".split(" "); | ||
F=function(l){function f(b){var a=new J;a.geometry.boundingSphere.version=0;l.call(this,b,a)}l&&(f.__proto__=l);f.prototype=Object.create(l&&l.prototype);f.prototype.constructor=f;f.prototype.afterUpdate=function(){var b=this,a=this.threeObject;aa.forEach(function(c){a[c]=b[c]});a.sync(function(){b.isDestroying||(a.geometry.boundingSphere.version++,b.notifyWorld("needsRender"))});l.prototype.afterUpdate.call(this)};f.prototype.destructor=function(){this.threeObject.dispose();l.prototype.destructor.call(this)}; | ||
return f}(S.Object3DFacade);C.GlyphsGeometry=O;C.Text3DFacade=F;C.TextMesh=J;C.configureTextBuilder=function(l){K(I,l)};C.fontProcessorWorkerModule=H;Object.defineProperty(C,"__esModule",{value:!0})}); |
{ | ||
"name": "troika-3d-text", | ||
"version": "0.15.1", | ||
"version": "0.15.2", | ||
"description": "Troika 3D Text", | ||
@@ -18,3 +18,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"dependencies": { | ||
"troika-3d": "^0.15.1", | ||
"troika-3d": "^0.15.2", | ||
"troika-three-utils": "^0.15.0", | ||
@@ -31,3 +31,3 @@ "troika-worker-utils": "^0.15.0" | ||
}, | ||
"gitHead": "9e264ced7fdda3f3990d1519880f313566be1016" | ||
"gitHead": "4aa524eaf811d2b25048fbaa4bafd5e9a3074b96" | ||
} |
169
README.md
# `troika-3d-text` | ||
> TODO: description | ||
This package provides high quality text rendering in 3D scenes, using signed distance fields (SDF) and antialiasing using standard derivatives. | ||
Rather than relying on pre-generated SDF textures, this parses font files (.ttf, .otf, .woff) directly using [Typr.js](https://github.com/photopea/Typr.js), and generates the SDF atlas for glyphs on-the-fly as they are used. It also handles proper kerning and ligature glyph substitution. All font parsing, SDF generation, and glyph layout is performed in a web worker to prevent frame drops. | ||
Once the SDFs are generated, it assembles a geometry that positions all the glyphs, and _patches_ any Three.js Material with the proper shader code for rendering the SDFs. This means you can still benefit from all the features of Three.js's built-in materials like lighting, physically-based rendering, shadows, and fog. | ||
## Screenshots | ||
![Text Rendering](./screenshot1.png) | ||
![Zoomed-in](./screenshot2.png) | ||
![Font with ligatures](./screenshot3.png) | ||
![Text with a texture](./screenshot4.png) | ||
## Usage | ||
### Using within the Troika 3D framework | ||
This library is built first and foremost to work within Troika 3D scenes, via the `Text3DFacade` class. | ||
```js | ||
import {Text3DFacade} from 'troika-3d-text' | ||
``` | ||
import troika3dText from 'troika-3d-text'; | ||
// TODO: DEMONSTRATE API | ||
...then within your scene descriptor: | ||
```js | ||
{ | ||
key: 'my-text', | ||
facade: Text3DFacade, | ||
text: 'Hello world!', | ||
fontSize: 0.2, | ||
color: 0x9966FF, | ||
z: -2 | ||
// ...etc. | ||
} | ||
```` | ||
### Using standalone with Three.js | ||
The `Text3DFacade` mentioned above is just a wrapper around a Three.js `TextMesh` object, which you can also use directly outside of the Troika framework. A special build file is provided in the distribution that includes only the necessary dependencies: | ||
```js | ||
import {TextMesh} from 'troika-3d-text/dist/textmesh-standalone.esm.js' | ||
```` | ||
You can then use the `TextMesh` class like any other Three.js mesh: | ||
```js | ||
const textMesh = new TextMesh() | ||
myScene.add(textMesh) | ||
// set properties to configure: | ||
textMesh.text = 'Hello world!' | ||
textMesh.fontSize = 0.2 | ||
textMesh.position.z = -2 | ||
textMesh.color = 0x9966FF | ||
// be sure to call sync() after all properties are set to update the rendering: | ||
textMesh.sync() | ||
``` | ||
When you're done with the `TextMesh` instance, be sure to call `dispose` on it to prevent a memory leak: | ||
```js | ||
myScene.remove(textMesh) | ||
textMesh.dispose() | ||
``` | ||
### Using in other frameworks | ||
Some examples of using the standalone TextMesh within other frameworks: | ||
* [With react-three-fiber](https://codesandbox.io/embed/troika-3d-text-via-react-three-fiber-ntfx2?fontsize=14) | ||
* [As an A-Frame component](https://github.com/lojjic/aframe-troika-text) | ||
## Supported properties | ||
Both `Text3DFacade` and `TextMesh` support the following properties for controlling the text rendering: | ||
#### `text` | ||
The string of text to be rendered. Newlines and repeating whitespace characters are honored. | ||
Default: _none_ | ||
#### `anchor` | ||
Defines what position within the text block should correspond to the local origin, as a set of horizontal and vertical percentages from 0 to 1. A value of `[0, 0]` anchors at the block's top-left, `[1, 1]` at its bottom-right, and `[0.5, 0.5]` centers the block on the origin. | ||
Default: `[0, 0]` | ||
#### `clipRect` | ||
If specified, defines the `[minX, minY, maxX, maxY]` of a rectangle outside of which all pixels will be discarded. This can be used for example to clip overflowing text when `whiteSpace='nowrap'`. | ||
Default: _none_ | ||
#### `color` | ||
This is a shortcut for setting the `color` of the text's `material`. You can use this if you don't want to specify a whole custom `material` and just want to change its color. | ||
Use the `material` property if you want to control aspects of the material other than its color. | ||
Default: _none_ - uses the color of the `material` | ||
#### `font` | ||
The URL of a custom font file to be used. Supported font formats are: | ||
* .ttf | ||
* .otf | ||
* .woff (.woff2 is _not_ supported) | ||
Default: The *Roboto* font loaded from Google Fonts CDN | ||
#### `fontSize` | ||
The em-height at which to render the font, in local world units. | ||
Default: `0.1` | ||
#### `letterSpacing` | ||
Sets a uniform adjustment to spacing between letters after kerning is applied, in local world units. Positive numbers increase spacing and negative numbers decrease it. | ||
Default: `0` | ||
#### `lineHeight` | ||
Sets the height of each line of text. Can either be `'normal'` which chooses a reasonable height based on the chosen font's ascender/descender metrics, or a number that is interpreted as a multiple of the `fontSize`. | ||
Default: `'normal'` | ||
#### `material` | ||
Defines a Three.js Material _instance_ to be used as a base when rendering the text. This material will be automatically replaced with a new material derived from it, that adds shader code to decrease the alpha for each fragment (pixel) outside the text glyphs, with antialiasing. | ||
By default it will derive from a simple white `MeshBasicMaterial, but you can use any of the other mesh materials to gain other features like lighting, texture maps, etc. | ||
Also see the `color` shortcut property. | ||
Default: a `MeshBasicMaterial` instance | ||
#### `maxWidth` | ||
The maximum width of the text block, above which text may start wrapping according to the `whiteSpace` and `overflowWrap` properties. | ||
Default: `Infinity`, meaning text will never wrap | ||
#### `overflowWrap` | ||
Defines how text wraps if the `whiteSpace` property is `'normal'`. Can be either `'normal'` to break at whitespace characters, or `'break-word'` to allow breaking within words. | ||
Default: `'normal'` | ||
#### `textAlign` | ||
The horizontal alignment of each line of text within the overall text bounding box. Can be one of `'left'`, `'right'`, `'center'`, or `'justify'`. | ||
Default: `'left'` | ||
#### `whiteSpace` | ||
Defines whether text should wrap when a line reaches the `maxWidth`. Can be either `'normal'`, to allow wrapping according to the `overflowWrap` property, or `'nowrap'` to prevent wrapping. | ||
Note that `'normal'` in this context _does_ honor newline characters to manually break lines, making it behave more like `'pre-wrap'` does in CSS. | ||
Default: `'normal'` | ||
@@ -44,7 +44,3 @@ import { | ||
A downside of this is that the UVs end up being 0-1 within each glyph rather than across | ||
the entire text block; we may be able to work around that with an option to instance the | ||
`uv` attribute. (TODO) | ||
Another downside of course is the rare-but-possible lack of the instanced arrays extension, | ||
A downside of this is the rare-but-possible lack of the instanced arrays extension, | ||
which we could potentially work around with a fallback non-instanced implementation. | ||
@@ -51,0 +47,0 @@ |
@@ -20,5 +20,5 @@ import { createDerivedMaterial } from 'troika-three-utils' | ||
position = vec3( | ||
position.x == 1.0 ? aTroikaGlyphBounds.z : aTroikaGlyphBounds.x, | ||
position.y == 1.0 ? aTroikaGlyphBounds.w : aTroikaGlyphBounds.y, | ||
0.0 | ||
mix(aTroikaGlyphBounds.x, aTroikaGlyphBounds.z, position.x), | ||
mix(aTroikaGlyphBounds.y, aTroikaGlyphBounds.w, position.y), | ||
position.z | ||
); | ||
@@ -25,0 +25,0 @@ vTroikaLocalPos = vec3(position); |
@@ -226,9 +226,9 @@ import { | ||
/** | ||
* Shortcut to dispose the geometry and derived material | ||
* Shortcut to dispose the geometry specific to this instance. | ||
* Note: we don't also dispose the derived material here because if anything else is | ||
* sharing the same base material it will result in a pause next frame as the program | ||
* is recompiled. Instead users can dispose the base material manually, like normal, | ||
* and we'll also dispose the derived material at that time. | ||
*/ | ||
dispose() { | ||
const textMaterial = this._derivedMaterial | ||
if (textMaterial) { | ||
textMaterial.dispose() | ||
} | ||
this.geometry.dispose() | ||
@@ -248,2 +248,7 @@ } | ||
derivedMaterial = this._derivedMaterial = createTextDerivedMaterial(baseMaterial) | ||
// dispose the derived material when its base material is disposed: | ||
baseMaterial.addEventListener('dispose', function onDispose() { | ||
baseMaterial.removeEventListener('dispose', onDispose) | ||
derivedMaterial.dispose() | ||
}) | ||
} | ||
@@ -250,0 +255,0 @@ return derivedMaterial |
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
1827977
31
31760
175
Updatedtroika-3d@^0.15.2