From dcc6e40d30c4f0bae08e6dae14dfe9675ff037d4 Mon Sep 17 00:00:00 2001 From: Avrami H Date: Thu, 18 Nov 2021 13:11:54 +0800 Subject: [PATCH 1/2] Fix what appear to be bugs in some of the text cache checks --- src/shapes/text.class.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 04078cf2f7e..313c8727a89 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -1343,13 +1343,13 @@ * @return {Number} Line width */ getLineWidth: function(lineIndex) { - if (this.__lineWidths[lineIndex]) { + if (this.__lineWidths[lineIndex] !== undefined) { return this.__lineWidths[lineIndex]; } var width, line = this._textLines[lineIndex], lineInfo; - if (line === '') { + if (!line || line.join('') === '') { width = 0; } else { From ac1488390e27146c3eefe0e52fbe38d8ddcb4843 Mon Sep 17 00:00:00 2001 From: Avrami H Date: Thu, 18 Nov 2021 15:40:03 +0800 Subject: [PATCH 2/2] Remove check for line === '', if this check passes, _charBounds can be undefined in some edge cases --- src/shapes/text.class.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 313c8727a89..e767bbab468 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -1347,15 +1347,8 @@ return this.__lineWidths[lineIndex]; } - var width, line = this._textLines[lineIndex], lineInfo; - - if (!line || line.join('') === '') { - width = 0; - } - else { - lineInfo = this.measureLine(lineIndex); - width = lineInfo.width; - } + var lineInfo = this.measureLine(lineIndex); + var width = lineInfo.width; this.__lineWidths[lineIndex] = width; return width; },