From 6a6e7b702e0dd2f2d364d617fe20036b44bc46a1 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 18 Feb 2011 11:08:38 +0100 Subject: removed double utf8 decoding in text rendering --- src/engine/client/text.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/engine/client') 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) -- cgit 1.4.1