diff --git a/src/TextBubbleSkin.js b/src/TextBubbleSkin.js index d578656..ab0085c 100644 --- a/src/TextBubbleSkin.js +++ b/src/TextBubbleSkin.js @@ -54,7 +54,7 @@ class TextBubbleSkin extends Skin { /** @type {Array} */ this._lines = []; - this._textSize = {width: 0, height: 0}; + /** @type {object} */ this._textAreaSize = {width: 0, height: 0}; /** @type {string} */ @@ -127,17 +127,14 @@ class TextBubbleSkin extends Skin { this._lines = this.textWrapper.wrapText(BubbleStyle.MAX_LINE_WIDTH, this._text); // Measure width of longest line to avoid extra-wide bubbles - let longestLine = 0; + let longestLineWidth = 0; for (const line of this._lines) { - longestLine = Math.max(longestLine, this.measurementProvider.measureText(line)); + longestLineWidth = Math.max(longestLineWidth, this.measurementProvider.measureText(line)); } - this._textSize.width = longestLine; - this._textSize.height = BubbleStyle.LINE_HEIGHT * this._lines.length; - // Calculate the canvas-space sizes of the padded text area and full text bubble - const paddedWidth = Math.max(this._textSize.width, BubbleStyle.MIN_WIDTH) + (BubbleStyle.PADDING * 2); - const paddedHeight = this._textSize.height + (BubbleStyle.PADDING * 2); + const paddedWidth = Math.max(longestLineWidth, BubbleStyle.MIN_WIDTH) + (BubbleStyle.PADDING * 2); + const paddedHeight = (BubbleStyle.LINE_HEIGHT * this._lines.length) + (BubbleStyle.PADDING * 2); this._textAreaSize.width = paddedWidth; this._textAreaSize.height = paddedHeight; @@ -267,14 +264,13 @@ class TextBubbleSkin extends Skin { if (this._texture === null) { const textureOptions = { - auto: true, - wrap: gl.CLAMP_TO_EDGE, - src: textureData + auto: false, + wrap: gl.CLAMP_TO_EDGE }; this._texture = twgl.createTexture(gl, textureOptions); } - + gl.bindTexture(gl.TEXTURE_2D, this._texture); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, textureData); this._silhouette.update(textureData); diff --git a/tap-snapshots/test-integration-scratch-tests.js-TAP.test.js b/tap-snapshots/test-integration-scratch-tests.js-TAP.test.js deleted file mode 100644 index 4cd97cf..0000000 --- a/tap-snapshots/test-integration-scratch-tests.js-TAP.test.js +++ /dev/null @@ -1,10 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/integration/scratch-tests.js TAP bubble snapshot > bubble-text-snapshot 1`] = ` -<e*&%$&^$></!abc'> -`