Merge pull request #1546 from def-/pr-glyph-missing

Fix text render when a glyph is missing (fixes #1543)
This commit is contained in:
Dennis Felsing 2019-03-28 23:38:31 +01:00 committed by GitHub
commit 5124372e9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -447,7 +447,19 @@ class CTextRender : public IEngineTextRender
if(pFont->m_FtFace->charmap)
GlyphIndex = FT_Get_Char_Index(pFont->m_FtFace, (FT_ULong)Chr);
if(GlyphIndex != 0 && FT_Load_Glyph(pFont->m_FtFace, GlyphIndex, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP))
if(GlyphIndex == 0)
{
const int ReplacementChr = 0x25a1; // White square to indicate missing glyph
GlyphIndex = FT_Get_Char_Index(pFont->m_FtFace, (FT_ULong)ReplacementChr);
if(GlyphIndex == 0)
{
dbg_msg("pFont", "font has no glyph for either %d or replacement char %d", Chr, ReplacementChr);
return;
}
}
if(FT_Load_Glyph(pFont->m_FtFace, GlyphIndex, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP))
{
dbg_msg("pFont", "error loading glyph %d", Chr);
return;