_font cache whitespace

This commit is contained in:
2023-09-10 12:52:24 +03:00
parent 479b65fab5
commit a2edead792
4 changed files with 112 additions and 126 deletions

View File

@@ -225,6 +225,70 @@ struct TIsPODType<FontCharacterEntry>
enum { Value = true };
};
/// <summary>
/// The font line info generated during text processing.
/// </summary>
API_STRUCT(NoDefault) struct FontLineCache
{
DECLARE_SCRIPTING_TYPE_MINIMAL(FontLineCache);
/// <summary>
/// The root position of the line (upper left corner).
/// </summary>
API_FIELD() Float2 Location;
/// <summary>
/// The line bounds (width and height).
/// </summary>
API_FIELD() Float2 Size;
/// <summary>
/// The first character index (from the input text).
/// </summary>
API_FIELD() int32 FirstCharIndex;
/// <summary>
/// The last character index (from the input text).
/// </summary>
API_FIELD() int32 LastCharIndex;
};
template<>
struct TIsPODType<FontLineCache>
{
enum { Value = true };
};
/// <summary>
/// The font line info generated during text processing.
/// </summary>
API_STRUCT(NoDefault) struct FontLineCharacterCache
{
DECLARE_SCRIPTING_TYPE_MINIMAL(FontLineCharacterCache);
/// <summary>
///
/// </summary>
FontCharacterEntry Entry;
/// <summary>
///
/// </summary>
int32 Kerning;
/// <summary>
///
/// </summary>
bool IsWhitespace;
};
template<>
struct TIsPODType<FontLineCharacterCache>
{
enum { Value = true };
};
/// <summary>
/// Represents font object that can be using during text rendering (it uses Font Asset but with pre-cached data for chosen font properties).
/// </summary>
@@ -350,7 +414,8 @@ public:
/// <param name="text">The input text.</param>
/// <param name="layout">The layout properties.</param>
/// <param name="outputLines">The output lines list.</param>
void ProcessText(const StringView& text, Array<FontLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout, Array<FontCharacterEntry>& characterEntries, Array<int32>& characterKernings);
/// <param name="characterEntries">Cached information about each character in lines.</param>
void ProcessText(const StringView& text, Array<FontLineCache>& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout, Array<FontLineCharacterCache>* characterEntries = nullptr);
/// <summary>
/// Processes text to get cached lines for rendering.
@@ -361,9 +426,7 @@ public:
API_FUNCTION() Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array<FontLineCache> lines;
Array<FontCharacterEntry> characterEntries;
Array<int32> xAdvances;
ProcessText(text, lines, layout, characterEntries, xAdvances);
ProcessText(text, lines, layout);
return lines;
}
@@ -377,9 +440,7 @@ public:
API_FUNCTION() Array<FontLineCache> ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array<FontLineCache> lines;
Array<FontCharacterEntry> characterEntries;
Array<int32> xAdvances;
ProcessText(textRange.Substring(text), lines, layout, characterEntries, xAdvances);
ProcessText(textRange.Substring(text), lines, layout);
return lines;
}