/*! * @pixi/text-bitmap - v6.5.10 * Compiled Thu, 06 Jul 2023 15:25:11 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),p=isNaN(c)?f:c;o[l]=p}r[n].push(o)}var d=new u;return r.info.forEach((function(e){return d.info.push({face:e.face,size:parseInt(e.size,10)})})),r.common.forEach((function(e){return d.common.push({lineHeight:parseInt(e.lineHeight,10)})})),r.page.forEach((function(e){return d.page.push({id:parseInt(e.id,10),file:e.file})})),r.char.forEach((function(e){return d.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 d.kerning.push({first:parseInt(e.first,10),second:parseInt(e.second,10),amount:parseInt(e.amount,10)})})),r.distanceField.forEach((function(e){return d.distanceField.push({distanceRange:parseInt(e.distanceRange,10),fieldType:e.fieldType})})),d},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")>-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}(),d=[f,c,p];function g(e){for(var t=0;t=p-I*f){if(0===A)throw new Error("[BitmapFont] textureHeight "+p+"px is too small (fontFamily: '"+g.fontFamily+"', fontSize: "+g.fontSize+"px, char: '"+F+"')");--E,b=null,T=null,w=null,A=0,M=0,S=0}else if(S=Math.max(I+C.fontProperties.descent,S),D*f+M>=y){if(0===M)throw new Error("[BitmapFont] textureWidth "+c+"px is too small (fontFamily: '"+g.fontFamily+"', fontSize: "+g.fontSize+"px, char: '"+F+"')");--E,A+=S*f,A=Math.ceil(A),M=0,S=0}else{x(b,T,C,M,A,f,g);var N=v(C.text);_.char.push({id:N,page:P.length-1,x:M/f,y:A/f,width:D,height:I,xoffset:0,yoffset:0,xadvance:Math.ceil(O-(g.dropShadow?g.dropShadowDistance:0)-(g.stroke?g.strokeThickness:0))}),M+=(D+2*l)*f,M=Math.ceil(M)}}if(!(null==o?void 0:o.skipKerning)){E=0;for(var B=d.length;E0&&l.x>d&&(++E,i.removeItems(u,1+S-E,1+O-S),O=S,S=-1,f.push(P),c.push(u.length>0?u[u.length-1].prevSpaces:0),M=Math.max(M,P),A++,l.x=0,l.y+=a.lineHeight,x=null,C=0)}}else f.push(w),c.push(-1),M=Math.max(M,w),++A,++E,l.x=0,l.y+=a.lineHeight,x=null,C=0}var B=p[p.length-1];"\r"!==B&&"\n"!==B&&(/(?:\s)/.test(B)&&(w=P),f.push(w),M=Math.max(M,w),c.push(-1));var k=[];for(O=0;O<=A;O++){var L=0;"right"===this._align?L=M-f[O]:"center"===this._align?L=(M-f[O])/2:"justify"===this._align&&(L=c[O]<0?0:(M-f[O])/c[O]),k.push(L)}var z=u.length,H={},R=[],j=this._activePagesMeshData;g.push.apply(g,j);for(O=0;O 0.99) {\r\n alpha = 1.0;\r\n }\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}}),X=o.BLEND_MODES.NORMAL_NPM);var Y=new r.Mesh(U,q);Y.blendMode=X,se={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:Y,vertices:null,uvs:null,indices:null}}se.index=0,se.indexCount=0,se.vertexCount=0,se.uvsCount=0,se.total=0;var G=this._textureCache;G[W]=G[W]||new n.Texture(ee.baseTexture),se.mesh.texture=G[W],se.mesh.tint=this._tint,R.push(se),H[W]=se}H[W].total++}for(O=0;O6*V)||se.vertices.length<2*r.Mesh.BATCHABLE_SIZE)se.vertices=new Float32Array(8*V),se.uvs=new Float32Array(8*V),se.indices=new Uint16Array(6*V);else for(var Z=se.total,$=se.vertices,J=4*Z*2;J<$.length;J++)$[J]=0;se.mesh.size=6*V}for(O=0;O