diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 8c4dee971..1105920ba 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -1145,7 +1145,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color, // Check if there is no need to do anything if (font == nullptr || - text.IsEmpty() || + text.Length() < 0 || (customMaterial && (!customMaterial->IsReady() || !customMaterial->IsGUI()))) return; @@ -1249,7 +1249,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color, void Render2D::DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const Float2& location, MaterialBase* customMaterial) { - DrawText(font, StringView(text.Get() + textRange.StartIndex, textRange.Length()), color, location, customMaterial); + DrawText(font, textRange.Substring(text), color, location, customMaterial); } void Render2D::DrawText(Font* font, const StringView& text, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial) @@ -1362,7 +1362,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color, void Render2D::DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial) { - DrawText(font, StringView(text.Get() + textRange.StartIndex, textRange.Length()), color, layout, customMaterial); + DrawText(font, textRange.Substring(text), color, layout, customMaterial); } FORCE_INLINE bool NeedAlphaWithTint(const Color& color) diff --git a/Source/Engine/UI/GUI/Common/RichTextBox.Tags.cs b/Source/Engine/UI/GUI/Common/RichTextBox.Tags.cs index 7c222fb5b..3fd6e80ff 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBox.Tags.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBox.Tags.cs @@ -165,7 +165,7 @@ namespace FlaxEngine.GUI Range = new TextRange { StartIndex = tag.StartPosition, - EndIndex = tag.StartPosition, + EndIndex = tag.StartPosition - 1, }, Style = context.StyleStack.Peek(), Bounds = new Rectangle(context.Caret, new Float2(64.0f)),