1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-15 09:25:37 +02:00

Avoid copies when working with EnrichedString

This commit is contained in:
sfan5
2024-08-27 13:51:02 +02:00
parent fa4529b4f1
commit 19a58745c9
6 changed files with 53 additions and 54 deletions

View File

@@ -513,12 +513,15 @@ void CGUITTFont::setFontHinting(const bool enable, const bool enable_auto_hintin
void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position, video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>* clip)
{
draw(EnrichedString(std::wstring(text.c_str()), color), position, hcenter, vcenter, clip);
// Allow colors to work for strings that have passed through irrlicht by catching
// them here and converting them to enriched just before drawing.
EnrichedString s(text.c_str(), color);
draw(s, position, hcenter, vcenter, clip);
}
void CGUITTFont::draw(const EnrichedString &text, const core::rect<s32>& position, bool hcenter, bool vcenter, const core::rect<s32>* clip)
{
const std::vector<video::SColor> &colors = text.getColors();
const auto &colors = text.getColors();
if (!Driver)
return;