Skip to content

Commit

Permalink
Fall back to a higher resolution font if the default one isn't availa…
Browse files Browse the repository at this point in the history
…ble.
  • Loading branch information
codereader committed Nov 19, 2017
1 parent 0739f21 commit 7a34352
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions plugins/dm.gui/gui/RenderableText.cpp
Expand Up @@ -35,15 +35,35 @@ void RenderableText::printMissingGlyphSetError() const

void RenderableText::realiseFontShaders()
{
fonts::IGlyphSetPtr glyphSet = _font->getGlyphSet(_resolution);
if (glyphSet)
{
glyphSet->realiseShaders();
}
else
{
printMissingGlyphSetError();
}
while (_resolution < fonts::Resolution::NumResolutions)
{
fonts::IGlyphSetPtr glyphSet = _font->getGlyphSet(_resolution);

if (glyphSet)
{
glyphSet->realiseShaders();
break;
}
else
{
printMissingGlyphSetError();

switch (_resolution)
{
case fonts::Resolution12:
rWarning() << "Falling back to higher resolution 24..." << std::endl;
_resolution = fonts::Resolution24;
break;
case fonts::Resolution24:
rWarning() << "Falling back to higher resolution 48..." << std::endl;
_resolution = fonts::Resolution48;
break;
case fonts::Resolution48:
rWarning() << "No resolutions to fall back." << std::endl;
return;
}
}
}
}

void RenderableText::render()
Expand Down

0 comments on commit 7a34352

Please sign in to comment.