Change CViewText to UTF-8, ryzom/ryzomcore#335

develop
kaetemi 4 years ago
parent 9021ce465f
commit c129ce87df

@ -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);

@ -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;

Loading…
Cancel
Save