diff --git a/src/extras/BitmapText.js b/src/extras/BitmapText.js index 76c3ae1..0592b54 100644 --- a/src/extras/BitmapText.js +++ b/src/extras/BitmapText.js @@ -96,16 +96,18 @@ * Disable by setting value to 0 * * @member {number} + * @private */ - this.maxWidth = 0; + this._maxWidth = 0; /** * The max line height. This is useful when trying to use the total height of the Text, * ie: when trying to vertically align. * * @member {number} + * @private */ - this.maxLineHeight = 0; + this._maxLineHeight = 0; /** * Text anchor. read-only @@ -169,7 +171,7 @@ continue; } - if (lastSpace !== -1 && this.maxWidth > 0 && pos.x * scale > this.maxWidth) + if (lastSpace !== -1 && this._maxWidth > 0 && pos.x * scale > this._maxWidth) { core.utils.removeItems(chars, lastSpace - spacesRemoved, i - lastSpace); i = lastSpace; @@ -277,7 +279,7 @@ this._glyphs[i].y -= this._textHeight * this.anchor.y; } } - this.maxLineHeight = maxLineHeight * scale; + this._maxLineHeight = maxLineHeight * scale; } /** @@ -432,6 +434,42 @@ } /** + * The max width of this bitmap text in pixels. If the text provided is longer than the + * value provided, line breaks will be automatically inserted in the last whitespace. + * Disable by setting value to 0 + * + * @member {number} + */ + get maxWidth() + { + return this._maxWidth; + } + + set maxWidth(value) // eslint-disable-line require-jsdoc + { + if (this._maxWidth === value) + { + return; + } + this._maxWidth = value; + this.dirty = true; + } + + /** + * The max line height. This is useful when trying to use the total height of the Text, + * ie: when trying to vertically align. + * + * @member {number} + * @readonly + */ + get maxLineHeight() + { + this.validate(); + + return this._maxLineHeight; + } + + /** * The width of the overall text, different from fontSize, * which is defined in the style object *