From 12609c3f7652da8982112124116d11c7034035a0 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Wed, 21 Mar 2018 07:25:43 -0700 Subject: [PATCH] BitmapFontTextRenderer: fixed issue where letters could be cut off on the end of the line because measurement didn't account for removing xOffset from whitespace after the final letter (closes #1676) --- .../controls/text/BitmapFontTextRenderer.as | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/feathers/controls/text/BitmapFontTextRenderer.as b/source/feathers/controls/text/BitmapFontTextRenderer.as index 42312586ab..9ba6af0a97 100644 --- a/source/feathers/controls/text/BitmapFontTextRenderer.as +++ b/source/feathers/controls/text/BitmapFontTextRenderer.as @@ -925,7 +925,7 @@ package feathers.controls.text currentX -= customLetterSpacing; if(charData !== null) { - currentX -= (charData.xAdvance - charData.width) * scale; + currentX -= (charData.xAdvance - charData.width - charData.xOffset) * scale; } if(currentX < 0) { @@ -976,7 +976,7 @@ package feathers.controls.text //this is the spacing after the last character //that isn't whitespace var previousCharData:BitmapChar = font.getChar(previousCharID); - widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width) * scale; + widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width - previousCharData.xOffset) * scale; } widthOfWhitespaceAfterWord += xAdvance; } @@ -1013,7 +1013,7 @@ package feathers.controls.text if(previousCharID === previousCharID) //!isNaN { previousCharData = font.getChar(previousCharID); - widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width) * scale; + widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width - previousCharData.xOffset) * scale; } if(!isAligned) { @@ -1070,7 +1070,7 @@ package feathers.controls.text currentX = currentX - customLetterSpacing; if(charData !== null) { - currentX -= (charData.xAdvance - charData.width) * scale; + currentX -= (charData.xAdvance - charData.width - charData.xOffset) * scale; } if(currentX < 0) { @@ -1423,7 +1423,7 @@ package feathers.controls.text currentX -= customLetterSpacing; if(charData !== null) { - currentX -= (charData.xAdvance - charData.width) * scale; + currentX -= (charData.xAdvance - charData.width - charData.xOffset) * scale; } if(currentX < 0) { @@ -1467,7 +1467,7 @@ package feathers.controls.text //this is the spacing after the last character //that isn't whitespace var previousCharData:BitmapChar = font.getChar(previousCharID); - widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width) * scale; + widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width - previousCharData.xOffset) * scale; } widthOfWhitespaceAfterWord += xAdvance; } @@ -1489,7 +1489,7 @@ package feathers.controls.text if(previousCharID === previousCharID) //!isNaN { previousCharData = font.getChar(previousCharID); - widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width) * scale; + widthOfWhitespaceAfterWord = customLetterSpacing + (previousCharData.xAdvance - previousCharData.width - previousCharData.xOffset) * scale; } } //we're just reusing this variable to avoid creating a @@ -1516,7 +1516,7 @@ package feathers.controls.text currentX -= customLetterSpacing; if(charData !== null) { - currentX -= (charData.xAdvance - charData.width) * scale; + currentX -= (charData.xAdvance - charData.width - charData.xOffset) * scale; } if(currentX < 0) { @@ -1655,7 +1655,7 @@ package feathers.controls.text currentX -= customLetterSpacing; if(charData !== null) { - currentX -= (charData.xAdvance - charData.width) * scale; + currentX -= (charData.xAdvance - charData.width - charData.xOffset) * scale; } //then work our way backwards until we fit into the width