render question mark if glyph is not loaded

This commit is contained in:
ohyzha
2024-08-08 12:23:38 +03:00
parent a390470420
commit 1659cee9eb
2 changed files with 44 additions and 36 deletions

View File

@@ -57,6 +57,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("Text with unsupported glyphs \u1E30\u1E31 is coming", 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;

View File

@@ -170,8 +170,21 @@ namespace OpenVulkano::Scene
cursorX = pos.x;
continue;
}
if (symbols->find(c) != symbols->end())
if (symbols->find(c) == symbols->end())
{
Logger::RENDER->error("Could not find glyph for character {}", c);
if (symbols->find(static_cast<uint32_t>('?')) != symbols->end())
{
c = static_cast<uint32_t>('?');
}
else
{
Logger::RENDER->error("Could not find glyph for character ? to replace glyph {}", c);
continue;
}
}
uint32_t vIdx = i * 4;
uint32_t indices[] = { 1 + vIdx, 2 + vIdx, 3 + vIdx, 1 + vIdx, 3 + vIdx, 0 + vIdx };
GlyphInfo& info = symbols->at(c);
@@ -204,12 +217,6 @@ namespace OpenVulkano::Scene
// when setting for depth comparison operator will be available( <= )
cursorX += info.advance + 0.08;
}
else
{
// throw ? replace with ? character (if available) ?
Logger::RENDER->error("Could not find glyph for character {}", c);
}
}
SimpleDrawable::Init(m_shader, &m_geometry, &m_material, &m_uniBuffer);
}