Add multifont rendering to editor

This commit is contained in:
ExMatics HydrogenC
2023-11-30 13:41:45 +08:00
parent a3bc394e4e
commit 41bbce56f6
69 changed files with 1132 additions and 647 deletions

View File

@@ -8,7 +8,6 @@
#include "Engine/Content/AssetReference.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "TextLayoutOptions.h"
#include "MultiFont.h"
class FontAsset;
struct FontTextureAtlasSlot;
@@ -341,15 +340,6 @@ public:
/// <param name="outputLines">The output lines list.</param>
void ProcessText(const StringView& text, Array<FontLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
/// <summary>
/// Processes text to get cached lines for rendering.
/// </summary>
/// <param name="fonts">The font list.</param>
/// <param name="text">The input text.</param>
/// <param name="layout">The layout properties.</param>
/// <param name="outputLines">The output lines list.</param>
static void ProcessText(const Array<Font*>& fonts, const StringView& text, Array<MultiFontLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
/// <summary>
/// Processes text to get cached lines for rendering.
/// </summary>
@@ -406,17 +396,6 @@ public:
/// <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);
/*
/// <summary>
/// Measures minimum size of the rectangle that will be needed to draw given text.
/// </summary>
/// <param name="fonts">The fonts to render with.</param>
/// <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() static Float2 MeasureText(const Array<Font*>& fonts, 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>
@@ -504,18 +483,6 @@ public:
/// <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);
/*
/// <summary>
/// Calculates character position for given text and character index.
/// </summary>
/// <param name="fonts">The fonts to use.</param>
/// <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() static Float2 GetCharPosition(const Array<Font*>& fonts, const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
*/
/// <summary>
/// Calculates character position for given text and character index.
/// </summary>
@@ -557,28 +524,7 @@ public:
/// </summary>
/// <param name="c">The char to test.</param>
/// <returns>True if the font contains the glyph of the char, otherwise false.</returns>
API_FUNCTION() FORCE_INLINE bool ContainsChar(Char c);
/// <summary>
/// Gets the index of the font that should be used to render the char
/// </summary>
/// <param name="fonts">The font list.</param>
/// <param name="c">The char.</param>
/// <param name="missing">Number to return if char cannot be found.</param>
/// <returns></returns>
API_FUNCTION() FORCE_INLINE static int32 GetCharFontIndex(const Array<Font*>& fonts, Char c, int32 missing = -1) {
int32 fontIndex = 0;
while (fontIndex < fonts.Count() && !fonts[fontIndex]->ContainsChar(c))
{
fontIndex++;
}
if (fontIndex == fonts.Count()) {
return missing;
}
return fontIndex;
}
API_FUNCTION() FORCE_INLINE bool ContainsChar(Char c) const;
/// <summary>
/// Flushes the size of the face with the Free Type library backend.