mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-09 22:34:43 +00:00
Update textbox.class.js
This commit is contained in:
parent
b57e37bd5e
commit
8f14daaba8
2 changed files with 20 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue