From a2e1dc98a212e54e3f5076beccbb9580573198c3 Mon Sep 17 00:00:00 2001 From: VDm Date: Tue, 8 Apr 2025 01:58:04 +0400 Subject: [PATCH] fix(ui): fix CSimpleFontString to use the FixedColor flag only if the string does not contain color tags --- src/gx/font/CGxString.cpp | 4 ++-- src/ui/CSimpleFontString.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gx/font/CGxString.cpp b/src/gx/font/CGxString.cpp index 6694241..eab4ce8 100644 --- a/src/gx/font/CGxString.cpp +++ b/src/gx/font/CGxString.cpp @@ -348,7 +348,7 @@ int32_t CGxString::Initialize(float fontHeight, const C3Vector& position, float face->m_strings.LinkToTail(this); - float requestedFontHeight = this->m_flags & 0x4 && !(this->m_flags & 0x80) + float requestedFontHeight = ((this->m_flags & 0x4) && !(this->m_flags & 0x80)) ? GxuFontGetOneToOneHeight(face) : fontHeight; this->m_requestedFontHeight = requestedFontHeight; @@ -382,7 +382,7 @@ void CGxString::InitializeTextLine(const char* currentText, uint32_t numBytes, C float stepGlyph = 0.0f; float stepScreen = 0.0f; uint32_t prevCode = 0; - CImVector color; + CImVector color = this->m_fontColor; while (numBytes && *currentText) { int32_t advance; diff --git a/src/ui/CSimpleFontString.cpp b/src/ui/CSimpleFontString.cpp index 7a6623a..5d58631 100644 --- a/src/ui/CSimpleFontString.cpp +++ b/src/ui/CSimpleFontString.cpp @@ -876,9 +876,17 @@ void CSimpleFontString::UpdateString() { uint32_t styleFlags = this->m_styleFlags; if (!(this->m_styleFlags & 0x400)) { - // TODO - - styleFlags |= 0x400; + // Set FixedColor flag if the text does not contain color tags + bool found = false; + for (size_t i = 0; displayText && displayText[i]; ++i) { + if (displayText[i] == '|' && (displayText[i + 1] == 'C' || displayText[i + 1] == 'c')) { + found = true; + break; + } + } + if (!found) { + styleFlags |= 0x400u; + } } CImVector color = { 0xFF, 0xFF, 0xFF, 0xFF };