diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 513d358..e9f1091 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -209,7 +209,7 @@ { this._sourceLoaded(); } - else if(!source.getContext) + else if (!source.getContext) { // Image fail / not ready this.isLoading = true; @@ -372,9 +372,11 @@ image.crossOrigin = ''; } - image.src = imageUrl; baseTexture = new BaseTexture(image, scaleMode); baseTexture.imageUrl = imageUrl; + + image.src = imageUrl; + utils.BaseTextureCache[imageUrl] = baseTexture; // if there is an @2x at the end of the url we are going to assume its a highres image diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 513d358..e9f1091 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -209,7 +209,7 @@ { this._sourceLoaded(); } - else if(!source.getContext) + else if (!source.getContext) { // Image fail / not ready this.isLoading = true; @@ -372,9 +372,11 @@ image.crossOrigin = ''; } - image.src = imageUrl; baseTexture = new BaseTexture(image, scaleMode); baseTexture.imageUrl = imageUrl; + + image.src = imageUrl; + utils.BaseTextureCache[imageUrl] = baseTexture; // if there is an @2x at the end of the url we are going to assume its a highres image diff --git a/src/text/BitmapText.js b/src/text/BitmapText.js index d25f2cb..77df45b 100644 --- a/src/text/BitmapText.js +++ b/src/text/BitmapText.js @@ -176,6 +176,7 @@ var pos = new core.math.Point(); var prevCharCode = null; var chars = []; + var lastLineWidth = 0; var maxLineWidth = 0; var lineWidths = []; var line = 0; @@ -187,8 +188,8 @@ if (/(?:\r\n|\r|\n)/.test(this.text.charAt(i))) { - lineWidths.push(pos.x); - maxLineWidth = Math.max(maxLineWidth, pos.x); + lineWidths.push(lastLineWidth); + maxLineWidth = Math.max(maxLineWidth, lastLineWidth); line++; pos.x = 0; @@ -210,13 +211,14 @@ } chars.push({texture:charData.texture, line: line, charCode: charCode, position: new core.math.Point(pos.x + charData.xOffset, pos.y + charData.yOffset)}); + lastLineWidth = pos.x + (charData.texture.width + charData.xOffset); pos.x += charData.xAdvance; prevCharCode = charCode; } - lineWidths.push(pos.x); - maxLineWidth = Math.max(maxLineWidth, pos.x); + lineWidths.push(lastLineWidth); + maxLineWidth = Math.max(maxLineWidth, lastLineWidth); var lineAlignOffsets = [];