implement multiline text rendering

This commit is contained in:
ohyzha
2024-08-06 10:22:07 +03:00
parent afccf5dee0
commit cb409268a8
7 changed files with 49 additions and 25 deletions

View File

@@ -56,6 +56,7 @@ namespace OpenVulkano
texts.push_back(std::make_pair("ABab?.^{}_cdFGETG123)(", TextConfig()));
texts.push_back(std::make_pair("Hello, World!", TextConfig()));
texts.push_back(std::make_pair("\u0410\u0411\u0412\u041F", TextConfig()));
texts.push_back(std::make_pair("This is first line\nSecond gg line\nThird G line", TextConfig()));
texts[0].second.applyBorder = true;
texts[1].second.backgroundColor.a = 1;
@@ -73,7 +74,7 @@ namespace OpenVulkano
}
#ifdef MSDFGEN_AVAILABLE
m_atlasGenerator.GenerateAtlas(fontPath, charset);
m_atlasGenerator.GenerateAtlas(fontPath, charset, "roboto-regular-atlas.png");
#endif
for (int i = 0; i < texts.size(); i++)
@@ -81,9 +82,8 @@ namespace OpenVulkano
#ifdef MSDFGEN_AVAILABLE
TextDrawable* t = new TextDrawable(&m_atlasGenerator, texts[i].second);
#else
auto metadataInfoPath = resourceLoader.GetResourcePath("atlas_metadata");
auto metadataInfo = resourceLoader.GetResource("atlas_metadata");
auto data = resourceLoader.GetResource("roboto-regular-atlas.png");
auto metadataInfo = TextDrawable::ReadAtlasMetadataFile(metadataInfoPath);
Image::ImageLoaderPng loader;
static auto image = loader.loadData(reinterpret_cast<uint8_t*>(data.Data()), data.Size());
static Texture tex;