diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 959c82855..2ffaa8d49 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -247,7 +247,7 @@ namespace NLGUI std::string _HardTextFormat; std::string _HardText; std::string _Text; - size_t _TextLength; + mutable sint _TextLength; /// index of the computed String associated to this text control uint _Index; /// info on the computed String associated to this text control @@ -443,7 +443,7 @@ namespace NLGUI void setup (); void setupDefault (); - void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd); + void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp index 4a8162f51..872c1fd3d 100644 --- a/nel/src/3d/font_manager.cpp +++ b/nel/src/3d/font_manager.cpp @@ -130,6 +130,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, output.CacheVersion = getCacheVersion(); uint j = 0; + size_t idx = 0; { CVertexBufferReadWrite vba; output.Vertices.lock (vba); @@ -138,8 +139,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, hlfPixScrH = 0.f; // For all chars - //for (uint i = 0; i < s.size(); i++) - for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++idx) { // Creating font k.Char = *it; @@ -211,7 +211,8 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, } } output.Vertices.setNumVertices (j); - output.Length = j >> 2; + output.Length = idx; + nlassert(output.Length == NLMISC::CUtfStringView(output.Text).count()); // compile string info output.StringWidth = (float)penx; @@ -316,6 +317,7 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv, } } output.Length = idx; + nlassert(output.Length == std::min(len, NLMISC::CUtfStringView(output.Text).count())); // compile string info output.StringWidth = (float)penx;