From cc0bac0214d39c68c27288d395cdcca39a6cf97d Mon Sep 17 00:00:00 2001 From: zekechan Date: Tue, 30 Jul 2024 13:40:53 +0800 Subject: [PATCH] Removed empty line spacing added when text is undefined. Fix #6807 --- src/gameobjects/bitmaptext/GetBitmapTextSize.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gameobjects/bitmaptext/GetBitmapTextSize.js b/src/gameobjects/bitmaptext/GetBitmapTextSize.js index 7241e26319..aabf523c64 100644 --- a/src/gameobjects/bitmaptext/GetBitmapTextSize.js +++ b/src/gameobjects/bitmaptext/GetBitmapTextSize.js @@ -263,10 +263,12 @@ var GetBitmapTextSize = function (src, round, updateOrigin, out) for (i = crs.length - 1; i >= 0; i--) { - // eslint-disable-next-line quotes - text = stringInsert(text, crs[i], "\n"); + if (crs[i] > -1) + { + text = stringInsert(text, crs[i], "\n"); + } } - + out.wrappedText = text; textLength = text.length; @@ -298,8 +300,6 @@ var GetBitmapTextSize = function (src, round, updateOrigin, out) current = null; } - xAdvance = 0; - yAdvance = (lineHeight + lineSpacing) * (currentLine + 1); lastGlyph = null; lineWidths[currentLine] = currentLineWidth; @@ -317,6 +317,9 @@ var GetBitmapTextSize = function (src, round, updateOrigin, out) currentLine++; currentLineWidth = 0; + xAdvance = 0; + yAdvance = (lineHeight + lineSpacing) * currentLine; + continue; } @@ -522,4 +525,4 @@ var GetBitmapTextSize = function (src, round, updateOrigin, out) return out; }; -module.exports = GetBitmapTextSize; \ No newline at end of file +module.exports = GetBitmapTextSize;