_font cache processtext entry

This commit is contained in:
2023-09-03 20:11:51 +03:00
parent 4ad78fdb80
commit 54761f40fe
3 changed files with 57 additions and 3 deletions

View File

@@ -1281,7 +1281,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color,
font->ProcessText(text, Lines, layout);
// Render all lines
FontCharacterEntry entry;
//FontCharacterEntry entry;
Render2DDrawCall drawCall;
if (customMaterial)
{
@@ -1299,6 +1299,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color,
Float2 pointer = line.Location;
// Render all characters from the line
int32 entryIndex = 0;
for (int32 charIndex = line.FirstCharIndex; charIndex <= line.LastCharIndex; charIndex++)
{
// Cache current character
@@ -1308,7 +1309,8 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color,
if (currentChar != '\n')
{
// Get character entry
font->GetCharacter(currentChar, entry, enableFallbackFonts);
//font->GetCharacter(currentChar, entry, enableFallbackFonts);
const FontCharacterEntry& entry = line.CharacterEntries[entryIndex];
// Check if need to select/change font atlas (since characters even in the same font may be located in different atlases)
if (fontAtlas == nullptr || entry.TextureIndex != fontAtlasIndex)
@@ -1365,6 +1367,7 @@ void Render2D::DrawText(Font* font, const StringView& text, const Color& color,
// Move
pointer.X += entry.AdvanceX * scale;
}
entryIndex++;
}
}
}