diff --git a/Source/Engine/Render2D/Font.h b/Source/Engine/Render2D/Font.h
index b1fdd4e55..d216223b4 100644
--- a/Source/Engine/Render2D/Font.h
+++ b/Source/Engine/Render2D/Font.h
@@ -66,6 +66,16 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(TextRange);
{
return Math::Min(EndIndex, other.EndIndex) > Math::Max(StartIndex, other.StartIndex);
}
+
+ ///
+ /// Gets the substring from the source text.
+ ///
+ /// The text.
+ /// The substring of the original text of the defined range.
+ StringView Substring(const StringView& text) const
+ {
+ return StringView(text.Get() + StartIndex, EndIndex - StartIndex);
+ }
};
template<>
@@ -336,6 +346,20 @@ public:
return lines;
}
+ ///
+ /// Processes text to get cached lines for rendering.
+ ///
+ /// The input text.
+ /// The input text range (substring range of the input text parameter).
+ /// The layout properties.
+ /// The output lines list.
+ API_FUNCTION() Array ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ Array lines;
+ ProcessText(textRange.Substring(text), lines, layout);
+ return lines;
+ }
+
///
/// Processes text to get cached lines for rendering.
///
@@ -346,6 +370,17 @@ public:
return ProcessText(text, TextLayoutOptions());
}
+ ///
+ /// Processes text to get cached lines for rendering.
+ ///
+ /// The input text.
+ /// The input text range (substring range of the input text parameter).
+ /// The output lines list.
+ API_FUNCTION() FORCE_INLINE Array ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
+ {
+ return ProcessText(textRange.Substring(text), TextLayoutOptions());
+ }
+
///
/// Measures minimum size of the rectangle that will be needed to draw given text.
///
@@ -354,6 +389,18 @@ public:
/// The minimum size for that text and fot to render properly.
API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The layout properties.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ return MeasureText(textRange.Substring(text), layout);
+ }
+
///
/// Measures minimum size of the rectangle that will be needed to draw given text
/// .
@@ -364,6 +411,17 @@ public:
return MeasureText(text, TextLayoutOptions());
}
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text
+ /// .
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
+ {
+ return MeasureText(textRange.Substring(text), TextLayoutOptions());
+ }
+
///
/// Calculates hit character index at given location.
///
@@ -374,7 +432,7 @@ public:
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
API_FUNCTION() int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
{
- return HitTestText(StringView(text.Get() + textRange.StartIndex, textRange.Length()), location, layout);
+ return HitTestText(textRange.Substring(text), location, layout);
}
///
@@ -406,7 +464,7 @@ public:
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
{
- return HitTestText(StringView(text.Get() + textRange.StartIndex, textRange.Length()), location, TextLayoutOptions());
+ return HitTestText(textRange.Substring(text), location, TextLayoutOptions());
}
///
@@ -428,7 +486,7 @@ public:
/// The character position (upper left corner which can be used for a caret position).
API_FUNCTION() Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
{
- return GetCharPosition(StringView(text.Get() + textRange.StartIndex, textRange.Length()), index, layout);
+ return GetCharPosition(textRange.Substring(text), index, layout);
}
///
@@ -451,7 +509,7 @@ public:
/// The character position (upper left corner which can be used for a caret position).
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
{
- return GetCharPosition(StringView(text.Get() + textRange.StartIndex, textRange.Length()), index, TextLayoutOptions());
+ return GetCharPosition(textRange.Substring(text), index, TextLayoutOptions());
}
///
diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
index b606e46ae..2a0e541f4 100644
--- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
+++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
@@ -14,7 +14,7 @@ namespace FlaxEngine.GUI
/// The delegate for text blocks processing.
///
/// The text.
- /// The output text blocks. Given list is not-nul and cleared before.
+ /// The output text blocks. Given list is not-null and cleared before.
public delegate void ParseTextBlocksDelegate(string text, List textBlocks);
///