diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 5e7bc0b..d68d177 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -489,6 +489,19 @@ } /** + * Gets the local bounds of the text object. + * + * @param {Rectangle} rect - The output rectangle. + * @return {Rectangle} The bounds. + */ + getLocalBounds(rect) + { + this.updateText(true); + + return super.getLocalBounds.call(this, rect); + } + + /** * calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. */ _calculateBounds() diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 5e7bc0b..d68d177 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -489,6 +489,19 @@ } /** + * Gets the local bounds of the text object. + * + * @param {Rectangle} rect - The output rectangle. + * @return {Rectangle} The bounds. + */ + getLocalBounds(rect) + { + this.updateText(true); + + return super.getLocalBounds.call(this, rect); + } + + /** * calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. */ _calculateBounds() diff --git a/test/core/getLocalBounds.js b/test/core/getLocalBounds.js index d160a56..309da0e 100644 --- a/test/core/getLocalBounds.js +++ b/test/core/getLocalBounds.js @@ -196,4 +196,13 @@ expect(bounds.width).to.equal(100); expect(bounds.height).to.equal(100); }); + + it('should register correct local-bounds with a Text', function () + { + const text = new PIXI.Text('hello'); + const bounds = text.getLocalBounds(); + + expect(bounds.width).to.not.equal(0); + expect(bounds.height).to.not.equal(0); + }); });