Skip to content

Commit 53dfccb

Browse files
committed
imgui_freetype: Fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails. (#618)
1 parent 5e976e9 commit 53dfccb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Other Changes:
5656
BeginMenu()/EndMenu() or BeginPopup/EndPopup(). (#3223, #1207) [@rokups]
5757
- Drag and Drop: Fixed unintended fallback "..." tooltip display during drag operation when
5858
drag source uses _SourceNoPreviewTooltip flags. (#3160) [@rokups]
59+
- Misc, Freetype: Fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
5960
- CI: Added CI test to verify we're never accidentally dragging libstdc++ (on some compiler setups,
6061
static constructors for non-pod data seems to drag in libstdc++ due to thread-safety concerns).
6162
Fixed a static contructor which led to this dependency on some compiler setups (unclear which).

misc/freetype/imgui_freetype.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// - v0.60: (2019/01/10) re-factored to match big update in STB builder. fixed texture height waste. fixed redundant glyphs when merging. support for glyph padding.
1414
// - v0.61: (2019/01/15) added support for imgui allocators + added FreeType only override function SetAllocatorFunctions().
1515
// - v0.62: (2019/02/09) added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!)
16+
// - v0.63: (2020/06/04) fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
1617

1718
// Gamma Correct Blending:
1819
// FreeType assumes blending in linear space rather than gamma space.
@@ -467,7 +468,6 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
467468
ImFontBuildSrcGlyphFT& src_glyph = src_tmp.GlyphsList[glyph_i];
468469

469470
const FT_Glyph_Metrics* metrics = src_tmp.Font.LoadGlyph(src_glyph.Codepoint);
470-
IM_ASSERT(metrics != NULL);
471471
if (metrics == NULL)
472472
continue;
473473

@@ -559,6 +559,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
559559
ImFontBuildSrcGlyphFT& src_glyph = src_tmp.GlyphsList[glyph_i];
560560
stbrp_rect& pack_rect = src_tmp.Rects[glyph_i];
561561
IM_ASSERT(pack_rect.was_packed);
562+
if (pack_rect.w == 0 && pack_rect.h == 0)
563+
continue;
562564

563565
GlyphInfo& info = src_glyph.Info;
564566
IM_ASSERT(info.Width + padding <= pack_rect.w);

0 commit comments

Comments
 (0)