Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/text

Package Overview
Dependencies
Maintainers
3
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.0.0-alpha.3 to 5.0.0-rc

220

lib/text.es.js
/*!
* @pixi/text - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/text - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -10,5 +10,5 @@ * @pixi/text is licensed under the MIT License.

import { Texture } from '@pixi/core';
import { settings as settings$1 } from '@pixi/settings';
import { settings } from '@pixi/settings';
import { Rectangle } from '@pixi/math';
import { hex2string, sign, trimCanvas } from '@pixi/utils';
import { hex2string, hex2rgb, string2hex, trimCanvas, sign } from '@pixi/utils';

@@ -32,3 +32,2 @@ /**

// disabling eslint for now, going to rewrite this in v5
/* eslint-disable */

@@ -68,6 +67,8 @@ var defaultStyle = {

/**
* A TextStyle Object decorates a Text Object. It can be shared between
* multiple Text objects. Changing the style will update all text objects using it.
* It can be generated [here](https://pixijs.io/pixi-text-style).
* A TextStyle Object contains information to decorate a Text objects.
*
* An instance can be shared between multiple Text objects; then changing the style will update all text objects using it.
*
* A tool can be used to generate a text style [here](https://pixijs.io/pixi-text-style).
*
* @class

@@ -796,3 +797,3 @@ * @memberof PIXI

* @class
* @memberOf PIXI
* @memberof PIXI
*/

@@ -825,5 +826,14 @@ var TextMetrics = function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties)

wordWrap = wordWrap || style.wordWrap;
wordWrap = (wordWrap === undefined || wordWrap === null) ? style.wordWrap : wordWrap;
var font = style.toFontString();
var fontProperties = TextMetrics.measureFont(font);
// fallback in case UA disallow canvas data extraction
// (toDataURI, getImageData functions)
if (fontProperties.fontSize === 0)
{
fontProperties.fontSize = style.fontSize;
fontProperties.ascent = style.fontSize;
}
var context = canvas.getContext('2d');

@@ -1211,3 +1221,3 @@

* @param {string} text The text
* @return {array} A tokenized array
* @return {string[]} A tokenized array
*/

@@ -1293,3 +1303,3 @@ TextMetrics.tokenize = function tokenize (text)

* @param {string} font - String representing the style of the font
* @return {PIXI.TextMetrics~FontMetrics} Font properties object
* @return {PIXI.TextMetrics.FontMetrics} Font properties object
*/

@@ -1416,7 +1426,9 @@ TextMetrics.measureFont = function measureFont (font)

* Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}.
* @class FontMetrics
* @memberof PIXI.TextMetrics~
*
* @typedef {object} FontMetrics
* @property {number} ascent - The ascent distance
* @property {number} descent - The descent distance
* @property {number} fontSize - Font size from ascent to descent
* @memberof PIXI.TextMetrics
* @private
*/

@@ -1445,3 +1457,3 @@

