imgui_freetype: Fixed crash when FT_Render_Glyph() returns NULL (which apparently happens with Freetype 2.11). (#4394, #4145 ?)

This commit is contained in:
ocornut 2021-08-23 16:42:58 +02:00
parent 6afe9bbb45
commit 68f428b449
2 changed files with 7 additions and 2 deletions

View File

@ -40,9 +40,12 @@ Breaking Changes:
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
very useful in practice, and the only use of it in the demo was illfit. very useful in practice, and the only use of it in the demo was illfit.
Other Changes: Other Changes:
- imgui_freetype: Fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL
(which apparently happens with Freetype 2.11). (#4394, #4145?).
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.84.2 (Released 2021-08-23) VERSION 1.84.2 (Released 2021-08-23)
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -6,6 +6,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL.
// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs. // 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs.
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format. // 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format.
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+). // 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
@ -539,7 +540,8 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
// Render glyph into a bitmap (currently held by FreeType) // Render glyph into a bitmap (currently held by FreeType)
const FT_Bitmap* ft_bitmap = src_tmp.Font.RenderGlyphAndGetInfo(&src_glyph.Info); const FT_Bitmap* ft_bitmap = src_tmp.Font.RenderGlyphAndGetInfo(&src_glyph.Info);
IM_ASSERT(ft_bitmap); if (ft_bitmap == NULL)
continue;
// Allocate new temporary chunk if needed // Allocate new temporary chunk if needed
const int bitmap_size_in_bytes = src_glyph.Info.Width * src_glyph.Info.Height * 4; const int bitmap_size_in_bytes = src_glyph.Info.Width * src_glyph.Info.Height * 4;