refactor code and support utf8 strings rendering

This commit is contained in:
ohyzha
2024-08-02 23:08:24 +03:00
parent 875ad80337
commit 9589b4d39f
11 changed files with 70 additions and 30 deletions

View File

@@ -59,18 +59,17 @@ namespace OpenVulkano::Scene
m_generator.generate(glyphsGeometry.data(), glyphsGeometry.size());
int idx = 0;
BitmapConstRef<byte, 1> storage = m_generator.atlasStorage();
const BitmapConstRef<byte, 1>& storage = m_generator.atlasStorage();
m_atlasTex.resolution = Math::Vector3ui(storage.width, storage.height, 1);
m_atlasTex.textureBuffer = (msdfgen::byte*) storage.pixels;
m_atlasTex.format = OpenVulkano::DataFormat::R8_UNORM;
m_atlasTex.size = storage.width * storage.height * 1; // 1 channel
for (const auto& glyph: glyphsGeometry)
{
unicode_t c = static_cast<char8_t>(glyph.getCodepoint());
GlyphInfo info;
info.texture.resolution = Math::Vector3ui(storage.width, storage.height, 1);
info.texture.textureBuffer = (msdfgen::byte*)storage.pixels;
info.texture.format = OpenVulkano::DataFormat::R8_UNORM;
info.texture.size = storage.width * storage.height * 1; // 1 channel
info.geometry = glyph;
info.glyphBox = m_generator.getLayout()[idx++];
m_symbols[c] = std::move(info);
m_symbols[glyph.getCodepoint()] = std::move(info);
}
savePng(m_generator.atlasStorage(), outputFile.c_str());
destroyFont(font);