diff options
| author | Erik Kundiman <erik@megapahit.org> | 2025-01-20 16:00:28 +0800 |
|---|---|---|
| committer | Erik Kundiman <erik@megapahit.org> | 2025-01-20 16:00:28 +0800 |
| commit | ad3694fd4b6bfaf5621a12eb4536a1eb6a10f8f2 (patch) | |
| tree | bc343dc4a0f8a469ecab34e64b5c5dfe76ea1297 /indra/llrender/llfontfreetype.cpp | |
| parent | 45249de1ca418324c4077312eefc7edc7e22c401 (diff) | |
| parent | 306e9e6d0293ed6470db19c0882930fff0cd145f (diff) | |
Merge remote-tracking branch 'secondlife/release/2024.12-ForeverFPS' into 2024.12-ForeverFPS
Diffstat (limited to 'indra/llrender/llfontfreetype.cpp')
| -rw-r--r-- | indra/llrender/llfontfreetype.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index fa76669258..1ca4c8c079 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -554,7 +554,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, l return NULL; llassert(!mIsFallback); - fontp->renderGlyph(requested_glyph_type, glyph_index); + fontp->renderGlyph(requested_glyph_type, glyph_index, wch); EFontGlyphType bitmap_glyph_type = EFontGlyphType::Unspecified; switch (fontp->mFTFace->glyph->bitmap.pixel_mode) @@ -699,7 +699,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } } -void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) const +void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, llwchar wch) const { if (mFTFace == NULL) return; @@ -714,11 +714,28 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) co FT_Error error = FT_Load_Glyph(mFTFace, glyph_index, load_flags); if (FT_Err_Ok != error) { + if (error == FT_Err_Out_Of_Memory) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Out of memory loading glyph for character " << wch << LL_ENDL; + } + std::string message = llformat( - "Error %d (%s) loading glyph %u: bitmap_type=%u, load_flags=%d", - error, FT_Error_String(error), glyph_index, bitmap_type, load_flags); + "Error %d (%s) loading wchar %u glyph %u/%u: bitmap_type=%u, load_flags=%d", + error, FT_Error_String(error), wch, glyph_index, mFTFace->num_glyphs, bitmap_type, load_flags); LL_WARNS_ONCE() << message << LL_ENDL; error = FT_Load_Glyph(mFTFace, glyph_index, load_flags ^ FT_LOAD_COLOR); + if (FT_Err_Invalid_Outline == error + || FT_Err_Invalid_Composite == error + || (FT_Err_Ok != error && LLStringOps::isEmoji(wch))) + { + glyph_index = FT_Get_Char_Index(mFTFace, '?'); + // if '?' is not present, potentially can use last index, that's supposed to be null glyph + if (glyph_index > 0) + { + error = FT_Load_Glyph(mFTFace, glyph_index, load_flags ^ FT_LOAD_COLOR); + } + } llassert_always_msg(FT_Err_Ok == error, message.c_str()); } |
