diff options
author | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:15:38 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:16:32 +0200 |
commit | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch) | |
tree | f6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/graphics/engine/text.cpp | |
parent | 0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff) | |
parent | 1835d2ae580525603308206f7b8e6b4552b3ca0f (diff) | |
download | colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2 colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip |
Release 0.1.3-alpha
Diffstat (limited to 'src/graphics/engine/text.cpp')
-rw-r--r-- | src/graphics/engine/text.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index ffd2eb2..8fd01b7 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -19,6 +19,7 @@ #include "graphics/engine/text.h" #include "app/app.h" +#include "app/gamedata.h" #include "common/image.h" #include "common/logger.h" @@ -333,7 +334,7 @@ float CText::GetStringWidth(std::string text, FontType font, float size) // Skip special chars for (char& c : text) { - if (c < 32) + if (c < 32 && c >= 0) c = ':'; } @@ -351,7 +352,7 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset) if (font == FONT_BUTTON) return 0.0f; int width = 1; - if (ch.c1 < 32) + if (ch.c1 < 32 && ch.c1 >= 0) { if (ch.c1 == '\t') width = m_tabSize; @@ -646,7 +647,13 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera DrawCharAndAdjustPos(ch, font, size, pos, color); - fmtIndex++; + // increment fmtIndex for each byte in multibyte character + if ( ch.c1 != 0 ) + fmtIndex++; + if ( ch.c2 != 0 ) + fmtIndex++; + if ( ch.c3 != 0 ) + fmtIndex++; } if (eol != 0) @@ -859,7 +866,7 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size) return m_lastCachedFont; } - std::string path = CApplication::GetInstance().GetDataFilePath(DIR_FONT, mf->fileName); + std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName); m_lastCachedFont = new CachedFont(); m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize); |