New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/text-bitmap

Package Overview
Dependencies
Maintainers
3
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/text-bitmap - npm Package Compare versions

Comparing version 6.5.3 to 7.0.0-alpha

57

dist/cjs/text-bitmap.min.js

@@ -1,9 +0,56 @@

/*!
* @pixi/text-bitmap - v6.5.3
* Compiled Fri, 09 Sep 2022 13:55:20 UTC
"use strict";/*!
* @pixi/text-bitmap - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
*
* @pixi/text-bitmap is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@pixi/math"),t=require("@pixi/settings"),r=require("@pixi/mesh"),i=require("@pixi/utils"),n=require("@pixi/core"),a=require("@pixi/text"),o=require("@pixi/constants"),s=require("@pixi/display"),h=require("@pixi/loaders"),l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},l(e,t)};var u=function(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]},f=function(){function e(){}return e.test=function(e){return"string"==typeof e&&0===e.indexOf("info face=")},e.parse=function(e){var t=e.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(var i in t){var n=t[i].match(/^[a-z]+/gm)[0],a=t[i].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),o={};for(var s in a){var h=a[s].split("="),l=h[0],f=h[1].replace(/"/gm,""),c=parseFloat(f),d=isNaN(c)?f:c;o[l]=d}r[n].push(o)}var p=new u;return r.info.forEach((function(e){return p.info.push({face:e.face,size:parseInt(e.size,10)})})),r.common.forEach((function(e){return p.common.push({lineHeight:parseInt(e.lineHeight,10)})})),r.page.forEach((function(e){return p.page.push({id:parseInt(e.id,10),file:e.file})})),r.char.forEach((function(e){return p.char.push({id:parseInt(e.id,10),page:parseInt(e.page,10),x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xoffset:parseInt(e.xoffset,10),yoffset:parseInt(e.yoffset,10),xadvance:parseInt(e.xadvance,10)})})),r.kerning.forEach((function(e){return p.kerning.push({first:parseInt(e.first,10),second:parseInt(e.second,10),amount:parseInt(e.amount,10)})})),r.distanceField.forEach((function(e){return p.distanceField.push({distanceRange:parseInt(e.distanceRange,10),fieldType:e.fieldType})})),p},e}(),c=function(){function e(){}return e.test=function(e){return e instanceof XMLDocument&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},e.parse=function(e){for(var t=new u,r=e.getElementsByTagName("info"),i=e.getElementsByTagName("common"),n=e.getElementsByTagName("page"),a=e.getElementsByTagName("char"),o=e.getElementsByTagName("kerning"),s=e.getElementsByTagName("distanceField"),h=0;h<r.length;h++)t.info.push({face:r[h].getAttribute("face"),size:parseInt(r[h].getAttribute("size"),10)});for(h=0;h<i.length;h++)t.common.push({lineHeight:parseInt(i[h].getAttribute("lineHeight"),10)});for(h=0;h<n.length;h++)t.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(h=0;h<a.length;h++){var l=a[h];t.char.push({id:parseInt(l.getAttribute("id"),10),page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xoffset:parseInt(l.getAttribute("xoffset"),10),yoffset:parseInt(l.getAttribute("yoffset"),10),xadvance:parseInt(l.getAttribute("xadvance"),10)})}for(h=0;h<o.length;h++)t.kerning.push({first:parseInt(o[h].getAttribute("first"),10),second:parseInt(o[h].getAttribute("second"),10),amount:parseInt(o[h].getAttribute("amount"),10)});for(h=0;h<s.length;h++)t.distanceField.push({fieldType:s[h].getAttribute("fieldType"),distanceRange:parseInt(s[h].getAttribute("distanceRange"),10)});return t},e}(),d=function(){function e(){}return e.test=function(e){if("string"==typeof e&&e.indexOf("<font>")>-1){var t=(new globalThis.DOMParser).parseFromString(e,"text/xml");return c.test(t)}return!1},e.parse=function(e){var t=(new globalThis.DOMParser).parseFromString(e,"text/xml");return c.parse(t)},e}(),p=[f,c,d];function g(e){for(var t=0;t<p.length;t++)if(p[t].test(e))return p[t];return null}function x(e,t,r,n,o,s,h){var l=r.text,u=r.fontProperties;t.translate(n,o),t.scale(s,s);var f=h.strokeThickness/2,c=-h.strokeThickness/2;if(t.font=h.toFontString(),t.lineWidth=h.strokeThickness,t.textBaseline=h.textBaseline,t.lineJoin=h.lineJoin,t.miterLimit=h.miterLimit,t.fillStyle=function(e,t,r,i,n,o){var s,h=r.fill;if(!Array.isArray(h))return h;if(1===h.length)return h[0];var l=r.dropShadow?r.dropShadowDistance:0,u=r.padding||0,f=e.width/i-l-2*u,c=e.height/i-l-2*u,d=h.slice(),p=r.fillGradientStops.slice();if(!p.length)for(var g=d.length+1,x=1;x<g;++x)p.push(x/g);if(d.unshift(h[0]),p.unshift(0),d.push(h[h.length-1]),p.push(1),r.fillGradientType===a.TEXT_GRADIENT.LINEAR_VERTICAL){s=t.createLinearGradient(f/2,u,f/2,c+u);var v=0,m=(o.fontProperties.fontSize+r.strokeThickness)/c;for(x=0;x<n.length;x++)for(var y=o.lineHeight*x,_=0;_<d.length;_++){var b=y/c+("number"==typeof p[_]?p[_]:_/d.length)*m,T=Math.max(v,b);T=Math.min(T,1),s.addColorStop(T,d[_]),v=T}}else{s=t.createLinearGradient(u,c/2,f+u,c/2);var w=d.length+1,A=1;for(x=0;x<d.length;x++){var M=void 0;M="number"==typeof p[x]?p[x]:A/w,s.addColorStop(M,d[x]),A++}}return s}(e,t,h,s,[l],r),t.strokeStyle=h.stroke,h.dropShadow){var d=h.dropShadowColor,p=i.hex2rgb("number"==typeof d?d:i.string2hex(d)),g=h.dropShadowBlur*s,x=h.dropShadowDistance*s;t.shadowColor="rgba("+255*p[0]+","+255*p[1]+","+255*p[2]+","+h.dropShadowAlpha+")",t.shadowBlur=g,t.shadowOffsetX=Math.cos(h.dropShadowAngle)*x,t.shadowOffsetY=Math.sin(h.dropShadowAngle)*x}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;h.stroke&&h.strokeThickness&&t.strokeText(l,f,c+r.lineHeight-u.descent),h.fill&&t.fillText(l,f,c+r.lineHeight-u.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function v(e){return Array.from?Array.from(e):e.split("")}function m(e){return e.codePointAt?e.codePointAt(0):e.charCodeAt(0)}var y=function(){function r(t,r,a){var s,h,l=t.info[0],u=t.common[0],f=t.page[0],c=t.distanceField[0],d=i.getResolutionOfUrl(f.file),p={};this._ownsTextures=a,this.font=l.face,this.size=l.size,this.lineHeight=u.lineHeight/d,this.chars={},this.pageTextures=p;for(var g=0;g<t.page.length;g++){var x=t.page[g],v=x.id,m=x.file;p[v]=r instanceof Array?r[g]:r[m],(null==c?void 0:c.fieldType)&&"none"!==c.fieldType&&(p[v].baseTexture.alphaMode=o.ALPHA_MODES.NO_PREMULTIPLIED_ALPHA)}for(g=0;g<t.char.length;g++){var y=t.char[g],_=(v=y.id,y.page),b=t.char[g],T=b.x,w=b.y,A=b.width,M=b.height,S=b.xoffset,P=b.yoffset,C=b.xadvance;T/=d,w/=d,A/=d,M/=d,S/=d,P/=d,C/=d;var E=new e.Rectangle(T+p[_].frame.x/d,w+p[_].frame.y/d,A,M);this.chars[v]={xOffset:S,yOffset:P,xAdvance:C,kerning:{},texture:new n.Texture(p[_].baseTexture,E),page:_}}for(g=0;g<t.kerning.length;g++){var O=t.kerning[g],I=O.first,F=O.second,D=O.amount;I/=d,F/=d,D/=d,this.chars[F]&&(this.chars[F].kerning[I]=D)}this.distanceFieldRange=null==c?void 0:c.distanceRange,this.distanceFieldType=null!==(h=null===(s=null==c?void 0:c.fieldType)||void 0===s?void 0:s.toLowerCase())&&void 0!==h?h:"none"}return r.prototype.destroy=function(){for(var e in this.chars)this.chars[e].texture.destroy(),this.chars[e].texture=null;for(var e in this.pageTextures)this._ownsTextures&&this.pageTextures[e].destroy(!0),this.pageTextures[e]=null;this.chars=null,this.pageTextures=null},r.install=function(e,t,i){var a;if(e instanceof u)a=e;else{var o=g(e);if(!o)throw new Error("Unrecognized data format for font.");a=o.parse(e)}t instanceof n.Texture&&(t=[t]);var s=new r(a,t,i);return r.available[s.font]=s,s},r.uninstall=function(e){var t=r.available[e];if(!t)throw new Error("No font found named '"+e+"'");t.destroy(),delete r.available[e]},r.from=function(e,i,o){if(!e)throw new Error("[BitmapFont] Property `name` is required.");var s=Object.assign({},r.defaultOptions,o),h=s.chars,l=s.padding,f=s.resolution,c=s.textureWidth,d=s.textureHeight,p=function(e){"string"==typeof e&&(e=[e]);for(var t=[],r=0,i=e.length;r<i;r++){var n=e[r];if(Array.isArray(n)){if(2!==n.length)throw new Error("[BitmapFont]: Invalid character range length, expecting 2 got "+n.length+".");var a=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<a)throw new Error("[BitmapFont]: Invalid character range.");for(var s=a,h=o;s<=h;s++)t.push(String.fromCharCode(s))}else t.push.apply(t,v(n))}if(0===t.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}(h),g=i instanceof a.TextStyle?i:new a.TextStyle(i),y=c,_=new u;_.info[0]={face:g.fontFamily,size:g.fontSize},_.common[0]={lineHeight:g.fontSize};for(var b,T,w,A=0,M=0,S=0,P=[],C=0;C<p.length;C++){b||((b=t.settings.ADAPTER.createCanvas()).width=c,b.height=d,T=b.getContext("2d"),w=new n.BaseTexture(b,{resolution:f}),P.push(new n.Texture(w)),_.page.push({id:P.length-1,file:""}));var E=a.TextMetrics.measureText(p[C],g,!1,b),O=E.width,I=Math.ceil(E.height),F=Math.ceil(("italic"===g.fontStyle?2:1)*O);if(M>=d-I*f){if(0===M)throw new Error("[BitmapFont] textureHeight "+d+"px is too small for "+g.fontSize+"px fonts");--C,b=null,T=null,w=null,M=0,A=0,S=0}else if(S=Math.max(I+E.fontProperties.descent,S),F*f+A>=y)--C,M+=S*f,M=Math.ceil(M),A=0,S=0;else{x(b,T,E,A,M,f,g);var D=m(E.text);_.char.push({id:D,page:P.length-1,x:A/f,y:M/f,width:F,height:I,xoffset:0,yoffset:0,xadvance:Math.ceil(O-(g.dropShadow?g.dropShadowDistance:0)-(g.stroke?g.strokeThickness:0))}),A+=(F+2*l)*f,A=Math.ceil(A)}}C=0;for(var L=p.length;C<L;C++)for(var k=p[C],B=0;B<L;B++){var N=p[B],H=T.measureText(k).width,z=T.measureText(N).width,R=T.measureText(k+N).width-(H+z);R&&_.kerning.push({first:m(k),second:m(N),amount:R})}var j=new r(_,P,!0);return void 0!==r.available[e]&&r.uninstall(e),r.available[e]=j,j},r.ALPHA=[["a","z"],["A","Z"]," "],r.NUMERIC=[["0","9"]],r.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],r.ASCII=[[" ","~"]],r.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:r.ALPHANUMERIC},r.available={},r}(),_=[],b=[],T=[],w=function(a){function s(r,i){void 0===i&&(i={});var n=a.call(this)||this;n._tint=16777215;var o=Object.assign({},s.styleDefaults,i),h=o.align,l=o.tint,u=o.maxWidth,f=o.letterSpacing,c=o.fontName,d=o.fontSize;if(!y.available[c])throw new Error('Missing BitmapFont "'+c+'"');return n._activePagesMeshData=[],n._textWidth=0,n._textHeight=0,n._align=h,n._tint=l,n._fontName=c,n._fontSize=d||y.available[c].size,n.text=r,n._maxWidth=u,n._maxLineHeight=0,n._letterSpacing=f,n._anchor=new e.ObservablePoint((function(){n.dirty=!0}),n,0,0),n._roundPixels=t.settings.ROUND_PIXELS,n.dirty=!0,n._resolution=t.settings.RESOLUTION,n._autoResolution=!0,n._textureCache={},n}return function(e,t){function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(s,a),s.prototype.updateText=function(){for(var t,a=y.available[this._fontName],s=this._fontSize/a.size,h=new e.Point,l=[],u=[],f=[],c=v(this._text.replace(/(?:\r\n|\r)/g,"\n")||" "),d=this._maxWidth*a.size/this._fontSize,p="none"===a.distanceFieldType?_:b,g=null,x=0,w=0,A=0,M=-1,S=0,P=0,C=0,E=0,O=0;O<c.length;O++){var I=m(J=c[O]);if(/(?:\s)/.test(J)&&(M=O,S=x,E++),"\r"!==J&&"\n"!==J){var F=a.chars[I];if(F){g&&F.kerning[g]&&(h.x+=F.kerning[g]);var D=T.pop()||{texture:n.Texture.EMPTY,line:0,charCode:0,prevSpaces:0,position:new e.Point};D.texture=F.texture,D.line=A,D.charCode=I,D.position.x=h.x+F.xOffset+this._letterSpacing/2,D.position.y=h.y+F.yOffset,D.prevSpaces=E,l.push(D),x=D.position.x+Math.max(F.xAdvance-F.xOffset,F.texture.orig.width),h.x+=F.xAdvance+this._letterSpacing,C=Math.max(C,F.yOffset+F.texture.height),g=I,-1!==M&&d>0&&h.x>d&&(++P,i.removeItems(l,1+M-P,1+O-M),O=M,M=-1,u.push(S),f.push(l.length>0?l[l.length-1].prevSpaces:0),w=Math.max(w,S),A++,h.x=0,h.y+=a.lineHeight,g=null,E=0)}}else u.push(x),f.push(-1),w=Math.max(w,x),++A,++P,h.x=0,h.y+=a.lineHeight,g=null,E=0}var L=c[c.length-1];"\r"!==L&&"\n"!==L&&(/(?:\s)/.test(L)&&(x=S),u.push(x),w=Math.max(w,x),f.push(-1));var k=[];for(O=0;O<=A;O++){var B=0;"right"===this._align?B=w-u[O]:"center"===this._align?B=(w-u[O])/2:"justify"===this._align&&(B=f[O]<0?0:(w-u[O])/f[O]),k.push(B)}var N=l.length,H={},z=[],R=this._activePagesMeshData;for(O=0;O<R.length;O++)p.push(R[O]);for(O=0;O<N;O++){var j=(Q=l[O].texture).baseTexture.uid;if(!H[j]){if(!(oe=p.pop())){var W=new r.MeshGeometry,U=void 0,q=void 0;"none"===a.distanceFieldType?(U=new r.MeshMaterial(n.Texture.EMPTY),q=o.BLEND_MODES.NORMAL):(U=new r.MeshMaterial(n.Texture.EMPTY,{program:n.Program.from("// Mesh material default fragment\r\nattribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\n\r\nuniform mat3 projectionMatrix;\r\nuniform mat3 translationMatrix;\r\nuniform mat3 uTextureMatrix;\r\n\r\nvarying vec2 vTextureCoord;\r\n\r\nvoid main(void)\r\n{\r\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r\n\r\n vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r\n}\r\n","// Pixi texture info\r\nvarying vec2 vTextureCoord;\r\nuniform sampler2D uSampler;\r\n\r\n// Tint\r\nuniform vec4 uColor;\r\n\r\n// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r\nuniform float uFWidth;\r\n\r\nvoid main(void) {\r\n\r\n // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n\r\n // MSDF\r\n float median = texColor.r + texColor.g + texColor.b -\r\n min(texColor.r, min(texColor.g, texColor.b)) -\r\n max(texColor.r, max(texColor.g, texColor.b));\r\n // SDF\r\n median = min(median, texColor.a);\r\n\r\n float screenPxDistance = uFWidth * (median - 0.5);\r\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r\n\r\n // NPM Textures, NPM outputs\r\n gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\r\n\r\n}\r\n"),uniforms:{uFWidth:0}}),q=o.BLEND_MODES.NORMAL_NPM);var X=new r.Mesh(W,U);X.blendMode=q,oe={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:X,vertices:null,uvs:null,indices:null}}oe.index=0,oe.indexCount=0,oe.vertexCount=0,oe.uvsCount=0,oe.total=0;var G=this._textureCache;G[j]=G[j]||new n.Texture(Q.baseTexture),oe.mesh.texture=G[j],oe.mesh.tint=this._tint,z.push(oe),H[j]=oe}H[j].total++}for(O=0;O<R.length;O++)-1===z.indexOf(R[O])&&this.removeChild(R[O].mesh);for(O=0;O<z.length;O++)z[O].mesh.parent!==this&&this.addChild(z[O].mesh);for(var O in this._activePagesMeshData=z,H){var Y=(oe=H[O]).total;if(!((null===(t=oe.indices)||void 0===t?void 0:t.length)>6*Y)||oe.vertices.length<2*r.Mesh.BATCHABLE_SIZE)oe.vertices=new Float32Array(8*Y),oe.uvs=new Float32Array(8*Y),oe.indices=new Uint16Array(6*Y);else for(var V=oe.total,Z=oe.vertices,$=4*V*2;$<Z.length;$++)Z[$]=0;oe.mesh.size=6*Y}for(O=0;O<N;O++){var J,K=(J=l[O]).position.x+k[J.line]*("justify"===this._align?J.prevSpaces:1);this._roundPixels&&(K=Math.round(K));var Q,ee=K*s,te=J.position.y*s,re=H[(Q=J.texture).baseTexture.uid],ie=Q.frame,ne=Q._uvs,ae=re.index++;re.indices[6*ae+0]=0+4*ae,re.indices[6*ae+1]=1+4*ae,re.indices[6*ae+2]=2+4*ae,re.indices[6*ae+3]=0+4*ae,re.indices[6*ae+4]=2+4*ae,re.indices[6*ae+5]=3+4*ae,re.vertices[8*ae+0]=ee,re.vertices[8*ae+1]=te,re.vertices[8*ae+2]=ee+ie.width*s,re.vertices[8*ae+3]=te,re.vertices[8*ae+4]=ee+ie.width*s,re.vertices[8*ae+5]=te+ie.height*s,re.vertices[8*ae+6]=ee,re.vertices[8*ae+7]=te+ie.height*s,re.uvs[8*ae+0]=ne.x0,re.uvs[8*ae+1]=ne.y0,re.uvs[8*ae+2]=ne.x1,re.uvs[8*ae+3]=ne.y1,re.uvs[8*ae+4]=ne.x2,re.uvs[8*ae+5]=ne.y2,re.uvs[8*ae+6]=ne.x3,re.uvs[8*ae+7]=ne.y3}for(var O in this._textWidth=w*s,this._textHeight=(h.y+a.lineHeight)*s,H){var oe=H[O];if(0!==this.anchor.x||0!==this.anchor.y)for(var se=0,he=this._textWidth*this.anchor.x,le=this._textHeight*this.anchor.y,ue=0;ue<oe.total;ue++)oe.vertices[se++]-=he,oe.vertices[se++]-=le,oe.vertices[se++]-=he,oe.vertices[se++]-=le,oe.vertices[se++]-=he,oe.vertices[se++]-=le,oe.vertices[se++]-=he,oe.vertices[se++]-=le;this._maxLineHeight=C*s;var fe=oe.mesh.geometry.getBuffer("aVertexPosition"),ce=oe.mesh.geometry.getBuffer("aTextureCoord"),de=oe.mesh.geometry.getIndex();fe.data=oe.vertices,ce.data=oe.uvs,de.data=oe.indices,fe.update(),ce.update(),de.update()}for(O=0;O<l.length;O++)T.push(l[O])},s.prototype.updateTransform=function(){this.validate(),this.containerUpdateTransform()},s.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0);var t=y.available[this._fontName],r=t.distanceFieldRange,i=t.distanceFieldType,n=t.size;if("none"!==i)for(var o=this.worldTransform,s=o.a,h=o.b,l=o.c,u=o.d,f=Math.sqrt(s*s+h*h),c=Math.sqrt(l*l+u*u),d=(Math.abs(f)+Math.abs(c))/2,p=this._fontSize/n,g=0,x=this._activePagesMeshData;g<x.length;g++){x[g].mesh.shader.uniforms.uFWidth=d*r*p*this._resolution}a.prototype._render.call(this,e)},s.prototype.getLocalBounds=function(){return this.validate(),a.prototype.getLocalBounds.call(this)},s.prototype.validate=function(){this.dirty&&(this.updateText(),this.dirty=!1)},Object.defineProperty(s.prototype,"tint",{get:function(){return this._tint},set:function(e){if(this._tint!==e){this._tint=e;for(var t=0;t<this._activePagesMeshData.length;t++)this._activePagesMeshData[t].mesh.tint=e}},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"align",{get:function(){return this._align},set:function(e){this._align!==e&&(this._align=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"fontName",{get:function(){return this._fontName},set:function(e){if(!y.available[e])throw new Error('Missing BitmapFont "'+e+'"');this._fontName!==e&&(this._fontName=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"fontSize",{get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"anchor",{get:function(){return this._anchor},set:function(e){"number"==typeof e?this._anchor.set(e):this._anchor.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"text",{get:function(){return this._text},set:function(e){e=String(null==e?"":e),this._text!==e&&(this._text=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(e){this._maxWidth!==e&&(this._maxWidth=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"maxLineHeight",{get:function(){return this.validate(),this._maxLineHeight},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"textWidth",{get:function(){return this.validate(),this._textWidth},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(e){e!==this._roundPixels&&(this._roundPixels=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"textHeight",{get:function(){return this.validate(),this._textHeight},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)},enumerable:!1,configurable:!0}),s.prototype.destroy=function(e){var t=this._textureCache;for(var r in t){t[r].destroy(),delete t[r]}this._textureCache=null,a.prototype.destroy.call(this,e)},s.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0},s}(s.Container),A=function(){function e(){}return e.add=function(){h.LoaderResource.setExtensionXhrType("fnt",h.LoaderResource.XHR_RESPONSE_TYPE.TEXT)},e.use=function(t,r){var i=g(t.data);if(i)for(var n=e.getBaseUrl(this,t),a=i.parse(t.data),o={},s=function(e){o[e.metadata.pageFile]=e.texture,Object.keys(o).length===a.page.length&&(t.bitmapFont=y.install(a,o,!0),r())},l=0;l<a.page.length;++l){var u=a.page[l].file,f=n+u,c=!1;for(var d in this.resources){var p=this.resources[d];if(p.url===f){p.metadata.pageFile=u,p.texture?s(p):p.onAfterMiddleware.add(s),c=!0;break}}if(!c){var x={crossOrigin:t.crossOrigin,loadType:h.LoaderResource.LOAD_TYPE.IMAGE,metadata:Object.assign({pageFile:u},t.metadata.imageMetadata),parentResource:t};this.add(f,x,s)}}else r()},e.getBaseUrl=function(t,r){var i=r.isDataUrl?"":e.dirname(r.url);return r.isDataUrl&&("."===i&&(i=""),t.baseUrl&&i&&"/"===t.baseUrl.charAt(t.baseUrl.length-1)&&(i+="/")),(i=i.replace(t.baseUrl,""))&&"/"!==i.charAt(i.length-1)&&(i+="/"),i},e.dirname=function(e){var t=e.replace(/\\/g,"/").replace(/\/$/,"").replace(/\/[^\/]*$/,"");return t===e?".":""===t?"/":t},e.extension=n.ExtensionType.Loader,e}();exports.BitmapFont=y,exports.BitmapFontData=u,exports.BitmapFontLoader=A,exports.BitmapText=w,exports.TextFormat=f,exports.XMLFormat=c,exports.XMLStringFormat=d,exports.autoDetectFormat=g;
*/Object.defineProperty(exports,"__esModule",{value:!0});var v=require("@pixi/core"),W=require("@pixi/text"),H=require("@pixi/mesh"),Q=require("@pixi/display"),K=require("@pixi/assets");class O{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class R{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const s=e.match(/^[a-z]+\s+.+$/gm),l={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in s){const r=s[n].match(/^[a-z]+/gm)[0],a=s[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const i in a){const g=a[i].split("="),d=g[0],c=g[1].replace(/"/gm,""),x=parseFloat(c),m=isNaN(x)?c:x;f[d]=m}l[r].push(f)}const u=new O;return l.info.forEach(n=>u.info.push({face:n.face,size:parseInt(n.size,10)})),l.common.forEach(n=>u.common.push({lineHeight:parseInt(n.lineHeight,10)})),l.page.forEach(n=>u.page.push({id:parseInt(n.id,10),file:n.file})),l.char.forEach(n=>u.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),l.kerning.forEach(n=>u.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),l.distanceField.forEach(n=>u.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),u}}class ${static test(e){return e instanceof XMLDocument&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const s=new O,l=e.getElementsByTagName("info"),u=e.getElementsByTagName("common"),n=e.getElementsByTagName("page"),r=e.getElementsByTagName("char"),a=e.getElementsByTagName("kerning"),f=e.getElementsByTagName("distanceField");for(let i=0;i<l.length;i++)s.info.push({face:l[i].getAttribute("face"),size:parseInt(l[i].getAttribute("size"),10)});for(let i=0;i<u.length;i++)s.common.push({lineHeight:parseInt(u[i].getAttribute("lineHeight"),10)});for(let i=0;i<n.length;i++)s.page.push({id:parseInt(n[i].getAttribute("id"),10)||0,file:n[i].getAttribute("file")});for(let i=0;i<r.length;i++){const g=r[i];s.char.push({id:parseInt(g.getAttribute("id"),10),page:parseInt(g.getAttribute("page"),10)||0,x:parseInt(g.getAttribute("x"),10),y:parseInt(g.getAttribute("y"),10),width:parseInt(g.getAttribute("width"),10),height:parseInt(g.getAttribute("height"),10),xoffset:parseInt(g.getAttribute("xoffset"),10),yoffset:parseInt(g.getAttribute("yoffset"),10),xadvance:parseInt(g.getAttribute("xadvance"),10)})}for(let i=0;i<a.length;i++)s.kerning.push({first:parseInt(a[i].getAttribute("first"),10),second:parseInt(a[i].getAttribute("second"),10),amount:parseInt(a[i].getAttribute("amount"),10)});for(let i=0;i<f.length;i++)s.distanceField.push({fieldType:f[i].getAttribute("fieldType"),distanceRange:parseInt(f[i].getAttribute("distanceRange"),10)});return s}}class U{static test(e){if(typeof e=="string"&&e.includes("<font>")){const s=new globalThis.DOMParser().parseFromString(e,"text/xml");return $.test(s)}return!1}static parse(e){const s=new globalThis.DOMParser().parseFromString(e,"text/xml");return $.parse(s)}}const j=[R,$,U];function q(t){for(let e=0;e<j.length;e++)if(j[e].test(t))return j[e];return null}function tt(t,e,s,l,u,n){const r=s.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let a;const f=s.dropShadow?s.dropShadowDistance:0,i=s.padding||0,g=t.width/l-f-i*2,d=t.height/l-f-i*2,c=r.slice(),x=s.fillGradientStops.slice();if(!x.length){const m=c.length+1;for(let w=1;w<m;++w)x.push(w/m)}if(c.unshift(r[0]),x.unshift(0),c.push(r[r.length-1]),x.push(1),s.fillGradientType===W.TEXT_GRADIENT.LINEAR_VERTICAL){a=e.createLinearGradient(g/2,i,g/2,d+i);let m=0;const w=(n.fontProperties.fontSize+s.strokeThickness)/d;for(let S=0;S<u.length;S++){const b=n.lineHeight*S;for(let A=0;A<c.length;A++){let k=0;typeof x[A]=="number"?k=x[A]:k=A/c.length;const I=b/d+k*w;let F=Math.max(m,I);F=Math.min(F,1),a.addColorStop(F,c[A]),m=F}}}else{a=e.createLinearGradient(i,d/2,g+i,d/2);const m=c.length+1;let w=1;for(let S=0;S<c.length;S++){let b;typeof x[S]=="number"?b=x[S]:b=w/m,a.addColorStop(b,c[S]),w++}}return a}function et(t,e,s,l,u,n,r){const a=s.text,f=s.fontProperties;e.translate(l,u),e.scale(n,n);const i=r.strokeThickness/2,g=-(r.strokeThickness/2);if(e.font=r.toFontString(),e.lineWidth=r.strokeThickness,e.textBaseline=r.textBaseline,e.lineJoin=r.lineJoin,e.miterLimit=r.miterLimit,e.fillStyle=tt(t,e,r,n,[a],s),e.strokeStyle=r.stroke,r.dropShadow){const d=r.dropShadowColor,c=v.utils.hex2rgb(typeof d=="number"?d:v.utils.string2hex(d)),x=r.dropShadowBlur*n,m=r.dropShadowDistance*n;e.shadowColor=`rgba(${c[0]*255},${c[1]*255},${c[2]*255},${r.dropShadowAlpha})`,e.shadowBlur=x,e.shadowOffsetX=Math.cos(r.dropShadowAngle)*m,e.shadowOffsetY=Math.sin(r.dropShadowAngle)*m}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0;r.stroke&&r.strokeThickness&&e.strokeText(a,i,g+s.lineHeight-f.descent),r.fill&&e.fillText(a,i,g+s.lineHeight-f.descent),e.setTransform(1,0,0,1,0,0),e.fillStyle="rgba(0, 0, 0, 0)"}function G(t){return Array.from?Array.from(t):t.split("")}function it(t){typeof t=="string"&&(t=[t]);const e=[];for(let s=0,l=t.length;s<l;s++){const u=t[s];if(Array.isArray(u)){if(u.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${u.length}.`);const n=u[0].charCodeAt(0),r=u[1].charCodeAt(0);if(r<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,f=r;a<=f;a++)e.push(String.fromCharCode(a))}else e.push(...G(u))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}function X(t){return t.codePointAt?t.codePointAt(0):t.charCodeAt(0)}const z=class{constructor(t,e,s){const[l]=t.info,[u]=t.common,[n]=t.page,[r]=t.distanceField,a=v.utils.getResolutionOfUrl(n.file),f={};this._ownsTextures=s,this.font=l.face,this.size=l.size,this.lineHeight=u.lineHeight/a,this.chars={},this.pageTextures=f;for(let i=0;i<t.page.length;i++){const{id:g,file:d}=t.page[i];f[g]=e instanceof Array?e[i]:e[d],r?.fieldType&&r.fieldType!=="none"&&(f[g].baseTexture.alphaMode=v.ALPHA_MODES.NO_PREMULTIPLIED_ALPHA)}for(let i=0;i<t.char.length;i++){const{id:g,page:d}=t.char[i];let{x:c,y:x,width:m,height:w,xoffset:S,yoffset:b,xadvance:A}=t.char[i];c/=a,x/=a,m/=a,w/=a,S/=a,b/=a,A/=a;const k=new v.Rectangle(c+f[d].frame.x/a,x+f[d].frame.y/a,m,w);this.chars[g]={xOffset:S,yOffset:b,xAdvance:A,kerning:{},texture:new v.Texture(f[d].baseTexture,k),page:d}}for(let i=0;i<t.kerning.length;i++){let{first:g,second:d,amount:c}=t.kerning[i];g/=a,d/=a,c/=a,this.chars[d]&&(this.chars[d].kerning[g]=c)}this.distanceFieldRange=r?.distanceRange,this.distanceFieldType=r?.fieldType?.toLowerCase()??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,s){let l;if(t instanceof O)l=t;else{const n=q(t);if(!n)throw new Error("Unrecognized data format for font.");l=n.parse(t)}e instanceof v.Texture&&(e=[e]);const u=new z(l,e,s);return z.available[u.font]=u,u}static uninstall(t){const e=z.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete z.available[t]}static from(t,e,s){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:l,padding:u,resolution:n,textureWidth:r,textureHeight:a}=Object.assign({},z.defaultOptions,s),f=it(l),i=e instanceof W.TextStyle?e:new W.TextStyle(e),g=r,d=new O;d.info[0]={face:i.fontFamily,size:i.fontSize},d.common[0]={lineHeight:i.fontSize};let c=0,x=0,m,w,S,b=0;const A=[];for(let I=0;I<f.length;I++){m||(m=v.settings.ADAPTER.createCanvas(),m.width=r,m.height=a,w=m.getContext("2d"),S=new v.BaseTexture(m,{resolution:n}),A.push(new v.Texture(S)),d.page.push({id:A.length-1,file:""}));const F=W.TextMetrics.measureText(f[I],i,!1,m),P=F.width,E=Math.ceil(F.height),B=Math.ceil((i.fontStyle==="italic"?2:1)*P);if(x>=a-E*n){if(x===0)throw new Error(`[BitmapFont] textureHeight ${a}px is too small for ${i.fontSize}px fonts`);--I,m=null,w=null,S=null,x=0,c=0,b=0;continue}if(b=Math.max(E+F.fontProperties.descent,b),B*n+c>=g){--I,x+=b*n,x=Math.ceil(x),c=0,b=0;continue}et(m,w,F,c,x,n,i);const o=X(F.text);d.char.push({id:o,page:A.length-1,x:c/n,y:x/n,width:B,height:E,xoffset:0,yoffset:0,xadvance:Math.ceil(P-(i.dropShadow?i.dropShadowDistance:0)-(i.stroke?i.strokeThickness:0))}),c+=(B+2*u)*n,c=Math.ceil(c)}for(let I=0,F=f.length;I<F;I++){const P=f[I];for(let E=0;E<F;E++){const B=f[E],o=w.measureText(P).width,h=w.measureText(B).width,T=w.measureText(P+B).width-(o+h);T&&d.kerning.push({first:X(P),second:X(B),amount:T})}}const k=new z(d,A,!0);return z.available[t]!==void 0&&z.uninstall(t),z.available[t]=k,k}};let N=z;N.ALPHA=[["a","z"],["A","Z"]," "],N.NUMERIC=[["0","9"]],N.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],N.ASCII=[[" ","~"]],N.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:z.ALPHANUMERIC},N.available={};var nt=`// Pixi texture info\r
varying vec2 vTextureCoord;\r
uniform sampler2D uSampler;\r
\r
// Tint\r
uniform vec4 uColor;\r
\r
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
uniform float uFWidth;\r
\r
void main(void) {\r
\r
// To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
vec4 texColor = texture2D(uSampler, vTextureCoord);\r
\r
// MSDF\r
float median = texColor.r + texColor.g + texColor.b -\r
min(texColor.r, min(texColor.g, texColor.b)) -\r
max(texColor.r, max(texColor.g, texColor.b));\r
// SDF\r
median = min(median, texColor.a);\r
\r
float screenPxDistance = uFWidth * (median - 0.5);\r
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
\r
// NPM Textures, NPM outputs\r
gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\r
\r
}\r
`,st=`// Mesh material default fragment\r
attribute vec2 aVertexPosition;\r
attribute vec2 aTextureCoord;\r
\r
uniform mat3 projectionMatrix;\r
uniform mat3 translationMatrix;\r
uniform mat3 uTextureMatrix;\r
\r
varying vec2 vTextureCoord;\r
\r
void main(void)\r
{\r
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
\r
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
}\r
`;const rt=[],at=[],Y=[],V=class extends Q.Container{constructor(t,e={}){super(),this._tint=16777215;const{align:s,tint:l,maxWidth:u,letterSpacing:n,fontName:r,fontSize:a}=Object.assign({},V.styleDefaults,e);if(!N.available[r])throw new Error(`Missing BitmapFont "${r}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=s,this._tint=l,this._fontName=r,this._fontSize=a||N.available[r].size,this.text=t,this._maxWidth=u,this._maxLineHeight=0,this._letterSpacing=n,this._anchor=new v.ObservablePoint(()=>{this.dirty=!0},this,0,0),this._roundPixels=v.settings.ROUND_PIXELS,this.dirty=!0,this._resolution=v.settings.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const t=N.available[this._fontName],e=this._fontSize/t.size,s=new v.Point,l=[],u=[],n=[],r=this._text.replace(/(?:\r\n|\r)/g,`
`)||" ",a=G(r),f=this._maxWidth*t.size/this._fontSize,i=t.distanceFieldType==="none"?rt:at;let g=null,d=0,c=0,x=0,m=-1,w=0,S=0,b=0,A=0;for(let o=0;o<a.length;o++){const h=a[o],T=X(h);if(/(?:\s)/.test(h)&&(m=o,w=d,A++),h==="\r"||h===`
`){u.push(d),n.push(-1),c=Math.max(c,d),++x,++S,s.x=0,s.y+=t.lineHeight,g=null,A=0;continue}const p=t.chars[T];if(!p)continue;g&&p.kerning[g]&&(s.x+=p.kerning[g]);const M=Y.pop()||{texture:v.Texture.EMPTY,line:0,charCode:0,prevSpaces:0,position:new v.Point};M.texture=p.texture,M.line=x,M.charCode=T,M.position.x=s.x+p.xOffset+this._letterSpacing/2,M.position.y=s.y+p.yOffset,M.prevSpaces=A,l.push(M),d=M.position.x+Math.max(p.xAdvance-p.xOffset,p.texture.orig.width),s.x+=p.xAdvance+this._letterSpacing,b=Math.max(b,p.yOffset+p.texture.height),g=T,m!==-1&&f>0&&s.x>f&&(++S,v.utils.removeItems(l,1+m-S,1+o-m),o=m,m=-1,u.push(w),n.push(l.length>0?l[l.length-1].prevSpaces:0),c=Math.max(c,w),x++,s.x=0,s.y+=t.lineHeight,g=null,A=0)}const k=a[a.length-1];k!=="\r"&&k!==`
`&&(/(?:\s)/.test(k)&&(d=w),u.push(d),c=Math.max(c,d),n.push(-1));const I=[];for(let o=0;o<=x;o++){let h=0;this._align==="right"?h=c-u[o]:this._align==="center"?h=(c-u[o])/2:this._align==="justify"&&(h=n[o]<0?0:(c-u[o])/n[o]),I.push(h)}const F=l.length,P={},E=[],B=this._activePagesMeshData;for(let o=0;o<B.length;o++)i.push(B[o]);for(let o=0;o<F;o++){const h=l[o].texture,T=h.baseTexture.uid;if(!P[T]){let p=i.pop();if(!p){const C=new H.MeshGeometry;let y,L;t.distanceFieldType==="none"?(y=new H.MeshMaterial(v.Texture.EMPTY),L=v.BLEND_MODES.NORMAL):(y=new H.MeshMaterial(v.Texture.EMPTY,{program:v.Program.from(st,nt),uniforms:{uFWidth:0}}),L=v.BLEND_MODES.NORMAL_NPM);const D=new H.Mesh(C,y);D.blendMode=L,p={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:D,vertices:null,uvs:null,indices:null}}p.index=0,p.indexCount=0,p.vertexCount=0,p.uvsCount=0,p.total=0;const{_textureCache:M}=this;M[T]=M[T]||new v.Texture(h.baseTexture),p.mesh.texture=M[T],p.mesh.tint=this._tint,E.push(p),P[T]=p}P[T].total++}for(let o=0;o<B.length;o++)E.includes(B[o])||this.removeChild(B[o].mesh);for(let o=0;o<E.length;o++)E[o].mesh.parent!==this&&this.addChild(E[o].mesh);this._activePagesMeshData=E;for(const o in P){const h=P[o],T=h.total;if(!(h.indices?.length>6*T)||h.vertices.length<H.Mesh.BATCHABLE_SIZE*2)h.vertices=new Float32Array(4*2*T),h.uvs=new Float32Array(4*2*T),h.indices=new Uint16Array(6*T);else{const p=h.total,M=h.vertices;for(let C=p*4*2;C<M.length;C++)M[C]=0}h.mesh.size=6*T}for(let o=0;o<F;o++){const h=l[o];let T=h.position.x+I[h.line]*(this._align==="justify"?h.prevSpaces:1);this._roundPixels&&(T=Math.round(T));const p=T*e,M=h.position.y*e,C=h.texture,y=P[C.baseTexture.uid],L=C.frame,D=C._uvs,_=y.index++;y.indices[_*6+0]=0+_*4,y.indices[_*6+1]=1+_*4,y.indices[_*6+2]=2+_*4,y.indices[_*6+3]=0+_*4,y.indices[_*6+4]=2+_*4,y.indices[_*6+5]=3+_*4,y.vertices[_*8+0]=p,y.vertices[_*8+1]=M,y.vertices[_*8+2]=p+L.width*e,y.vertices[_*8+3]=M,y.vertices[_*8+4]=p+L.width*e,y.vertices[_*8+5]=M+L.height*e,y.vertices[_*8+6]=p,y.vertices[_*8+7]=M+L.height*e,y.uvs[_*8+0]=D.x0,y.uvs[_*8+1]=D.y0,y.uvs[_*8+2]=D.x1,y.uvs[_*8+3]=D.y1,y.uvs[_*8+4]=D.x2,y.uvs[_*8+5]=D.y2,y.uvs[_*8+6]=D.x3,y.uvs[_*8+7]=D.y3}this._textWidth=c*e,this._textHeight=(s.y+t.lineHeight)*e;for(const o in P){const h=P[o];if(this.anchor.x!==0||this.anchor.y!==0){let C=0;const y=this._textWidth*this.anchor.x,L=this._textHeight*this.anchor.y;for(let D=0;D<h.total;D++)h.vertices[C++]-=y,h.vertices[C++]-=L,h.vertices[C++]-=y,h.vertices[C++]-=L,h.vertices[C++]-=y,h.vertices[C++]-=L,h.vertices[C++]-=y,h.vertices[C++]-=L}this._maxLineHeight=b*e;const T=h.mesh.geometry.getBuffer("aVertexPosition"),p=h.mesh.geometry.getBuffer("aTextureCoord"),M=h.mesh.geometry.getIndex();T.data=h.vertices,p.data=h.uvs,M.data=h.indices,T.update(),p.update(),M.update()}for(let o=0;o<l.length;o++)Y.push(l[o])}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:s,size:l}=N.available[this._fontName];if(s!=="none"){const{a:u,b:n,c:r,d:a}=this.worldTransform,f=Math.sqrt(u*u+n*n),i=Math.sqrt(r*r+a*a),g=(Math.abs(f)+Math.abs(i))/2,d=this._fontSize/l,c=t._view.resolution;for(const x of this._activePagesMeshData)x.mesh.shader.uniforms.uFWidth=g*e*d*c}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){this.dirty&&(this.updateText(),this.dirty=!1)}get tint(){return this._tint}set tint(t){if(this._tint!==t){this._tint=t;for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!N.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this;for(const s in e)e[s].destroy(),delete e[s];this._textureCache=null,super.destroy(t)}};let Z=V;Z.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const ot=[".xml",".fnt"],J={extension:{type:v.ExtensionType.LoadParser,priority:K.LoaderParserPriority.Normal},test(t){return ot.includes(v.utils.path.extname(t))},async testParse(t){return R.test(t)||U.test(t)},async parse(t,e,s){const l=R.test(t)?R.parse(t):U.parse(t),{src:u}=e,{page:n}=l,r=[];for(let i=0;i<n.length;++i){const g=n[i].file,d=v.utils.path.join(v.utils.path.dirname(u),g);r.push(d)}const a=await s.load(r),f=r.map(i=>a[i]);return N.install(l,f,!0)},async load(t,e){return(await v.settings.ADAPTER.fetch(t)).text()},unload(t){t.destroy()}};v.extensions.add(J),exports.BitmapFont=N,exports.BitmapFontData=O,exports.BitmapText=Z,exports.TextFormat=R,exports.XMLFormat=$,exports.XMLStringFormat=U,exports.autoDetectFormat=q,exports.loadBitmapFont=J;
//# sourceMappingURL=text-bitmap.min.js.map

59

index.d.ts
/// <reference path="./global.d.ts" />
import { Container } from '@pixi/display';
import type { Dict } from '@pixi/utils';
import type { ExtensionMetadata } from '@pixi/core';
import type { IDestroyOptions } from '@pixi/display';
import type { ITextStyle } from '@pixi/text';
import type { Loader } from '@pixi/loaders';
import { LoaderResource } from '@pixi/loaders';
import type { LoaderParser } from '@pixi/assets';
import { Mesh } from '@pixi/mesh';
import { ObservablePoint } from '@pixi/math';
import type { Rectangle } from '@pixi/math';
import { ObservablePoint } from '@pixi/core';
import type { Rectangle } from '@pixi/core';
import type { Renderer } from '@pixi/core';

@@ -17,2 +14,3 @@ import { TextStyle } from '@pixi/text';

import { Texture } from '@pixi/core';
import { utils } from '@pixi/core';

@@ -68,3 +66,3 @@ /**

/** Collection of available/installed fonts. */
static readonly available: Dict<BitmapFont>;
static readonly available: utils.Dict<BitmapFont>;
/** The name of the font face. */

@@ -77,5 +75,5 @@ readonly font: string;

/** The map of characters by character code. */
readonly chars: Dict<IBitmapFontCharacter>;
readonly chars: utils.Dict<IBitmapFontCharacter>;
/** The map of base page textures (i.e., sheets of glyphs). */
readonly pageTextures: Dict<Texture>;
readonly pageTextures: utils.Dict<Texture>;
/** The range of the distance field in pixels. */

@@ -92,3 +90,3 @@ readonly distanceFieldRange: number;

*/
constructor(data: BitmapFontData, textures: Texture[] | Dict<Texture>, ownsTextures?: boolean);
constructor(data: BitmapFontData, textures: Texture[] | utils.Dict<Texture>, ownsTextures?: boolean);
/** Remove references to created glyph textures. */

@@ -107,3 +105,3 @@ destroy(): void;

*/
static install(data: string | XMLDocument | BitmapFontData, textures: Texture | Texture[] | Dict<Texture>, ownsTextures?: boolean): BitmapFont;
static install(data: string | XMLDocument | BitmapFontData, textures: Texture | Texture[] | utils.Dict<Texture>, ownsTextures?: boolean): BitmapFont;
/**

@@ -180,36 +178,2 @@ * Remove bitmap font by name.

/**
* {@link PIXI.Loader Loader} middleware for loading
* bitmap-based fonts suitable for using with {@link PIXI.BitmapText}.
* @memberof PIXI
*/
export declare class BitmapFontLoader {
/** @ignore */
static extension: ExtensionMetadata;
/**
* Called when the plugin is installed.
* @see PIXI.extensions.add
*/
static add(): void;
/**
* Called after a resource is loaded.
* @see PIXI.Loader.loaderMiddleware
* @param this
* @param {PIXI.LoaderResource} resource
* @param {Function} next
*/
static use(this: Loader, resource: LoaderResource, next: (...args: any[]) => void): void;
/**
* Get folder path from a resource.
* @param loader
* @param resource
*/
private static getBaseUrl;
/**
* Replacement for NodeJS's path.dirname
* @param {string} url - Path to get directory for
*/
private static dirname;
}
/**
* A BitmapText object will create a line or multiple lines of text using bitmap font.

@@ -441,3 +405,3 @@ *

page: number;
kerning: Dict<number>;
kerning: utils.Dict<number>;
}

@@ -594,2 +558,5 @@

/** simple loader plugin for loading in bitmap fonts! */
export declare const loadBitmapFont: LoaderParser<string | BitmapFont, any>;
declare interface PageMeshData {

@@ -596,0 +563,0 @@ index: number;

{
"name": "@pixi/text-bitmap",
"version": "6.5.3",
"version": "7.0.0-alpha",
"main": "dist/cjs/text-bitmap.js",
"module": "dist/esm/text-bitmap.mjs",
"bundle": "dist/browser/text-bitmap.js",
"types": "index.d.ts",

@@ -36,18 +35,13 @@ "exports": {

"files": [
"lib",
"dist",
"*.d.ts"
],
"peerDependencies": {
"@pixi/constants": "6.5.3",
"@pixi/core": "6.5.3",
"@pixi/display": "6.5.3",
"@pixi/loaders": "6.5.3",
"@pixi/math": "6.5.3",
"@pixi/mesh": "6.5.3",
"@pixi/settings": "6.5.3",
"@pixi/text": "6.5.3",
"@pixi/utils": "6.5.3"
},
"gitHead": "28e6b2841a65837a5e2873a3d5a9c27cabbe795a"
"pixiRequirements": [
"@pixi/assets",
"@pixi/core",
"@pixi/display",
"@pixi/mesh",
"@pixi/text"
],
"gitHead": "da993226df64b804a9c00ed9ee4d011191467b8a"
}

@@ -12,6 +12,3 @@ # @pixi/text-bitmap

```js
import { BitmapFontLoader } from '@pixi/text-bitmap';
import { extensions } from '@pixi/core';
extensions.add(BitmapFontLoader);
import '@pixi/text-bitmap';
```

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc