Socket
Socket
Sign inDemoInstall

@pixi/text

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/text - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

6

dist/text.min.js
/*!
* @pixi/text - v5.2.1
* Compiled Tue, 28 Jan 2020 23:33:11 UTC
* @pixi/text - v5.2.2
* Compiled Tue, 21 Apr 2020 03:53:51 UTC
*

@@ -8,3 +8,3 @@ * @pixi/text is licensed under the MIT License.

*/
this.PIXI=this.PIXI||{};var _pixi_text=function(t,e,i,n,r,o){"use strict";var s={LINEAR_VERTICAL:0,LINEAR_HORIZONTAL:1},a={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:s.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},h=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],l=function(t){this.styleID=0,this.reset(),u(this,t,t)},f={align:{configurable:!0},breakWords:{configurable:!0},dropShadow:{configurable:!0},dropShadowAlpha:{configurable:!0},dropShadowAngle:{configurable:!0},dropShadowBlur:{configurable:!0},dropShadowColor:{configurable:!0},dropShadowDistance:{configurable:!0},fill:{configurable:!0},fillGradientType:{configurable:!0},fillGradientStops:{configurable:!0},fontFamily:{configurable:!0},fontSize:{configurable:!0},fontStyle:{configurable:!0},fontVariant:{configurable:!0},fontWeight:{configurable:!0},letterSpacing:{configurable:!0},lineHeight:{configurable:!0},leading:{configurable:!0},lineJoin:{configurable:!0},miterLimit:{configurable:!0},padding:{configurable:!0},stroke:{configurable:!0},strokeThickness:{configurable:!0},textBaseline:{configurable:!0},trim:{configurable:!0},whiteSpace:{configurable:!0},wordWrap:{configurable:!0},wordWrapWidth:{configurable:!0}};function d(t){return"number"==typeof t?o.hex2string(t):("string"==typeof t&&0===t.indexOf("0x")&&(t=t.replace("0x","#")),t)}function c(t){if(Array.isArray(t)){for(var e=0;e<t.length;++e)t[e]=d(t[e]);return t}return d(t)}function u(t,e,i){for(var n in i)Array.isArray(e[n])?t[n]=e[n].slice():t[n]=e[n]}l.prototype.clone=function(){var t={};return u(t,this,a),new l(t)},l.prototype.reset=function(){u(this,a,a)},f.align.get=function(){return this._align},f.align.set=function(t){this._align!==t&&(this._align=t,this.styleID++)},f.breakWords.get=function(){return this._breakWords},f.breakWords.set=function(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)},f.dropShadow.get=function(){return this._dropShadow},f.dropShadow.set=function(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)},f.dropShadowAlpha.get=function(){return this._dropShadowAlpha},f.dropShadowAlpha.set=function(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)},f.dropShadowAngle.get=function(){return this._dropShadowAngle},f.dropShadowAngle.set=function(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)},f.dropShadowBlur.get=function(){return this._dropShadowBlur},f.dropShadowBlur.set=function(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)},f.dropShadowColor.get=function(){return this._dropShadowColor},f.dropShadowColor.set=function(t){var e=c(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)},f.dropShadowDistance.get=function(){return this._dropShadowDistance},f.dropShadowDistance.set=function(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)},f.fill.get=function(){return this._fill},f.fill.set=function(t){var e=c(t);this._fill!==e&&(this._fill=e,this.styleID++)},f.fillGradientType.get=function(){return this._fillGradientType},f.fillGradientType.set=function(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)},f.fillGradientStops.get=function(){return this._fillGradientStops},f.fillGradientStops.set=function(t){(function(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(var i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0})(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)},f.fontFamily.get=function(){return this._fontFamily},f.fontFamily.set=function(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)},f.fontSize.get=function(){return this._fontSize},f.fontSize.set=function(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)},f.fontStyle.get=function(){return this._fontStyle},f.fontStyle.set=function(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)},f.fontVariant.get=function(){return this._fontVariant},f.fontVariant.set=function(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)},f.fontWeight.get=function(){return this._fontWeight},f.fontWeight.set=function(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)},f.letterSpacing.get=function(){return this._letterSpacing},f.letterSpacing.set=function(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)},f.lineHeight.get=function(){return this._lineHeight},f.lineHeight.set=function(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)},f.leading.get=function(){return this._leading},f.leading.set=function(t){this._leading!==t&&(this._leading=t,this.styleID++)},f.lineJoin.get=function(){return this._lineJoin},f.lineJoin.set=function(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)},f.miterLimit.get=function(){return this._miterLimit},f.miterLimit.set=function(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)},f.padding.get=function(){return this._padding},f.padding.set=function(t){this._padding!==t&&(this._padding=t,this.styleID++)},f.stroke.get=function(){return this._stroke},f.stroke.set=function(t){var e=c(t);this._stroke!==e&&(this._stroke=e,this.styleID++)},f.strokeThickness.get=function(){return this._strokeThickness},f.strokeThickness.set=function(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)},f.textBaseline.get=function(){return this._textBaseline},f.textBaseline.set=function(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)},f.trim.get=function(){return this._trim},f.trim.set=function(t){this._trim!==t&&(this._trim=t,this.styleID++)},f.whiteSpace.get=function(){return this._whiteSpace},f.whiteSpace.set=function(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)},f.wordWrap.get=function(){return this._wordWrap},f.wordWrap.set=function(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)},f.wordWrapWidth.get=function(){return this._wordWrapWidth},f.wordWrapWidth.set=function(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)},l.prototype.toFontString=function(){var t="number"==typeof this.fontSize?this.fontSize+"px":this.fontSize,e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(var i=e.length-1;i>=0;i--){var n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&h.indexOf(n)<0&&(n='"'+n+'"'),e[i]=n}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+t+" "+e.join(",")},Object.defineProperties(l.prototype,f);var g=function(t,e,i,n,r,o,s,a,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=s,this.maxLineWidth=a,this.fontProperties=h};g.measureText=function(t,e,i,n){void 0===n&&(n=g._canvas),i=null==i?e.wordWrap:i;var r=e.toFontString(),o=g.measureFont(r);0===o.fontSize&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);var s=n.getContext("2d");s.font=r;for(var a=(i?g.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),h=new Array(a.length),l=0,f=0;f<a.length;f++){var d=s.measureText(a[f]).width+(a[f].length-1)*e.letterSpacing;h[f]=d,l=Math.max(l,d)}var c=l+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);var u=e.lineHeight||o.fontSize+e.strokeThickness,p=Math.max(u,o.fontSize+e.strokeThickness)+(a.length-1)*(u+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new g(t,e,c,p,a,h,u+e.leading,l,o)},g.wordWrap=function(t,e,i){void 0===i&&(i=g._canvas);for(var n=i.getContext("2d"),r=0,o="",s="",a={},h=e.letterSpacing,l=e.whiteSpace,f=g.collapseSpaces(l),d=g.collapseNewlines(l),c=!f,u=e.wordWrapWidth+h,p=g.tokenize(t),_=0;_<p.length;_++){var S=p[_];if(g.isNewline(S)){if(!d){s+=g.addLine(o),c=!f,o="",r=0;continue}S=" "}if(f){var y=g.isBreakingSpace(S),w=g.isBreakingSpace(o[o.length-1]);if(y&&w)continue}var x=g.getFromCache(S,h,a,n);if(x>u)if(""!==o&&(s+=g.addLine(o),o="",r=0),g.canBreakWords(S,e.breakWords))for(var m=g.wordWrapSplit(S),v=0;v<m.length;v++){for(var I=m[v],b=1;m[v+b];){var k=m[v+b],T=I[I.length-1];if(g.canBreakChars(T,k,S,v,e.breakWords))break;I+=k,b++}v+=I.length-1;var W=g.getFromCache(I,h,a,n);W+r>u&&(s+=g.addLine(o),c=!1,o="",r=0),o+=I,r+=W}else{o.length>0&&(s+=g.addLine(o),o="",r=0);var D=_===p.length-1;s+=g.addLine(S,!D),c=!1,o="",r=0}else x+r>u&&(c=!1,s+=g.addLine(o),o="",r=0),(o.length>0||!g.isBreakingSpace(S)||c)&&(o+=S,r+=x)}return s+=g.addLine(o,!1)},g.addLine=function(t,e){return void 0===e&&(e=!0),t=g.trimRight(t),t=e?t+"\n":t},g.getFromCache=function(t,e,i,n){var r=i[t];if(void 0===r){var o=t.length*e;r=n.measureText(t).width+o,i[t]=r}return r},g.collapseSpaces=function(t){return"normal"===t||"pre-line"===t},g.collapseNewlines=function(t){return"normal"===t},g.trimRight=function(t){if("string"!=typeof t)return"";for(var e=t.length-1;e>=0;e--){var i=t[e];if(!g.isBreakingSpace(i))break;t=t.slice(0,-1)}return t},g.isNewline=function(t){return"string"==typeof t&&g._newlines.indexOf(t.charCodeAt(0))>=0},g.isBreakingSpace=function(t){return"string"==typeof t&&g._breakingSpaces.indexOf(t.charCodeAt(0))>=0},g.tokenize=function(t){var e=[],i="";if("string"!=typeof t)return e;for(var n=0;n<t.length;n++){var r=t[n];g.isBreakingSpace(r)||g.isNewline(r)?(""!==i&&(e.push(i),i=""),e.push(r)):i+=r}return""!==i&&e.push(i),e},g.canBreakWords=function(t,e){return e},g.canBreakChars=function(t,e,i,n,r){return!0},g.wordWrapSplit=function(t){return t.split("")},g.measureFont=function(t){if(g._fonts[t])return g._fonts[t];var e={},i=g._canvas,n=g._context;n.font=t;var r=g.METRICS_STRING+g.BASELINE_SYMBOL,o=Math.ceil(n.measureText(r).width),s=Math.ceil(n.measureText(g.BASELINE_SYMBOL).width),a=2*s;s=s*g.BASELINE_MULTIPLIER|0,i.width=o,i.height=a,n.fillStyle="#f00",n.fillRect(0,0,o,a),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(r,0,s);var h=n.getImageData(0,0,o,a).data,l=h.length,f=4*o,d=0,c=0,u=!1;for(d=0;d<s;++d){for(var p=0;p<f;p+=4)if(255!==h[c+p]){u=!0;break}if(u)break;c+=f}for(e.ascent=s-d,c=l-f,u=!1,d=a;d>s;--d){for(var _=0;_<f;_+=4)if(255!==h[c+_]){u=!0;break}if(u)break;c-=f}return e.descent=d-s,e.fontSize=e.ascent+e.descent,g._fonts[t]=e,e},g.clearMetrics=function(t){void 0===t&&(t=""),t?delete g._fonts[t]:g._fonts={}};var p=function(){try{var t=new OffscreenCanvas(0,0),e=t.getContext("2d");return e&&e.measureText?t:document.createElement("canvas")}catch(t){return document.createElement("canvas")}}();p.width=p.height=10,g._canvas=p,g._context=p.getContext("2d"),g._fonts={},g.METRICS_STRING="|ÉqÅ",g.BASELINE_SYMBOL="M",g.BASELINE_MULTIPLIER=1.4,g._newlines=[10,13],g._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];var _={texture:!0,children:!1,baseTexture:!0},S=function(t){function e(e,o,s){(s=s||document.createElement("canvas")).width=3,s.height=3;var a=i.Texture.from(s);a.orig=new r.Rectangle,a.trim=new r.Rectangle,t.call(this,a),this.canvas=s,this.context=this.canvas.getContext("2d"),this._resolution=n.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=o,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var a={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),this.dirty||!t){this._font=this._style.toFontString();var i,n,r=this.context,s=g.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),a=s.width,h=s.height,l=s.lines,f=s.lineHeight,d=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil((Math.max(1,a)+2*e.padding)*this._resolution),this.canvas.height=Math.ceil((Math.max(1,h)+2*e.padding)*this._resolution),r.scale(this._resolution,this._resolution),r.clearRect(0,0,this.canvas.width,this.canvas.height),r.font=this._font,r.lineWidth=e.strokeThickness,r.textBaseline=e.textBaseline,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit;for(var p=e.dropShadow?2:1,_=0;_<p;++_){var S=e.dropShadow&&0===_,y=S?2*h:0,w=y*this.resolution;if(S){r.fillStyle="black",r.strokeStyle="black";var x=e.dropShadowColor,m=o.hex2rgb("number"==typeof x?x:o.string2hex(x));r.shadowColor="rgba("+255*m[0]+","+255*m[1]+","+255*m[2]+","+e.dropShadowAlpha+")",r.shadowBlur=e.dropShadowBlur,r.shadowOffsetX=Math.cos(e.dropShadowAngle)*e.dropShadowDistance,r.shadowOffsetY=Math.sin(e.dropShadowAngle)*e.dropShadowDistance+w}else r.fillStyle=this._generateFillStyle(e,l),r.strokeStyle=e.stroke,r.shadowColor=0,r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0;for(var v=0;v<l.length;v++)i=e.strokeThickness/2,n=e.strokeThickness/2+v*f+u.ascent,"right"===e.align?i+=c-d[v]:"center"===e.align&&(i+=(c-d[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(l[v],i+e.padding,n+e.padding-y,!0),e.fill&&this.drawLetterSpacing(l[v],i+e.padding,n+e.padding-y)}this.updateTexture()}},e.prototype.drawLetterSpacing=function(t,e,i,n){void 0===n&&(n=!1);var r=this._style.letterSpacing;if(0!==r)for(var o=e,s=Array.from?Array.from(t):t.split(""),a=this.context.measureText(t).width,h=0,l=0;l<s.length;++l){var f=s[l];n?this.context.strokeText(f,o,i):this.context.fillText(f,o,i),o+=a-(h=this.context.measureText(t.substring(l+1)).width)+r,a=h}else n?this.context.strokeText(t,e,i):this.context.fillText(t,e,i)},e.prototype.updateTexture=function(){var t=this.canvas;if(this._style.trim){var e=o.trimCanvas(t);e.data&&(t.width=e.width,t.height=e.height,this.context.putImageData(e.data,0,0))}var i=this._texture,n=this._style,r=n.trim?0:n.padding,s=i.baseTexture;i.trim.width=i._frame.width=Math.ceil(t.width/this._resolution),i.trim.height=i._frame.height=Math.ceil(t.height/this._resolution),i.trim.x=-r,i.trim.y=-r,i.orig.width=i._frame.width-2*r,i.orig.height=i._frame.height-2*r,this._onTextureUpdate(),s.setRealSize(t.width,t.height,this._resolution),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype._generateFillStyle=function(t,e){if(!Array.isArray(t.fill))return t.fill;if(1===t.fill.length)return t.fill[0];var i,n,r,o,a=t.dropShadow?t.dropShadowDistance:0,h=Math.ceil(this.canvas.width/this._resolution)-a,l=Math.ceil(this.canvas.height/this._resolution)-a,f=t.fill.slice(),d=t.fillGradientStops.slice();if(!d.length)for(var c=f.length+1,u=1;u<c;++u)d.push(u/c);if(f.unshift(t.fill[0]),d.unshift(0),f.push(t.fill[t.fill.length-1]),d.push(1),t.fillGradientType===s.LINEAR_VERTICAL){i=this.context.createLinearGradient(h/2,0,h/2,l),n=(f.length+1)*e.length,r=0;for(var g=0;g<e.length;g++){r+=1;for(var p=0;p<f.length;p++)o="number"==typeof d[p]?d[p]/e.length+g/e.length:r/n,i.addColorStop(o,f[p]),r++}}else{i=this.context.createLinearGradient(0,l/2,h,l/2),n=f.length+1,r=1;for(var _=0;_<f.length;_++)o="number"==typeof d[_]?d[_]:r/n,i.addColorStop(o,f[_]),r++}return i},e.prototype.destroy=function(e){"boolean"==typeof e&&(e={children:e}),e=Object.assign({},_,e),t.prototype.destroy.call(this,e),this.context=null,this.canvas=null,this._style=null},a.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},a.width.set=function(t){this.updateText(!0);var e=o.sign(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t},a.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},a.height.set=function(t){this.updateText(!0);var e=o.sign(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t},a.style.get=function(){return this._style},a.style.set=function(t){t=t||{},this._style=t instanceof l?t:new l(t),this.localStyleID=-1,this.dirty=!0},a.text.get=function(){return this._text},a.text.set=function(t){t=String(null==t?"":t),this._text!==t&&(this._text=t,this.dirty=!0)},a.resolution.get=function(){return this._resolution},a.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},Object.defineProperties(e.prototype,a),e}(e.Sprite);return t.TEXT_GRADIENT=s,t.Text=S,t.TextMetrics=g,t.TextStyle=l,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils);Object.assign(this.PIXI,_pixi_text);
this.PIXI=this.PIXI||{};var _pixi_text=function(t,e,i,n,r,o){"use strict";var s={LINEAR_VERTICAL:0,LINEAR_HORIZONTAL:1},a={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:s.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},h=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],l=function(t){this.styleID=0,this.reset(),u(this,t,t)},f={align:{configurable:!0},breakWords:{configurable:!0},dropShadow:{configurable:!0},dropShadowAlpha:{configurable:!0},dropShadowAngle:{configurable:!0},dropShadowBlur:{configurable:!0},dropShadowColor:{configurable:!0},dropShadowDistance:{configurable:!0},fill:{configurable:!0},fillGradientType:{configurable:!0},fillGradientStops:{configurable:!0},fontFamily:{configurable:!0},fontSize:{configurable:!0},fontStyle:{configurable:!0},fontVariant:{configurable:!0},fontWeight:{configurable:!0},letterSpacing:{configurable:!0},lineHeight:{configurable:!0},leading:{configurable:!0},lineJoin:{configurable:!0},miterLimit:{configurable:!0},padding:{configurable:!0},stroke:{configurable:!0},strokeThickness:{configurable:!0},textBaseline:{configurable:!0},trim:{configurable:!0},whiteSpace:{configurable:!0},wordWrap:{configurable:!0},wordWrapWidth:{configurable:!0}};function d(t){return"number"==typeof t?o.hex2string(t):("string"==typeof t&&0===t.indexOf("0x")&&(t=t.replace("0x","#")),t)}function c(t){if(Array.isArray(t)){for(var e=0;e<t.length;++e)t[e]=d(t[e]);return t}return d(t)}function u(t,e,i){for(var n in i)Array.isArray(e[n])?t[n]=e[n].slice():t[n]=e[n]}l.prototype.clone=function(){var t={};return u(t,this,a),new l(t)},l.prototype.reset=function(){u(this,a,a)},f.align.get=function(){return this._align},f.align.set=function(t){this._align!==t&&(this._align=t,this.styleID++)},f.breakWords.get=function(){return this._breakWords},f.breakWords.set=function(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)},f.dropShadow.get=function(){return this._dropShadow},f.dropShadow.set=function(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)},f.dropShadowAlpha.get=function(){return this._dropShadowAlpha},f.dropShadowAlpha.set=function(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)},f.dropShadowAngle.get=function(){return this._dropShadowAngle},f.dropShadowAngle.set=function(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)},f.dropShadowBlur.get=function(){return this._dropShadowBlur},f.dropShadowBlur.set=function(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)},f.dropShadowColor.get=function(){return this._dropShadowColor},f.dropShadowColor.set=function(t){var e=c(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)},f.dropShadowDistance.get=function(){return this._dropShadowDistance},f.dropShadowDistance.set=function(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)},f.fill.get=function(){return this._fill},f.fill.set=function(t){var e=c(t);this._fill!==e&&(this._fill=e,this.styleID++)},f.fillGradientType.get=function(){return this._fillGradientType},f.fillGradientType.set=function(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)},f.fillGradientStops.get=function(){return this._fillGradientStops},f.fillGradientStops.set=function(t){(function(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(var i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0})(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)},f.fontFamily.get=function(){return this._fontFamily},f.fontFamily.set=function(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)},f.fontSize.get=function(){return this._fontSize},f.fontSize.set=function(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)},f.fontStyle.get=function(){return this._fontStyle},f.fontStyle.set=function(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)},f.fontVariant.get=function(){return this._fontVariant},f.fontVariant.set=function(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)},f.fontWeight.get=function(){return this._fontWeight},f.fontWeight.set=function(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)},f.letterSpacing.get=function(){return this._letterSpacing},f.letterSpacing.set=function(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)},f.lineHeight.get=function(){return this._lineHeight},f.lineHeight.set=function(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)},f.leading.get=function(){return this._leading},f.leading.set=function(t){this._leading!==t&&(this._leading=t,this.styleID++)},f.lineJoin.get=function(){return this._lineJoin},f.lineJoin.set=function(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)},f.miterLimit.get=function(){return this._miterLimit},f.miterLimit.set=function(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)},f.padding.get=function(){return this._padding},f.padding.set=function(t){this._padding!==t&&(this._padding=t,this.styleID++)},f.stroke.get=function(){return this._stroke},f.stroke.set=function(t){var e=c(t);this._stroke!==e&&(this._stroke=e,this.styleID++)},f.strokeThickness.get=function(){return this._strokeThickness},f.strokeThickness.set=function(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)},f.textBaseline.get=function(){return this._textBaseline},f.textBaseline.set=function(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)},f.trim.get=function(){return this._trim},f.trim.set=function(t){this._trim!==t&&(this._trim=t,this.styleID++)},f.whiteSpace.get=function(){return this._whiteSpace},f.whiteSpace.set=function(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)},f.wordWrap.get=function(){return this._wordWrap},f.wordWrap.set=function(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)},f.wordWrapWidth.get=function(){return this._wordWrapWidth},f.wordWrapWidth.set=function(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)},l.prototype.toFontString=function(){var t="number"==typeof this.fontSize?this.fontSize+"px":this.fontSize,e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(var i=e.length-1;i>=0;i--){var n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&h.indexOf(n)<0&&(n='"'+n+'"'),e[i]=n}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+t+" "+e.join(",")},Object.defineProperties(l.prototype,f);var g=function(t,e,i,n,r,o,s,a,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=s,this.maxLineWidth=a,this.fontProperties=h};g.measureText=function(t,e,i,n){void 0===n&&(n=g._canvas),i=null==i?e.wordWrap:i;var r=e.toFontString(),o=g.measureFont(r);0===o.fontSize&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);var s=n.getContext("2d");s.font=r;for(var a=(i?g.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),h=new Array(a.length),l=0,f=0;f<a.length;f++){var d=s.measureText(a[f]).width+(a[f].length-1)*e.letterSpacing;h[f]=d,l=Math.max(l,d)}var c=l+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);var u=e.lineHeight||o.fontSize+e.strokeThickness,p=Math.max(u,o.fontSize+e.strokeThickness)+(a.length-1)*(u+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new g(t,e,c,p,a,h,u+e.leading,l,o)},g.wordWrap=function(t,e,i){void 0===i&&(i=g._canvas);for(var n=i.getContext("2d"),r=0,o="",s="",a={},h=e.letterSpacing,l=e.whiteSpace,f=g.collapseSpaces(l),d=g.collapseNewlines(l),c=!f,u=e.wordWrapWidth+h,p=g.tokenize(t),_=0;_<p.length;_++){var S=p[_];if(g.isNewline(S)){if(!d){s+=g.addLine(o),c=!f,o="",r=0;continue}S=" "}if(f){var y=g.isBreakingSpace(S),w=g.isBreakingSpace(o[o.length-1]);if(y&&w)continue}var x=g.getFromCache(S,h,a,n);if(x>u)if(""!==o&&(s+=g.addLine(o),o="",r=0),g.canBreakWords(S,e.breakWords))for(var v=g.wordWrapSplit(S),m=0;m<v.length;m++){for(var I=v[m],b=1;v[m+b];){var k=v[m+b],T=I[I.length-1];if(g.canBreakChars(T,k,S,m,e.breakWords))break;I+=k,b++}m+=I.length-1;var W=g.getFromCache(I,h,a,n);W+r>u&&(s+=g.addLine(o),c=!1,o="",r=0),o+=I,r+=W}else{o.length>0&&(s+=g.addLine(o),o="",r=0);var D=_===p.length-1;s+=g.addLine(S,!D),c=!1,o="",r=0}else x+r>u&&(c=!1,s+=g.addLine(o),o="",r=0),(o.length>0||!g.isBreakingSpace(S)||c)&&(o+=S,r+=x)}return s+=g.addLine(o,!1)},g.addLine=function(t,e){return void 0===e&&(e=!0),t=g.trimRight(t),t=e?t+"\n":t},g.getFromCache=function(t,e,i,n){var r=i[t];if(void 0===r){var o=t.length*e;r=n.measureText(t).width+o,i[t]=r}return r},g.collapseSpaces=function(t){return"normal"===t||"pre-line"===t},g.collapseNewlines=function(t){return"normal"===t},g.trimRight=function(t){if("string"!=typeof t)return"";for(var e=t.length-1;e>=0;e--){var i=t[e];if(!g.isBreakingSpace(i))break;t=t.slice(0,-1)}return t},g.isNewline=function(t){return"string"==typeof t&&g._newlines.indexOf(t.charCodeAt(0))>=0},g.isBreakingSpace=function(t){return"string"==typeof t&&g._breakingSpaces.indexOf(t.charCodeAt(0))>=0},g.tokenize=function(t){var e=[],i="";if("string"!=typeof t)return e;for(var n=0;n<t.length;n++){var r=t[n];g.isBreakingSpace(r)||g.isNewline(r)?(""!==i&&(e.push(i),i=""),e.push(r)):i+=r}return""!==i&&e.push(i),e},g.canBreakWords=function(t,e){return e},g.canBreakChars=function(t,e,i,n,r){return!0},g.wordWrapSplit=function(t){return t.split("")},g.measureFont=function(t){if(g._fonts[t])return g._fonts[t];var e={},i=g._canvas,n=g._context;n.font=t;var r=g.METRICS_STRING+g.BASELINE_SYMBOL,o=Math.ceil(n.measureText(r).width),s=Math.ceil(n.measureText(g.BASELINE_SYMBOL).width),a=2*s;s=s*g.BASELINE_MULTIPLIER|0,i.width=o,i.height=a,n.fillStyle="#f00",n.fillRect(0,0,o,a),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(r,0,s);var h=n.getImageData(0,0,o,a).data,l=h.length,f=4*o,d=0,c=0,u=!1;for(d=0;d<s;++d){for(var p=0;p<f;p+=4)if(255!==h[c+p]){u=!0;break}if(u)break;c+=f}for(e.ascent=s-d,c=l-f,u=!1,d=a;d>s;--d){for(var _=0;_<f;_+=4)if(255!==h[c+_]){u=!0;break}if(u)break;c-=f}return e.descent=d-s,e.fontSize=e.ascent+e.descent,g._fonts[t]=e,e},g.clearMetrics=function(t){void 0===t&&(t=""),t?delete g._fonts[t]:g._fonts={}};var p=function(){try{var t=new OffscreenCanvas(0,0),e=t.getContext("2d");return e&&e.measureText?t:document.createElement("canvas")}catch(t){return document.createElement("canvas")}}();p.width=p.height=10,g._canvas=p,g._context=p.getContext("2d"),g._fonts={},g.METRICS_STRING="|ÉqÅ",g.BASELINE_SYMBOL="M",g.BASELINE_MULTIPLIER=1.4,g._newlines=[10,13],g._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];var _={texture:!0,children:!1,baseTexture:!0},S=function(t){function e(e,o,s){var a=!1;s||(s=document.createElement("canvas"),a=!0),s.width=3,s.height=3;var h=i.Texture.from(s);h.orig=new r.Rectangle,h.trim=new r.Rectangle,t.call(this,h),this._ownCanvas=a,this.canvas=s,this.context=this.canvas.getContext("2d"),this._resolution=n.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=o,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var a={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),this.dirty||!t){this._font=this._style.toFontString();var i,n,r=this.context,s=g.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),a=s.width,h=s.height,l=s.lines,f=s.lineHeight,d=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil((Math.max(1,a)+2*e.padding)*this._resolution),this.canvas.height=Math.ceil((Math.max(1,h)+2*e.padding)*this._resolution),r.scale(this._resolution,this._resolution),r.clearRect(0,0,this.canvas.width,this.canvas.height),r.font=this._font,r.lineWidth=e.strokeThickness,r.textBaseline=e.textBaseline,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit;for(var p=e.dropShadow?2:1,_=0;_<p;++_){var S=e.dropShadow&&0===_,y=S?2*h:0,w=y*this.resolution;if(S){r.fillStyle="black",r.strokeStyle="black";var x=e.dropShadowColor,v=o.hex2rgb("number"==typeof x?x:o.string2hex(x));r.shadowColor="rgba("+255*v[0]+","+255*v[1]+","+255*v[2]+","+e.dropShadowAlpha+")",r.shadowBlur=e.dropShadowBlur,r.shadowOffsetX=Math.cos(e.dropShadowAngle)*e.dropShadowDistance,r.shadowOffsetY=Math.sin(e.dropShadowAngle)*e.dropShadowDistance+w}else r.fillStyle=this._generateFillStyle(e,l,s),r.strokeStyle=e.stroke,r.shadowColor=0,r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0;for(var m=0;m<l.length;m++)i=e.strokeThickness/2,n=e.strokeThickness/2+m*f+u.ascent,"right"===e.align?i+=c-d[m]:"center"===e.align&&(i+=(c-d[m])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(l[m],i+e.padding,n+e.padding-y,!0),e.fill&&this.drawLetterSpacing(l[m],i+e.padding,n+e.padding-y)}this.updateTexture()}},e.prototype.drawLetterSpacing=function(t,e,i,n){void 0===n&&(n=!1);var r=this._style.letterSpacing;if(0!==r)for(var o=e,s=Array.from?Array.from(t):t.split(""),a=this.context.measureText(t).width,h=0,l=0;l<s.length;++l){var f=s[l];n?this.context.strokeText(f,o,i):this.context.fillText(f,o,i),o+=a-(h=this.context.measureText(t.substring(l+1)).width)+r,a=h}else n?this.context.strokeText(t,e,i):this.context.fillText(t,e,i)},e.prototype.updateTexture=function(){var t=this.canvas;if(this._style.trim){var e=o.trimCanvas(t);e.data&&(t.width=e.width,t.height=e.height,this.context.putImageData(e.data,0,0))}var i=this._texture,n=this._style,r=n.trim?0:n.padding,s=i.baseTexture;i.trim.width=i._frame.width=Math.ceil(t.width/this._resolution),i.trim.height=i._frame.height=Math.ceil(t.height/this._resolution),i.trim.x=-r,i.trim.y=-r,i.orig.width=i._frame.width-2*r,i.orig.height=i._frame.height-2*r,this._onTextureUpdate(),s.setRealSize(t.width,t.height,this._resolution),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype._generateFillStyle=function(t,e,i){if(!Array.isArray(t.fill))return t.fill;if(1===t.fill.length)return t.fill[0];var n,r=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,a=Math.ceil(this.canvas.width/this._resolution)-r-2*o,h=Math.ceil(this.canvas.height/this._resolution)-r-2*o,l=t.fill.slice(),f=t.fillGradientStops.slice();if(!f.length)for(var d=l.length+1,c=1;c<d;++c)f.push(c/d);if(l.unshift(t.fill[0]),f.unshift(0),l.push(t.fill[t.fill.length-1]),f.push(1),t.fillGradientType===s.LINEAR_VERTICAL){n=this.context.createLinearGradient(a/2,o,a/2,h+o);for(var u=0,g=(i.fontProperties.fontSize+t.strokeThickness)/h,p=0;p<e.length;p++)for(var _=i.lineHeight*p,S=0;S<l.length;S++){var y=_/h+("number"==typeof f[S]?f[S]:S/l.length)*g,w=Math.max(u,y);w=Math.min(w,1),n.addColorStop(w,l[S]),u=w}}else{n=this.context.createLinearGradient(o,h/2,a+o,h/2);for(var x=l.length+1,v=1,m=0;m<l.length;m++){var I=void 0;I="number"==typeof f[m]?f[m]:v/x,n.addColorStop(I,l[m]),v++}}return n},e.prototype.destroy=function(e){"boolean"==typeof e&&(e={children:e}),e=Object.assign({},_,e),t.prototype.destroy.call(this,e),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null},a.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},a.width.set=function(t){this.updateText(!0);var e=o.sign(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t},a.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},a.height.set=function(t){this.updateText(!0);var e=o.sign(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t},a.style.get=function(){return this._style},a.style.set=function(t){t=t||{},this._style=t instanceof l?t:new l(t),this.localStyleID=-1,this.dirty=!0},a.text.get=function(){return this._text},a.text.set=function(t){t=String(null==t?"":t),this._text!==t&&(this._text=t,this.dirty=!0)},a.resolution.get=function(){return this._resolution},a.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},Object.defineProperties(e.prototype,a),e}(e.Sprite);return t.TEXT_GRADIENT=s,t.Text=S,t.TextMetrics=g,t.TextStyle=l,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils);Object.assign(this.PIXI,_pixi_text);
//# sourceMappingURL=text.min.js.map
{
"name": "@pixi/text",
"version": "5.2.1",
"version": "5.2.2",
"main": "lib/text.js",

@@ -27,14 +27,14 @@ "module": "lib/text.es.js",

"dependencies": {
"@pixi/core": "5.2.1",
"@pixi/math": "5.2.1",
"@pixi/settings": "5.2.1",
"@pixi/sprite": "5.2.1",
"@pixi/utils": "5.2.1"
"@pixi/core": "5.2.2",
"@pixi/math": "5.2.2",
"@pixi/settings": "5.2.2",
"@pixi/sprite": "5.2.2",
"@pixi/utils": "5.2.2"
},
"devDependencies": {
"@pixi/canvas-display": "5.2.1",
"@pixi/canvas-renderer": "5.2.1",
"@pixi/canvas-sprite": "5.2.1"
"@pixi/canvas-display": "5.2.2",
"@pixi/canvas-renderer": "5.2.2",
"@pixi/canvas-sprite": "5.2.2"
},
"gitHead": "b56b4fca1c169f0e6d2a0472251ba1f7399bb4a3"
"gitHead": "c163c466c20f2286b6e41ab90d68a03aad2051d4"
}

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 too big to display

Sorry, the diff of this file is not supported yet

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

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