about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-02-18 11:08:38 +0100
committeroy <Tom_Adams@web.de>2011-02-18 11:08:38 +0100
commit6a6e7b702e0dd2f2d364d617fe20036b44bc46a1 (patch)
tree5095fd0bce477a1b145f98a68d311f2f80ea5f12 /src
parentae94c36f547a699b1657b0b2284fb14f04da0d41 (diff)
downloadzcatch-6a6e7b702e0dd2f2d364d617fe20036b44bc46a1.tar.gz
zcatch-6a6e7b702e0dd2f2d364d617fe20036b44bc46a1.zip
removed double utf8 decoding in text rendering
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/text.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp
index df28283d..a0b3b311 100644
--- a/src/engine/client/text.cpp
+++ b/src/engine/client/text.cpp
@@ -659,18 +659,13 @@ public:
 					pBatchEnd = pCurrent + Wlen;
 				}
 				
+				const char *pTmp = pCurrent;
+				int NextCharacter = str_utf8_decode(&pTmp);
 				while(pCurrent < pBatchEnd)
 				{
-					const char *pTmp;
-					float Advance = 0;
-					int Character = 0;
-					int Nextcharacter = 0;
-					CFontChar *pChr;
-
-					// TODO: UTF-8 decode
-					Character = str_utf8_decode(&pCurrent);
-					pTmp = pCurrent;
-					Nextcharacter = str_utf8_decode(&pTmp);
+					int Character = NextCharacter;
+					pCurrent = pTmp;
+					NextCharacter = str_utf8_decode(&pTmp);
 					
 					if(Character == '\n')
 					{
@@ -684,11 +679,10 @@ public:
 						continue;
 					}
 
-					pChr = GetChar(pFont, pSizeData, Character);
-
+					CFontChar *pChr = GetChar(pFont, pSizeData, Character);
 					if(pChr)
 					{
-						Advance = pChr->m_AdvanceX + Kerning(pFont, Character, Nextcharacter)*Scale;
+						float Advance = pChr->m_AdvanceX + Kerning(pFont, Character, NextCharacter)*Scale;
 						if(pCursor->m_Flags&TEXTFLAG_STOP_AT_END && DrawX+Advance*Size-pCursor->m_StartX > pCursor->m_LineWidth)
 						{
 							// we hit the end of the line, no more to render or count
@@ -702,10 +696,10 @@ public:
 							IGraphics::CQuadItem QuadItem(DrawX+pChr->m_OffsetX*Size, DrawY+pChr->m_OffsetY*Size, pChr->m_Width*Size, pChr->m_Height*Size);
 							Graphics()->QuadsDrawTL(&QuadItem, 1);
 						}
-					}
 
-					DrawX += Advance*Size;
-					pCursor->m_CharCount++;
+						DrawX += Advance*Size;
+						pCursor->m_CharCount++;
+					}
 				}
 				
 				if(NewLine)