From 8f14daaba819ea21f7618862a5efa41bf0f802e2 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Fri, 17 Jul 2015 11:40:54 +0200 Subject: [PATCH] Update textbox.class.js --- src/mixins/itext.svg_export.js | 2 +- src/shapes/textbox.class.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/mixins/itext.svg_export.js b/src/mixins/itext.svg_export.js index 483133c1..3f330792 100644 --- a/src/mixins/itext.svg_export.js +++ b/src/mixins/itext.svg_export.js @@ -10,7 +10,7 @@ */ _setSVGTextLineText: function(lineIndex, textSpans, height, textLeftOffset, textTopOffset, textBgRects) { if (!this.styles[lineIndex]) { - this.callSuper('_setSVGTextLineText', + fabric.Text.prototype._setSVGTextLineText.call(this, lineIndex, textSpans, height, textLeftOffset, textTopOffset); } else { diff --git a/src/shapes/textbox.class.js b/src/shapes/textbox.class.js index bbc76c22..2651e969 100644 --- a/src/shapes/textbox.class.js +++ b/src/shapes/textbox.class.js @@ -92,15 +92,28 @@ this._set('width', this.dynamicMinWidth); } - // calculate a styleMap that lets us know where styles as, as _textLines is separated by \n and wraps, - // but the style object line indices is by \n. - this._styleMap = this._generateStyleMap(); - // clear cache and re-calculate height this._clearCache(); this.height = this._getTextHeight(ctx); + this._setLineWidths(); }, + /** + * set the __lineWidths cache array to support + * functions that expect it to be filled + * @private + */ + _setLineWidths: function() { + for (var i = 0, len = this._textLines.length; i < len; i++) { + this.__lineWidths[i] = this.width; + } + }, + + /** + * Calculate a styleMap that lets us know where styles as, as _textLines is separated by \n and wraps, + * but the style object line indices is by \n. + * @private + */ _generateStyleMap: function() { var realLineCount = 0, realLineCharCount = 0, @@ -329,6 +342,8 @@ var lines = this._wrapText(this.ctx, this.text); this.ctx.restore(); + this._textLines = lines; + this._styleMap = this._generateStyleMap(); return lines; },