Ver código fonte

Fixed incorrect clipping for certain text characters

BearishSun 9 anos atrás
pai
commit
863efab630
1 arquivos alterados com 7 adições e 0 exclusões
  1. 7 0
      Source/BansheeCore/Source/BsTextData.cpp

+ 7 - 0
Source/BansheeCore/Source/BsTextData.cpp

@@ -190,6 +190,7 @@ namespace BansheeEngine
 			return numQuads;
 			return numQuads;
 
 
 		UINT32 penX = 0;
 		UINT32 penX = 0;
+		UINT32 penNegativeXOffset = 0;
 		for(UINT32 i = mWordsStart; i <= mWordsEnd; i++)
 		for(UINT32 i = mWordsStart; i <= mWordsEnd; i++)
 		{
 		{
 			const TextWord& word = mTextData->getWord(i);
 			const TextWord& word = mTextData->getWord(i);
@@ -250,6 +251,12 @@ namespace BansheeEngine
 					INT32 curX = penX + curChar.xOffset;
 					INT32 curX = penX + curChar.xOffset;
 					INT32 curY = ((INT32) mTextData->getBaselineOffset() - curChar.yOffset);
 					INT32 curY = ((INT32) mTextData->getBaselineOffset() - curChar.yOffset);
 
 
+					// If index is negative, offset it so the text always begins at X=0. This works under the assumption
+					// that only the first character on a line can have a negative offset.
+					if (curX < 0)
+						penNegativeXOffset = penX - curChar.xOffset;
+
+					curX += penNegativeXOffset;
 					penX += curChar.xAdvance + kerning;
 					penX += curChar.xAdvance + kerning;
 					
 					
 					kerning = 0;
 					kerning = 0;