/**
* Cache of PIXI.TextMetrics~FontMetrics objects.
* Cache of {@see PIXI.TextMetrics.FontMetrics} objects.
* @memberof PIXI.TextMetrics

@@ -1516,2 +1528,3 @@ * @type {Object}

/* eslint max-depth: [2, 8] */
var defaultDestroyOptions = {

@@ -1524,5 +1537,15 @@ texture: true,

/**
* A Text Object will create a line or multiple lines of text. To split a line you can use '\n' in your text string,
* or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object.
* A Text Object will create a line or multiple lines of text.
*
* The text is created using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API).
*
* The primary advantage of this class over BitmapText is that you have great control over the style of the next,
* which you can change at runtime.
*
* The primary disadvantages is that each piece of text has it's own texture, which can use more memory.
* When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.
*
* To split a line you can use '\n' in your text string, or, on the `style` object,
* change its `wordWrap` property to true and and give the `wordWrapWidth` property a value.
*
* A Text can be created directly from a string and a style object,

@@ -1539,3 +1562,3 @@ * which can be generated [here](https://pixijs.io/pixi-text-style).

*/
var Text = (function (Sprite$$1) {
var Text = /*@__PURE__*/(function (Sprite$$1) {
function Text(text, style, canvas)

@@ -1548,3 +1571,3 @@ {

var texture = Texture.from(canvas, settings$1.SCALE_MODE, 'text');
var texture = Texture.from(canvas);

@@ -1556,5 +1579,2 @@ texture.orig = new Rectangle();

// base texture is already automatically added to the cache, now adding the actual texture
Texture.addToCache(this._texture, this._texture.baseTexture.textureCacheIds[0]);
/**

@@ -1574,7 +1594,9 @@ * The canvas element that everything is drawn to

/**
* The resolution / device pixel ratio of the canvas. This is set automatically by the renderer.
* The resolution / device pixel ratio of the canvas.
* This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
* @member {number}
* @default 1
*/
this.resolution = settings$1.RESOLUTION;
this._resolution = settings.RESOLUTION;
this._autoResolution = true;

@@ -1622,3 +1644,3 @@ /**

var prototypeAccessors = { width: { configurable: true },height: { configurable: true },style: { configurable: true },text: { configurable: true } };
var prototypeAccessors = { width: { configurable: true },height: { configurable: true },style: { configurable: true },text: { configurable: true },resolution: { configurable: true } };

@@ -1633,4 +1655,2 @@ /**

{
var this$1 = this;
var style = this._style;

@@ -1653,3 +1673,3 @@

var context = this.context;
var measured = TextMetrics.measureText(this._text, this._style, this._style.wordWrap, this.canvas);
var measured = TextMetrics.measureText(this._text || ' ', this._style, this._style.wordWrap, this.canvas);
var width = measured.width;

@@ -1663,6 +1683,6 @@ var height = measured.height;

this.canvas.width = Math.ceil((Math.max(1, width) + (style.padding * 2)) * this.resolution);
this.canvas.height = Math.ceil((Math.max(1, height) + (style.padding * 2)) * this.resolution);
this.canvas.width = Math.ceil((Math.max(1, width) + (style.padding * 2)) * this._resolution);
this.canvas.height = Math.ceil((Math.max(1, height) + (style.padding * 2)) * this._resolution);
context.scale(this.resolution, this.resolution);
context.scale(this._resolution, this._resolution);

@@ -1683,53 +1703,18 @@ context.clearRect(0, 0, this.canvas.width, this.canvas.height);

{
context.fillStyle = style.dropShadowColor;
context.globalAlpha = style.dropShadowAlpha;
var dropShadowColor = style.dropShadowColor;
var rgb = hex2rgb(typeof dropShadowColor === 'number' ? dropShadowColor : string2hex(dropShadowColor));
context.shadowColor = "rgba(" + (rgb[0] * 255) + "," + (rgb[1] * 255) + "," + (rgb[2] * 255) + "," + (style.dropShadowAlpha) + ")";
context.shadowBlur = style.dropShadowBlur;
if (style.dropShadowBlur > 0)
{
context.shadowColor = style.dropShadowColor;
}
var xShadowOffset = Math.cos(style.dropShadowAngle) * style.dropShadowDistance;
var yShadowOffset = Math.sin(style.dropShadowAngle) * style.dropShadowDistance;
for (var i = 0; i < lines.length; i++)
{
linePositionX = style.strokeThickness / 2;
linePositionY = ((style.strokeThickness / 2) + (i * lineHeight)) + fontProperties.ascent;
if (style.align === 'right')
{
linePositionX += maxLineWidth - lineWidths[i];
}
else if (style.align === 'center')
{
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
}
if (style.fill)
{
this$1.drawLetterSpacing(
lines[i],
linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding
);
if (style.stroke && style.strokeThickness)
{
context.strokeStyle = style.dropShadowColor;
this$1.drawLetterSpacing(
lines[i],
linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding,
true
);
context.strokeStyle = style.stroke;
}
}
}
context.shadowOffsetX = Math.cos(style.dropShadowAngle) * style.dropShadowDistance;
context.shadowOffsetY = Math.sin(style.dropShadowAngle) * style.dropShadowDistance;
}
else
{
context.shadowColor = 0;
context.shadowBlur = 0;
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
}
// reset the shadow blur and alpha that was set by the drop shadow, for the regular text
context.shadowBlur = 0;
context.globalAlpha = 1;
// set canvas text styles

@@ -1739,14 +1724,14 @@ context.fillStyle = this._generateFillStyle(style, lines);

// draw lines line by line
for (var i$1 = 0; i$1 < lines.length; i$1++)
for (var i = 0; i < lines.length; i++)
{
linePositionX = style.strokeThickness / 2;
linePositionY = ((style.strokeThickness / 2) + (i$1 * lineHeight)) + fontProperties.ascent;
linePositionY = ((style.strokeThickness / 2) + (i * lineHeight)) + fontProperties.ascent;
if (style.align === 'right')
{
linePositionX += maxLineWidth - lineWidths[i$1];
linePositionX += maxLineWidth - lineWidths[i];
}
else if (style.align === 'center')
{
linePositionX += (maxLineWidth - lineWidths[i$1]) / 2;
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
}

@@ -1756,4 +1741,4 @@

{
this$1.drawLetterSpacing(
lines[i$1],
this.drawLetterSpacing(
lines[i],
linePositionX + style.padding,

@@ -1767,4 +1752,4 @@ linePositionY + style.padding,

{
this$1.drawLetterSpacing(
lines[i$1],
this.drawLetterSpacing(
lines[i],
linePositionX + style.padding,

@@ -1790,3 +1775,2 @@ linePositionY + style.padding

{
var this$1 = this;
if ( isStroke === void 0 ) isStroke = false;

@@ -1823,9 +1807,9 @@

{
this$1.context.strokeText(current, currentPosition, y);
this.context.strokeText(current, currentPosition, y);
}
else
{
this$1.context.fillText(current, currentPosition, y);
this.context.fillText(current, currentPosition, y);
}
currentPosition += this$1.context.measureText(current).width + letterSpacing;
currentPosition += this.context.measureText(current).width + letterSpacing;
}

@@ -1847,5 +1831,8 @@ };

canvas.width = trimmed.width;
canvas.height = trimmed.height;
this.context.putImageData(trimmed.data, 0, 0);
if (trimmed.data)
{
canvas.width = trimmed.width;
canvas.height = trimmed.height;
this.context.putImageData(trimmed.data, 0, 0);
}
}

@@ -1858,4 +1845,4 @@

texture.trim.width = texture._frame.width = canvas.width / this.resolution;
texture.trim.height = texture._frame.height = canvas.height / this.resolution;
texture.trim.width = texture._frame.width = canvas.width / this._resolution;
texture.trim.height = texture._frame.height = canvas.height / this._resolution;
texture.trim.x = -padding;

@@ -1870,3 +1857,3 @@ texture.trim.y = -padding;

baseTexture.setRealSize(canvas.width, canvas.height, this.resolution);
baseTexture.setRealSize(canvas.width, canvas.height, this._resolution);

@@ -1883,5 +1870,5 @@ this.dirty = false;

{
if (this.resolution !== renderer.resolution)
if (this._autoResolution && this._resolution !== renderer.resolution)
{
this.resolution = renderer.resolution;
this._resolution = renderer.resolution;
this.dirty = true;

@@ -1903,5 +1890,5 @@ }

{
if (this.resolution !== renderer.resolution)
if (this._autoResolution && this._resolution !== renderer.resolution)
{
this.resolution = renderer.resolution;
this._resolution = renderer.resolution;
this.dirty = true;

@@ -1930,2 +1917,3 @@ }

* calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account.
* @protected
*/

@@ -1977,4 +1965,4 @@ Text.prototype._calculateBounds = function _calculateBounds ()

var width = this.canvas.width / this.resolution;
var height = this.canvas.height / this.resolution;
var width = this.canvas.width / this._resolution;
var height = this.canvas.height / this._resolution;

@@ -2173,3 +2161,3 @@ // make a copy of the style settings, so we can manipulate them later

{
text = String(text === '' || text === null || text === undefined ? ' ' : text);
text = String(text === null || text === undefined ? '' : text);

@@ -2184,2 +2172,26 @@ if (this._text === text)

/**
* The resolution / device pixel ratio of the canvas.
* This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
* @member {number}
* @default 1
*/
prototypeAccessors.resolution.get = function ()
{
return this._resolution;
};
prototypeAccessors.resolution.set = function (value) // eslint-disable-line require-jsdoc
{
this._autoResolution = false;
if (this._resolution === value)
{
return;
}
this._resolution = value;
this.dirty = true;
};
Object.defineProperties( Text.prototype, prototypeAccessors );

@@ -2186,0 +2198,0 @@

/*!
* @pixi/text - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/text - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

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

// disabling eslint for now, going to rewrite this in v5
/* eslint-disable */

@@ -71,6 +70,8 @@ var defaultStyle = {

/**
* A TextStyle Object decorates a Text Object. It can be shared between
* multiple Text objects. Changing the style will update all text objects using it.
* It can be generated [here](https://pixijs.io/pixi-text-style).
* A TextStyle Object contains information to decorate a Text objects.
*
* An instance can be shared between multiple Text objects; then changing the style will update all text objects using it.
*
* A tool can be used to generate a text style [here](https://pixijs.io/pixi-text-style).
*
* @class

@@ -799,3 +800,3 @@ * @memberof PIXI

* @class
* @memberOf PIXI
* @memberof PIXI
*/

@@ -828,5 +829,14 @@ var TextMetrics = function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties)

wordWrap = wordWrap || style.wordWrap;
wordWrap = (wordWrap === undefined || wordWrap === null) ? style.wordWrap : wordWrap;
var font = style.toFontString();
var fontProperties = TextMetrics.measureFont(font);
// fallback in case UA disallow canvas data extraction
// (toDataURI, getImageData functions)
if (fontProperties.fontSize === 0)
{
fontProperties.fontSize = style.fontSize;
fontProperties.ascent = style.fontSize;
}
var context = canvas.getContext('2d');

@@ -1214,3 +1224,3 @@

* @param {string} text The text
* @return {array} A tokenized array
* @return {string[]} A tokenized array
*/

@@ -1296,3 +1306,3 @@ TextMetrics.tokenize = function tokenize (text)

* @param {string} font - String representing the style of the font
* @return {PIXI.TextMetrics~FontMetrics} Font properties object
* @return {PIXI.TextMetrics.FontMetrics} Font properties object
*/

@@ -1419,7 +1429,9 @@ TextMetrics.measureFont = function measureFont (font)

* Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}.
* @class FontMetrics
* @memberof PIXI.TextMetrics~
*
* @typedef {object} FontMetrics
* @property {number} ascent - The ascent distance
* @property {number} descent - The descent distance
* @property {number} fontSize - Font size from ascent to descent
* @memberof PIXI.TextMetrics
* @private
*/

@@ -1448,3 +1460,3 @@

/**
* Cache of PIXI.TextMetrics~FontMetrics objects.
* Cache of {@see PIXI.TextMetrics.FontMetrics} objects.
* @memberof PIXI.TextMetrics

@@ -1519,2 +1531,3 @@ * @type {Object}

/* eslint max-depth: [2, 8] */
var defaultDestroyOptions = {

@@ -1527,5 +1540,15 @@ texture: true,

/**
* A Text Object will create a line or multiple lines of text. To split a line you can use '\n' in your text string,
* or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object.
* A Text Object will create a line or multiple lines of text.
*
* The text is created using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API).
*
* The primary advantage of this class over BitmapText is that you have great control over the style of the next,
* which you can change at runtime.
*
* The primary disadvantages is that each piece of text has it's own texture, which can use more memory.
* When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.
*
* To split a line you can use '\n' in your text string, or, on the `style` object,
* change its `wordWrap` property to true and and give the `wordWrapWidth` property a value.
*
* A Text can be created directly from a string and a style object,

@@ -1542,3 +1565,3 @@ * which can be generated [here](https://pixijs.io/pixi-text-style).

*/
var Text = (function (Sprite$$1) {
var Text = /*@__PURE__*/(function (Sprite) {
function Text(text, style, canvas)

@@ -1551,3 +1574,3 @@ {

var texture = core.Texture.from(canvas, settings.settings.SCALE_MODE, 'text');
var texture = core.Texture.from(canvas);

@@ -1557,7 +1580,4 @@ texture.orig = new math.Rectangle();

Sprite$$1.call(this, texture);
Sprite.call(this, texture);
// base texture is already automatically added to the cache, now adding the actual texture
core.Texture.addToCache(this._texture, this._texture.baseTexture.textureCacheIds[0]);
/**

@@ -1577,7 +1597,9 @@ * The canvas element that everything is drawn to

/**
* The resolution / device pixel ratio of the canvas. This is set automatically by the renderer.
* The resolution / device pixel ratio of the canvas.
* This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
* @member {number}
* @default 1
*/
this.resolution = settings.settings.RESOLUTION;
this._resolution = settings.settings.RESOLUTION;
this._autoResolution = true;

@@ -1621,7 +1643,7 @@ /**

if ( Sprite$$1 ) Text.__proto__ = Sprite$$1;
Text.prototype = Object.create( Sprite$$1 && Sprite$$1.prototype );
if ( Sprite ) Text.__proto__ = Sprite;
Text.prototype = Object.create( Sprite && Sprite.prototype );
Text.prototype.constructor = Text;
var prototypeAccessors = { width: { configurable: true },height: { configurable: true },style: { configurable: true },text: { configurable: true } };
var prototypeAccessors = { width: { configurable: true },height: { configurable: true },style: { configurable: true },text: { configurable: true },resolution: { configurable: true } };

@@ -1636,4 +1658,2 @@ /**

{
var this$1 = this;
var style = this._style;

@@ -1656,3 +1676,3 @@

var context = this.context;
var measured = TextMetrics.measureText(this._text, this._style, this._style.wordWrap, this.canvas);
var measured = TextMetrics.measureText(this._text || ' ', this._style, this._style.wordWrap, this.canvas);
var width = measured.width;

@@ -1666,6 +1686,6 @@ var height = measured.height;

this.canvas.width = Math.ceil((Math.max(1, width) + (style.padding * 2)) * this.resolution);
this.canvas.height = Math.ceil((Math.max(1, height) + (style.padding * 2)) * this.resolution);
this.canvas.width = Math.ceil((Math.max(1, width) + (style.padding * 2)) * this._resolution);
this.canvas.height = Math.ceil((Math.max(1, height) + (style.padding * 2)) * this._resolution);
context.scale(this.resolution, this.resolution);
context.scale(this._resolution, this._resolution);

@@ -1686,53 +1706,18 @@ context.clearRect(0, 0, this.canvas.width, this.canvas.height);

{
context.fillStyle = style.dropShadowColor;
context.globalAlpha = style.dropShadowAlpha;
var dropShadowColor = style.dropShadowColor;
var rgb = utils.hex2rgb(typeof dropShadowColor === 'number' ? dropShadowColor : utils.string2hex(dropShadowColor));
context.shadowColor = "rgba(" + (rgb[0] * 255) + "," + (rgb[1] * 255) + "," + (rgb[2] * 255) + "," + (style.dropShadowAlpha) + ")";
context.shadowBlur = style.dropShadowBlur;
if (style.dropShadowBlur > 0)
{
context.shadowColor = style.dropShadowColor;
}
var xShadowOffset = Math.cos(style.dropShadowAngle) * style.dropShadowDistance;
var yShadowOffset = Math.sin(style.dropShadowAngle) * style.dropShadowDistance;
for (var i = 0; i < lines.length; i++)
{
linePositionX = style.strokeThickness / 2;
linePositionY = ((style.strokeThickness / 2) + (i * lineHeight)) + fontProperties.ascent;
if (style.align === 'right')
{
linePositionX += maxLineWidth - lineWidths[i];
}
else if (style.align === 'center')
{
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
}
if (style.fill)
{
this$1.drawLetterSpacing(
lines[i],
linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding
);
if (style.stroke && style.strokeThickness)
{
context.strokeStyle = style.dropShadowColor;
this$1.drawLetterSpacing(
lines[i],
linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding,
true
);
context.strokeStyle = style.stroke;
}
}
}
context.shadowOffsetX = Math.cos(style.dropShadowAngle) * style.dropShadowDistance;
context.shadowOffsetY = Math.sin(style.dropShadowAngle) * style.dropShadowDistance;
}
else
{
context.shadowColor = 0;
context.shadowBlur = 0;
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
}
// reset the shadow blur and alpha that was set by the drop shadow, for the regular text
context.shadowBlur = 0;
context.globalAlpha = 1;
// set canvas text styles

@@ -1742,14 +1727,14 @@ context.fillStyle = this._generateFillStyle(style, lines);

// draw lines line by line
for (var i$1 = 0; i$1 < lines.length; i$1++)
for (var i = 0; i < lines.length; i++)
{
linePositionX = style.strokeThickness / 2;
linePositionY = ((style.strokeThickness / 2) + (i$1 * lineHeight)) + fontProperties.ascent;
linePositionY = ((style.strokeThickness / 2) + (i * lineHeight)) + fontProperties.ascent;
if (style.align === 'right')
{
linePositionX += maxLineWidth - lineWidths[i$1];
linePositionX += maxLineWidth - lineWidths[i];
}
else if (style.align === 'center')
{
linePositionX += (maxLineWidth - lineWidths[i$1]) / 2;
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
}

@@ -1759,4 +1744,4 @@

{
this$1.drawLetterSpacing(
lines[i$1],
this.drawLetterSpacing(
lines[i],
linePositionX + style.padding,

@@ -1770,4 +1755,4 @@ linePositionY + style.padding,

{
this$1.drawLetterSpacing(
lines[i$1],
this.drawLetterSpacing(
lines[i],
linePositionX + style.padding,

@@ -1793,3 +1778,2 @@ linePositionY + style.padding

{
var this$1 = this;
if ( isStroke === void 0 ) isStroke = false;

@@ -1826,9 +1810,9 @@

{
this$1.context.strokeText(current, currentPosition, y);
this.context.strokeText(current, currentPosition, y);
}
else
{
this$1.context.fillText(current, currentPosition, y);
this.context.fillText(current, currentPosition, y);
}
currentPosition += this$1.context.measureText(current).width + letterSpacing;
currentPosition += this.context.measureText(current).width + letterSpacing;
}

@@ -1850,5 +1834,8 @@ };

canvas.width = trimmed.width;
canvas.height = trimmed.height;
this.context.putImageData(trimmed.data, 0, 0);
if (trimmed.data)
{
canvas.width = trimmed.width;
canvas.height = trimmed.height;
this.context.putImageData(trimmed.data, 0, 0);
}
}

@@ -1861,4 +1848,4 @@

texture.trim.width = texture._frame.width = canvas.width / this.resolution;
texture.trim.height = texture._frame.height = canvas.height / this.resolution;
texture.trim.width = texture._frame.width = canvas.width / this._resolution;
texture.trim.height = texture._frame.height = canvas.height / this._resolution;
texture.trim.x = -padding;

@@ -1873,3 +1860,3 @@ texture.trim.y = -padding;

baseTexture.setRealSize(canvas.width, canvas.height, this.resolution);
baseTexture.setRealSize(canvas.width, canvas.height, this._resolution);

@@ -1886,5 +1873,5 @@ this.dirty = false;

{
if (this.resolution !== renderer.resolution)
if (this._autoResolution && this._resolution !== renderer.resolution)
{
this.resolution = renderer.resolution;
this._resolution = renderer.resolution;
this.dirty = true;

@@ -1895,3 +1882,3 @@ }

Sprite$$1.prototype.render.call(this, renderer);
Sprite.prototype.render.call(this, renderer);
};

@@ -1907,5 +1894,5 @@

{
if (this.resolution !== renderer.resolution)
if (this._autoResolution && this._resolution !== renderer.resolution)
{
this.resolution = renderer.resolution;
this._resolution = renderer.resolution;
this.dirty = true;

@@ -1916,3 +1903,3 @@ }

Sprite$$1.prototype._renderCanvas.call(this, renderer);
Sprite.prototype._renderCanvas.call(this, renderer);
};

@@ -1930,3 +1917,3 @@

return Sprite$$1.prototype.getLocalBounds.call(this, rect);
return Sprite.prototype.getLocalBounds.call(this, rect);
};

@@ -1936,2 +1923,3 @@

* calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account.
* @protected
*/

@@ -1983,4 +1971,4 @@ Text.prototype._calculateBounds = function _calculateBounds ()

var width = this.canvas.width / this.resolution;
var height = this.canvas.height / this.resolution;
var width = this.canvas.width / this._resolution;
var height = this.canvas.height / this._resolution;

@@ -2086,3 +2074,3 @@ // make a copy of the style settings, so we can manipulate them later

Sprite$$1.prototype.destroy.call(this, options);
Sprite.prototype.destroy.call(this, options);

@@ -2180,3 +2168,3 @@ // make sure to reset the the context and canvas.. dont want this hanging around in memory!

{
text = String(text === '' || text === null || text === undefined ? ' ' : text);
text = String(text === null || text === undefined ? '' : text);

@@ -2191,2 +2179,26 @@ if (this._text === text)

/**
* The resolution / device pixel ratio of the canvas.
* This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
* @member {number}
* @default 1
*/
prototypeAccessors.resolution.get = function ()
{
return this._resolution;
};
prototypeAccessors.resolution.set = function (value) // eslint-disable-line require-jsdoc
{
this._autoResolution = false;
if (this._resolution === value)
{
return;
}
this._resolution = value;
this.dirty = true;
};
Object.defineProperties( Text.prototype, prototypeAccessors );

@@ -2193,0 +2205,0 @@

{
"name": "@pixi/text",
"version": "5.0.0-alpha.3",
"version": "5.0.0-rc",
"main": "lib/text.js",
"module": "lib/text.es.js",
"description": "PixiJS Application",
"description": "Text via the Canvas API",
"author": "Mat Groves",

@@ -28,11 +28,15 @@ "contributors": [

"dependencies": {
"@pixi/core": "^5.0.0-alpha.3",
"@pixi/math": "^5.0.0-alpha.3",
"@pixi/settings": "^5.0.0-alpha.3",
"@pixi/sprite": "^5.0.0-alpha.3",
"@pixi/utils": "^5.0.0-alpha.3"
"@pixi/core": "^5.0.0-rc",
"@pixi/math": "^5.0.0-rc",
"@pixi/settings": "^5.0.0-rc",
"@pixi/sprite": "^5.0.0-rc",
"@pixi/utils": "^5.0.0-rc"
},
"devDependencies": {
"floss": "^2.1.3"
}
"@pixi/canvas-display": "^5.0.0-rc",
"@pixi/canvas-renderer": "^5.0.0-rc",
"@pixi/canvas-sprite": "^5.0.0-rc",
"floss": "^2.1.5"
},
"gitHead": "9026a1bbca9a9d86b7a3b6d5eb4fa2c3145c2b85"
}

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