diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split('');