Update fallback glyph handling
This commit is contained in:
@@ -126,9 +126,22 @@ namespace OpenVulkano::Scene
|
||||
m_uniBuffer.binding.stageFlags = ShaderProgramType::FRAGMENT;
|
||||
}
|
||||
|
||||
uint32_t TextDrawable::GetFallbackGlyph() const
|
||||
{
|
||||
if (m_atlasData->glyphs.find(MISSING_GLYPH_SYMBOL) != m_atlasData->glyphs.end())
|
||||
{
|
||||
return MISSING_GLYPH_SYMBOL;
|
||||
}
|
||||
Logger::RENDER->warn("Could not find glyph for character ? to use as fallback. Using first glyph instead");
|
||||
return m_atlasData->glyphs.begin()->first;
|
||||
}
|
||||
|
||||
|
||||
void TextDrawable::GenerateText(const std::string& text, const Math::Vector3f& pos)
|
||||
{
|
||||
if (text.empty()) return;
|
||||
if (!m_atlasData && !*m_atlasData) { Logger::RENDER->error("Must have glyphs"); return;}
|
||||
const uint32_t fallbackGlyph = GetFallbackGlyph();
|
||||
|
||||
m_text = text;
|
||||
|
||||
@@ -161,16 +174,8 @@ namespace OpenVulkano::Scene
|
||||
|
||||
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;
|
||||
}
|
||||
Logger::RENDER->warn("Could not find glyph for character {}, using fallback", c);
|
||||
c = fallbackGlyph;
|
||||
}
|
||||
|
||||
uint32_t vIdx = i * 4;
|
||||
|
||||
Reference in New Issue
Block a user