fix inconsistent spacing for multiline text and support special characters

This commit is contained in:
ohyzha
2025-01-23 16:02:00 +02:00
parent 3a874f1ea6
commit 0583a7e25a
3 changed files with 63 additions and 27 deletions

View File

@@ -55,6 +55,9 @@ namespace OpenVulkano
texts.push_back(std::make_pair("Unsupported glyphs \u1E30\u1E31 are coming", TextConfig()));
texts.push_back(std::make_pair("AAAA, ____", TextConfig()));
texts.push_back(std::make_pair("0123456789", TextConfig()));
texts.push_back(std::make_pair("One\tTwo\t\tThree", TextConfig()));
texts.push_back(std::make_pair("Vertical\vTabs\vHere", TextConfig()));
texts.push_back(std::make_pair("\"\\\"", TextConfig()));
texts.push_back(std::make_pair("This is first line\nSecond gg line\nThird G line", TextConfig()));
texts[1].second.backgroundColor.a = 255;
@@ -86,9 +89,9 @@ namespace OpenVulkano
auto bitmapMetadataInfo = resourceLoader.GetResource("bitmap_atlas_packed.png");
auto bitmapSubpixelRenderingMetadataInfo = resourceLoader.GetResource("bitmap_subpixel_atlas_packed.png");
#endif
for (int i = 0, xOffset = -5; i < atlasesCount; i++, xOffset += 20)
{
float totalH = 0;
for (int j = 0; j < texts.size(); j++)
{
TextDrawable* t = nullptr;
@@ -139,9 +142,10 @@ namespace OpenVulkano
m_drawablesPool[nodeIdx].reset(t);
m_nodesPool[nodeIdx].Init();
m_nodesPool[nodeIdx].SetMatrix(
Math::Utils::translate(glm::mat4x4(1.f), Vector3f(xOffset, 2 - j * 2, 0)));
Math::Utils::translate(glm::mat4x4(1.f), Vector3f(xOffset, 2.f - totalH - (0.5f * j), 0)));
m_nodesPool[nodeIdx].AddDrawable(m_drawablesPool[nodeIdx].get());
m_scene.GetRoot()->AddChild(&m_nodesPool[nodeIdx]);
totalH += t->GetBoundingBox().max.y - t->GetBoundingBox().min.y;
}
}