Make font fallbacking the default option
This commit is contained in:
@@ -35,15 +35,6 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(15), EditorDisplay(\"General\")")
|
||||
String CopyrightNotice;
|
||||
|
||||
/// <summary>
|
||||
/// The copyright note used for content signing (eg. source code header).
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(1200), EditorDisplay(\"Other Settings\")")
|
||||
bool EnableFontFallback;
|
||||
|
||||
API_FIELD(Attributes = "EditorOrder(1205), EditorDisplay(\"Other Settings\")")
|
||||
FontFallbackList* FontFallbacks;
|
||||
|
||||
/// <summary>
|
||||
/// The default application icon.
|
||||
/// </summary>
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Engine/Graphics/Enums.h"
|
||||
#include "Engine/Graphics/PostProcessSettings.h"
|
||||
|
||||
class FontFallbackList;
|
||||
|
||||
/// <summary>
|
||||
/// Graphics rendering settings.
|
||||
/// </summary>
|
||||
@@ -118,6 +120,18 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(10000), EditorDisplay(\"Post Process Settings\", EditorDisplayAttribute.InlineStyle)")
|
||||
PostProcessSettings PostProcessSettings;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(12000), EditorDisplay(\"Text Render Settings\", EditorDisplayAttribute.InlineStyle)")
|
||||
bool EnableFontFallback = true;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(12005), EditorDisplay(\"Text Render Settings\", EditorDisplayAttribute.InlineStyle)")
|
||||
FontFallbackList* FallbackFonts;
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
/// Renamed UeeHDRProbes into UseHDRProbes
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Engine/Core/Config/GraphicsSettings.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
#include "Engine/Render2D/Render2D.h"
|
||||
|
||||
bool Graphics::UseVSync = false;
|
||||
Quality Graphics::AAQuality = Quality::Medium;
|
||||
@@ -69,6 +70,9 @@ void GraphicsSettings::Apply()
|
||||
Graphics::GIQuality = GIQuality;
|
||||
Graphics::PostProcessSettings = ::PostProcessSettings();
|
||||
Graphics::PostProcessSettings.BlendWith(PostProcessSettings, 1.0f);
|
||||
|
||||
Render2D::EnableFontFallback = EnableFontFallback;
|
||||
Render2D::FallbackFonts = FallbackFonts;
|
||||
}
|
||||
|
||||
void Graphics::DisposeDevice()
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of functions to handle text rendering with fallback font
|
||||
/// </summary>
|
||||
public static class FallbackTextUtils
|
||||
{
|
||||
public static FallbackFonts Fallbacks
|
||||
{
|
||||
get; set;
|
||||
} = null;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void DrawText(Font font, string text, Color color, ref TextLayoutOptions layout, MaterialBase customMaterial = null, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
Render2D.DrawText(font, Fallbacks, text, color, ref layout, customMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Render2D.DrawText(font, text, color, ref layout, customMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void DrawText(Font font, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
Render2D.DrawText(font, Fallbacks, text, color, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
Render2D.DrawText(font, text, color, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void DrawText(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
Render2D.DrawText(font, Fallbacks, text, color, ref layout, customMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Render2D.DrawText(font, text, color, ref layout, customMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 MeasureText(Font font, string text, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.MeasureText(Fallbacks, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 MeasureText(Font font, string text, ref TextRange textRange, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.MeasureText(Fallbacks, text, ref textRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref textRange);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 MeasureText(Font font, string text, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.MeasureText(Fallbacks, text, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 MeasureText(Font font, string text, ref TextRange textRange, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.MeasureText(Fallbacks, text, ref textRange, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref textRange, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int HitTestText(Font font, string text, Float2 location, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.HitTestText(Fallbacks, text, location);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.HitTestText(text, location);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int HitTestText(Font font, string text, ref TextRange textRange, Float2 location, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.HitTestText(Fallbacks, text, ref textRange, location);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.HitTestText(text, ref textRange, location);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int HitTestText(Font font, string text, Float2 location, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.HitTestText(Fallbacks, text, location, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.HitTestText(text, location, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int HitTestText(Font font, string text, ref TextRange textRange, Float2 location, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.HitTestText(Fallbacks, text, ref textRange, location, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.HitTestText(text, ref textRange, location, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 GetCharPosition(Font font, string text, int index, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.GetCharPosition(Fallbacks, text, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.GetCharPosition(text, index);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 GetCharPosition(Font font, string text, ref TextRange textRange, int index, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.GetCharPosition(Fallbacks, text, ref textRange, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.GetCharPosition(text, ref textRange, index);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 GetCharPosition(Font font, string text, int index, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.GetCharPosition(Fallbacks, text, index, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.GetCharPosition(text, index, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Float2 GetCharPosition(Font font, string text, ref TextRange textRange, int index, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (Fallbacks != null && useFallback)
|
||||
{
|
||||
return font.GetCharPosition(Fallbacks, text, ref textRange, index, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.GetCharPosition(text, ref textRange, index, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the max font height among the font and all fallback fonts of the same size.
|
||||
/// </summary>
|
||||
/// <param name="font">The primary font to use.</param>
|
||||
/// <param name="fallbacks">The fallback fonts.</param>
|
||||
/// <returns>The max height.</returns>
|
||||
public static float GetMaxHeight(Font font, FallbackFonts fallbacks)
|
||||
{
|
||||
float height = font.Height;
|
||||
|
||||
var fallbackFonts = fallbacks.GetFontList(font.Size);
|
||||
foreach (var item in fallbackFonts)
|
||||
{
|
||||
height = Mathf.Max(height, item.Height);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the max font height among the font and all fallback fonts of the same size.
|
||||
/// </summary>
|
||||
/// <param name="font">The primary font to use.</param>
|
||||
/// <param name="useFallback">Whether to enable fallback fonts, uses <see cref="Fallbacks"/> if true.</param>
|
||||
/// <returns>The max height.</returns>
|
||||
public static float GetMaxHeight(Font font, bool useFallback = true)
|
||||
{
|
||||
if(Fallbacks != null && useFallback)
|
||||
{
|
||||
return GetMaxHeight(font, Fallbacks);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,18 @@ void Font::Invalidate()
|
||||
_characters.Clear();
|
||||
}
|
||||
|
||||
inline API_FUNCTION() float Font::GetMaxHeight(FontFallbackList* fallbacks) const
|
||||
{
|
||||
float height = GetHeight();
|
||||
auto& fallbackFonts = fallbacks->GetFontList(GetSize());
|
||||
for (int32 i = 0; i < fallbackFonts.Count(); i++)
|
||||
{
|
||||
height = Math::Max(height, static_cast<float>(fallbackFonts[i]->GetHeight()));
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
void Font::ProcessText(const StringView& text, Array<FontLineCache>& outputLines, const TextLayoutOptions& layout)
|
||||
{
|
||||
float cursorX = 0;
|
||||
@@ -548,7 +560,7 @@ void Font::ProcessText(FontFallbackList* fallbacks, const StringView& text, Arra
|
||||
}
|
||||
}
|
||||
|
||||
Float2 Font::MeasureText(const StringView& text, const TextLayoutOptions& layout)
|
||||
Float2 Font::MeasureTextInternal(const StringView& text, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.IsEmpty())
|
||||
@@ -569,7 +581,7 @@ Float2 Font::MeasureText(const StringView& text, const TextLayoutOptions& layout
|
||||
return max;
|
||||
}
|
||||
|
||||
Float2 Font::MeasureText(FontFallbackList* fallbacks, const StringView& text, const TextLayoutOptions& layout)
|
||||
Float2 Font::MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.IsEmpty())
|
||||
@@ -590,7 +602,7 @@ Float2 Font::MeasureText(FontFallbackList* fallbacks, const StringView& text, co
|
||||
return max;
|
||||
}
|
||||
|
||||
int32 Font::HitTestText(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
|
||||
int32 Font::HitTestTextInternal(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.Length() <= 0)
|
||||
@@ -664,7 +676,7 @@ int32 Font::HitTestText(const StringView& text, const Float2& location, const Te
|
||||
return smallestIndex;
|
||||
}
|
||||
|
||||
int32 Font::HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location, const TextLayoutOptions& layout)
|
||||
int32 Font::HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.Length() <= 0)
|
||||
@@ -764,7 +776,7 @@ int32 Font::HitTestText(FontFallbackList* fallbacks, const StringView& text, con
|
||||
return smallestIndex;
|
||||
}
|
||||
|
||||
Float2 Font::GetCharPosition(const StringView& text, int32 index, const TextLayoutOptions& layout)
|
||||
Float2 Font::GetCharPositionInternal(const StringView& text, int32 index, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.IsEmpty())
|
||||
@@ -818,7 +830,7 @@ Float2 Font::GetCharPosition(const StringView& text, int32 index, const TextLayo
|
||||
return rootOffset + Float2(lines.Last().Location.X + lines.Last().Size.X, static_cast<float>((lines.Count() - 1) * baseLinesDistance));
|
||||
}
|
||||
|
||||
Float2 Font::GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index, const TextLayoutOptions& layout)
|
||||
Float2 Font::GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index, const TextLayoutOptions& layout)
|
||||
{
|
||||
// Check if there is no need to do anything
|
||||
if (text.IsEmpty())
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Engine/Content/AssetReference.h"
|
||||
#include "Engine/Scripting/ScriptingObject.h"
|
||||
#include "TextLayoutOptions.h"
|
||||
#include "Render2D.h"
|
||||
|
||||
class FontAsset;
|
||||
class FontFallbackList;
|
||||
@@ -402,7 +403,31 @@ public:
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Gets the maximum height among the font and the fallback fonts.
|
||||
/// </summary>
|
||||
/// <param name="fallbacks">The fallback fonts.</param>
|
||||
/// <returns>The maximum height.</returns>
|
||||
API_FUNCTION() float GetMaxHeight(FontFallbackList* fallbacks) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum height among the font and the fallback fonts, uses the default font defined in <see cref="Render2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="fallbacks">The fallback fonts.</param>
|
||||
/// <returns>The maximum height.</returns>
|
||||
API_FUNCTION() FORCE_INLINE float GetMaxHeight() const
|
||||
{
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts)
|
||||
{
|
||||
return GetMaxHeight(Render2D::FallbackFonts);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
@@ -410,12 +435,12 @@ public:
|
||||
void ProcessText(const StringView& text, Array<FontLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
API_FUNCTION() Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
Array<FontLineCache> lines;
|
||||
ProcessText(text, lines, layout);
|
||||
@@ -423,13 +448,13 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
API_FUNCTION() Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
Array<FontLineCache> lines;
|
||||
ProcessText(textRange.Substring(text), lines, layout);
|
||||
@@ -437,7 +462,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
@@ -447,7 +472,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
@@ -458,7 +483,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
@@ -466,12 +491,12 @@ public:
|
||||
void ProcessText(FontFallbackList* fallbacks, const StringView& text, Array<BlockedTextLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
API_FUNCTION() Array<BlockedTextLineCache> ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Array<BlockedTextLineCache> ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
Array<BlockedTextLineCache> lines;
|
||||
ProcessText(fallbacks, text, lines, layout);
|
||||
@@ -479,13 +504,13 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
API_FUNCTION() Array<BlockedTextLineCache> ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Array<BlockedTextLineCache> ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
Array<BlockedTextLineCache> lines;
|
||||
ProcessText(fallbacks, textRange.Substring(text), lines, layout);
|
||||
@@ -493,7 +518,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <returns>The output lines list.</returns>
|
||||
@@ -503,7 +528,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes text to get cached lines for rendering.
|
||||
/// Processes text to get cached lines for rendering, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
@@ -514,122 +539,293 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text.
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
API_FUNCTION() Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text.
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return MeasureText(textRange.Substring(text), layout);
|
||||
return MeasureTextInternal(textRange.Substring(text), layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text)
|
||||
{
|
||||
return MeasureTextInternal(text, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
|
||||
{
|
||||
return MeasureTextInternal(textRange.Substring(text), TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return MeasureTextInternal(fallbacks, textRange.Substring(text), layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text)
|
||||
{
|
||||
return MeasureTextInternal(fallbacks, text, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange)
|
||||
{
|
||||
return MeasureTextInternal(fallbacks, textRange.Substring(text), TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout) {
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return MeasureTextInternal(Render2D::FallbackFonts, text, layout);
|
||||
}
|
||||
else {
|
||||
return MeasureTextInternal(text, layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return MeasureTextInternal(Render2D::FallbackFonts, textRange.Substring(text), layout);
|
||||
}
|
||||
else {
|
||||
return MeasureTextInternal(textRange.Substring(text), layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text)
|
||||
{
|
||||
return MeasureText(text, TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return MeasureTextInternal(Render2D::FallbackFonts, text, TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return MeasureTextInternal(text, TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
|
||||
{
|
||||
return MeasureText(textRange.Substring(text), TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return MeasureTextInternal(Render2D::FallbackFonts, textRange.Substring(text), TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return MeasureTextInternal(textRange.Substring(text), TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="layout">The layout properties.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return MeasureText(fallbacks, textRange.Substring(text), layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text)
|
||||
{
|
||||
return MeasureText(fallbacks, text, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures minimum size of the rectangle that will be needed to draw given text
|
||||
/// </summary>.
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <returns>The minimum size for that text and fot to render properly.</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange)
|
||||
{
|
||||
return MeasureText(fallbacks, textRange.Substring(text), TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// Calculates hit character index at given location, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() int32 HitTestText(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
API_FUNCTION() int32 HitTestTextInternal(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// Calculates hit character index at given location, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return HitTestText(textRange.Substring(text), location, layout);
|
||||
return HitTestTextInternal(textRange.Substring(text), location, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// Calculates hit character index at given location, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, const Float2& location)
|
||||
{
|
||||
return HitTestTextInternal(text, location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
|
||||
{
|
||||
return HitTestTextInternal(textRange.Substring(text), location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return HitTestTextInternal(fallbacks, textRange.Substring(text), location, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location)
|
||||
{
|
||||
return HitTestTextInternal(fallbacks, text, location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
|
||||
{
|
||||
return HitTestTextInternal(fallbacks, textRange.Substring(text), location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout) {
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return HitTestTextInternal(Render2D::FallbackFonts, text, location, layout);
|
||||
}
|
||||
else {
|
||||
return HitTestTextInternal(text, location, layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return HitTestTextInternal(Render2D::FallbackFonts, textRange.Substring(text), location, layout);
|
||||
}
|
||||
else {
|
||||
return HitTestTextInternal(textRange.Substring(text), location, layout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, const Float2& location)
|
||||
{
|
||||
return HitTestText(text, location, TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return HitTestTextInternal(Render2D::FallbackFonts, text, location, TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return HitTestTextInternal(text, location, TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// Calculates hit character index at given location, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
@@ -637,89 +833,156 @@ public:
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
|
||||
{
|
||||
return HitTestText(textRange.Substring(text), location, TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return HitTestTextInternal(Render2D::FallbackFonts, textRange.Substring(text), location, TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return HitTestTextInternal(textRange.Substring(text), location, TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return HitTestText(fallbacks, textRange.Substring(text), location, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location)
|
||||
{
|
||||
return HitTestText(fallbacks, text, location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="location">The input location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
API_FUNCTION() FORCE_INLINE int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
|
||||
{
|
||||
return HitTestText(fallbacks, textRange.Substring(text), location, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index.
|
||||
/// Calculates character position for given text and character index, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() Float2 GetCharPosition(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
API_FUNCTION() Float2 GetCharPositionInternal(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index.
|
||||
/// Calculates character position for given text and character index, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return GetCharPosition(textRange.Substring(text), index, layout);
|
||||
return GetCharPositionInternal(textRange.Substring(text), index, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index
|
||||
/// Calculates character position for given text and character index, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, int32 index)
|
||||
{
|
||||
return GetCharPositionInternal(text, index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, with font fallbacking disabled.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
|
||||
{
|
||||
return GetCharPositionInternal(textRange.Substring(text), index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return GetCharPositionInternal(fallbacks, textRange.Substring(text), index, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index)
|
||||
{
|
||||
return GetCharPositionInternal(fallbacks, text, index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, using custom fallback options.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
|
||||
{
|
||||
return GetCharPositionInternal(fallbacks, textRange.Substring(text), index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout) {
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return GetCharPositionInternal(Render2D::FallbackFonts, text, index, layout);
|
||||
}
|
||||
else {
|
||||
return GetCharPositionInternal(text, index, layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return GetCharPositionInternal(Render2D::FallbackFonts, textRange.Substring(text), index, layout);
|
||||
}
|
||||
else {
|
||||
return GetCharPositionInternal(textRange.Substring(text), index, layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, int32 index)
|
||||
{
|
||||
return GetCharPosition(text, index, TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return GetCharPositionInternal(Render2D::FallbackFonts, text, index, TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return GetCharPositionInternal(text, index, TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index
|
||||
/// Calculates character position for given text and character index, follows the fallback settings defined in <see cref="Render2D" />.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
@@ -727,52 +990,12 @@ public:
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
|
||||
{
|
||||
return GetCharPosition(textRange.Substring(text), index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index.
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <param name="layout">The text layout properties.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
|
||||
{
|
||||
return GetCharPosition(fallbacks, textRange.Substring(text), index, layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index)
|
||||
{
|
||||
return GetCharPosition(fallbacks, text, index, TextLayoutOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given text and character index
|
||||
/// </summary>
|
||||
/// <param name="text">The input text to test.</param>
|
||||
/// <param name="textRange">The input text range (substring range of the input text parameter).</param>
|
||||
/// <param name="index">The text position to get coordinates of.</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
|
||||
{
|
||||
return GetCharPosition(fallbacks, textRange.Substring(text), index, TextLayoutOptions());
|
||||
if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
|
||||
return GetCharPositionInternal(Render2D::FallbackFonts, textRange.Substring(text), index, TextLayoutOptions());
|
||||
}
|
||||
else {
|
||||
return GetCharPositionInternal(textRange.Substring(text), index, TextLayoutOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -182,6 +182,8 @@ struct ClipMask
|
||||
};
|
||||
|
||||
Render2D::RenderingFeatures Render2D::Features = RenderingFeatures::VertexSnapping;
|
||||
bool Render2D::EnableFontFallback = true;
|
||||
FontFallbackList* Render2D::FallbackFonts = nullptr;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a text.
|
||||
/// Draws a text, follows the font fallback settings defined in <see cref="Render2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="font">The font to use.</param>
|
||||
/// <param name="text">The text to render.</param>
|
||||
@@ -128,7 +128,7 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a text using a custom material shader. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling).
|
||||
/// Draws a text using a custom material shader. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling). Follows the font fallback settings defined in <see cref="Render2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="font">The font to use.</param>
|
||||
/// <param name="customMaterial">Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.</param>
|
||||
|
||||
@@ -54,8 +54,6 @@ API_CLASS(Static) class FLAXENGINE_API Render2D
|
||||
};
|
||||
|
||||
public:
|
||||
API_FIELD() static bool EnableFontFallback;
|
||||
API_FIELD() static FontFallbackList* FallbackFonts;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if interface is during rendering phrase (Draw calls may be performed without failing).
|
||||
@@ -72,6 +70,10 @@ public:
|
||||
/// </summary>
|
||||
API_FIELD() static RenderingFeatures Features;
|
||||
|
||||
API_FIELD() static bool EnableFontFallback;
|
||||
|
||||
API_FIELD() static FontFallbackList* FallbackFonts;
|
||||
|
||||
/// <summary>
|
||||
/// Called when frame rendering begins by the graphics device.
|
||||
/// </summary>
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace FlaxEngine.GUI
|
||||
Render2D.DrawRectangle(clientRect, borderColor, BorderThickness);
|
||||
|
||||
// Draw text
|
||||
FallbackTextUtils.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
||||
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace FlaxEngine.GUI
|
||||
var font = Font.GetFont();
|
||||
for (int i = 0; i < _items.Count; i++)
|
||||
{
|
||||
itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + FallbackTextUtils.MeasureText(font, _items[i]).X);
|
||||
itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + font.MeasureText(_items[i]).X);
|
||||
}
|
||||
*/
|
||||
var itemsWidth = Width;
|
||||
@@ -673,7 +673,7 @@ namespace FlaxEngine.GUI
|
||||
var textRect = new Rectangle(margin, 0, clientRect.Width - boxSize - 2.0f * margin, clientRect.Height);
|
||||
Render2D.PushClip(textRect);
|
||||
var textColor = TextColor;
|
||||
FallbackTextUtils.DrawText(Font.GetFont(), FontMaterial, _items[_selectedIndex], textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.DrawText(Font.GetFont(), FontMaterial, _items[_selectedIndex], textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.PopClip();
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
FallbackTextUtils.DrawText(_font.GetFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, BaseLinesGapScale, scale);
|
||||
Render2D.DrawText(_font.GetFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, BaseLinesGapScale, scale);
|
||||
|
||||
if (ClipText)
|
||||
Render2D.PopClip();
|
||||
@@ -254,7 +254,7 @@ namespace FlaxEngine.GUI
|
||||
layout.Bounds.Size.X = Width - Margin.Width;
|
||||
else if (_autoWidth && !_autoHeight)
|
||||
layout.Bounds.Size.Y = Height - Margin.Height;
|
||||
_textSize = FallbackTextUtils.MeasureText(font, _text, ref layout);
|
||||
_textSize = font.MeasureText(_text, ref layout);
|
||||
_textSize.Y *= BaseLinesGapScale;
|
||||
|
||||
// Check if size is controlled via text
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace FlaxEngine.GUI
|
||||
if (!font)
|
||||
break;
|
||||
height = font.Height / DpiScale;
|
||||
return textBlock.Bounds.Location + FallbackTextUtils.GetCharPosition(font, _text, ref textBlock.Range, index - textBlock.Range.StartIndex);
|
||||
return textBlock.Bounds.Location + font.GetCharPosition(_text, ref textBlock.Range, index - textBlock.Range.StartIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace FlaxEngine.GUI
|
||||
var font = textBlock.Style.Font.GetFont();
|
||||
if (!font && textBlock.Range.Length > 0)
|
||||
break;
|
||||
return FallbackTextUtils.HitTestText(font, _text, ref textBlock.Range, location - textBlock.Bounds.Location) + textBlock.Range.StartIndex;
|
||||
return font.HitTestText(_text, ref textBlock.Range, location - textBlock.Bounds.Location) + textBlock.Range.StartIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,8 +288,8 @@ namespace FlaxEngine.GUI
|
||||
// Selection
|
||||
if (hasSelection && textBlock.Style.BackgroundSelectedBrush != null && textBlock.Range.Intersect(ref selection))
|
||||
{
|
||||
var leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : FallbackTextUtils.GetCharPosition(font, _text, selection.StartIndex);
|
||||
var rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : FallbackTextUtils.GetCharPosition(font, _text, selection.EndIndex);
|
||||
var leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : font.GetCharPosition(_text, selection.StartIndex);
|
||||
var rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : font.GetCharPosition(_text, selection.EndIndex);
|
||||
float height = font.Height / DpiScale;
|
||||
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
|
||||
alpha *= alpha;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace FlaxEngine.GUI
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
return FallbackTextUtils.MeasureText(font, _text, ref _layout);
|
||||
return font.MeasureText(_text, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -117,8 +117,8 @@ namespace FlaxEngine.GUI
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
height = FallbackTextUtils.GetMaxHeight(font) / DpiScale;
|
||||
return FallbackTextUtils.GetCharPosition(font, _text, index, ref _layout);
|
||||
height = font.GetMaxHeight() / DpiScale;
|
||||
return font.GetCharPosition(_text, index, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -130,7 +130,7 @@ namespace FlaxEngine.GUI
|
||||
return 0;
|
||||
}
|
||||
|
||||
return FallbackTextUtils.HitTestText(font, _text, location, ref _layout);
|
||||
return font.HitTestText(_text, location, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -169,9 +169,9 @@ namespace FlaxEngine.GUI
|
||||
// Check if sth is selected to draw selection
|
||||
if (HasSelection)
|
||||
{
|
||||
var leftEdge = FallbackTextUtils.GetCharPosition(font, _text, SelectionLeft, ref _layout);
|
||||
var rightEdge = FallbackTextUtils.GetCharPosition(font, _text, SelectionRight, ref _layout);
|
||||
float fontHeight = FallbackTextUtils.GetMaxHeight(font) / DpiScale;
|
||||
var leftEdge = font.GetCharPosition(_text, SelectionLeft, ref _layout);
|
||||
var rightEdge = font.GetCharPosition(_text, SelectionRight, ref _layout);
|
||||
float fontHeight = font.GetMaxHeight() / DpiScale;
|
||||
|
||||
// Draw selection background
|
||||
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
|
||||
@@ -211,11 +211,11 @@ namespace FlaxEngine.GUI
|
||||
var color = TextColor;
|
||||
if (!enabled)
|
||||
color *= 0.6f;
|
||||
FallbackTextUtils.DrawText(font, _text, color, ref _layout, TextMaterial);
|
||||
Render2D.DrawText(font, _text, color, ref _layout, TextMaterial);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_watermarkText) && !IsFocused)
|
||||
{
|
||||
FallbackTextUtils.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
|
||||
Render2D.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
|
||||
}
|
||||
|
||||
// Caret
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace FlaxEngine.GUI
|
||||
textColor *= 0.6f;
|
||||
}
|
||||
|
||||
FallbackTextUtils.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
|
||||
|
||||
if (!_isClosed && EnableContainmentLines)
|
||||
{
|
||||
|
||||
@@ -69,12 +69,6 @@ namespace FlaxEngine.GUI
|
||||
set => _fontSmall = new FontReference(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fallback fonts to use if the primary font can't render the char.
|
||||
/// </summary>
|
||||
[EditorOrder(50)]
|
||||
public FallbackFonts Fallbacks;
|
||||
|
||||
/// <summary>
|
||||
/// The background color.
|
||||
/// </summary>
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace FlaxEngine.GUI
|
||||
Render2D.FillRectangle(new Rectangle(1.1f, 1.1f, Width - 2, Height - 2), style.Background);
|
||||
|
||||
// Tooltip text
|
||||
FallbackTextUtils.DrawText(
|
||||
Render2D.DrawText(
|
||||
style.FontMedium,
|
||||
_currentText,
|
||||
GetClientArea(),
|
||||
|
||||
Reference in New Issue
Block a user