Closed wolfpld closed 2 years ago
Hello, thanks for reporting.
I think I used Freetype 2.11 last time I made a change (will verify). Just to put that put of the way, and because Freetype’s include system is all weird: can you confirm that your crash doesn’t possibly come from linking with a different version that the includes used? (Aka includes pulled from one version and lib from another)
I think this is highly unlikely. The CI setup I have does a fresh vcpkg install on each build and the resulting executable is also crashing on startup.
Crash is deep in freetype though. Even if we are doing something wrong (which i am not sure we do), freetype should not be crashing. This definitely is a freetype bug, at least in part.
I wonder if this could be the cause: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1076
I have tested imgui_freetype on Arch, which has freetype 2.11 with fixes for this issue (https://github.com/archlinux/svntogit-packages/commit/240e4bbd513dbd4afc0b72f51e53cb0fbb77b458), and it seems to be working fine.
I came up with a workaround for this freetype bug. Would you please try it? https://github.com/ocornut/imgui/compare/master...rokups:rk/freetype
This still crashes at FT_Error error = FT_Load_Glyph(Face, glyph_index, LoadFlags);
in FreeTypeFont::LoadGlyph()
.
I have tried applying the freetype issue 1076 patches (0006-Return_FT_Err_Ok_while_trying_to_render_bitmap.patch
, 0007-Restore_quiet_no-op_rendering_of_bitmap_glyphs.patch
) on the vcpkg side, and it doesn't help. It fixes the issue which @rokups workarounds above, but it still crashes on the line I have mentioned in the previous comment.
FreeType 2.11 has a bug causing that crash in af_face_globals_get_metrics
when built using MSVC: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1075. There's a patch here.
FWIW, Freetype is now fixed on vcpkg, so that's one way of delivery working as intended. It is quite bizarre there wasn't an upstream bug-fix release, considering this issue is quite critical.
Thanks! Closing this as a Freetype bug then.
Next commit will add a comment in imgui_freetype.cpp to help users navigate their way out of this issue:
// If this crash for you: FreeType 2.11.0 has a crash bug on some bitmap/colored fonts.
// - https://gitlab.freedesktop.org/freetype/freetype/-/issues/1076
// - https://github.com/ocornut/imgui/issues/4567
// - https://github.com/ocornut/imgui/issues/4566
// You can use FreeType 2.10, or the patched version of 2.11.0 in VcPkg, or probably any upcoming FreeType version.
FT_Error error = FT_Load_Glyph(Face, glyph_index, LoadFlags);
if (error)
return NULL;
The following is tested against the up-to-date
docking
branch. When freetype rendering is enabled (IMGUI_ENABLE_FREETYPE
, etc.) and freetype 2.11 is in use, you can observe such behavior that:is working as expected. However, adding a
config.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_LightHinting;
line results in an error somewhere inside the freetype library (writing_system_class was nullptr
):Similar, but different behavior may be observed in a more complex case, when merge mode is enabled:
Here the error within freetype is
metrics was nullptr
, at the following call stack:(Trying to replicate this with two simple ranges, both on Arial, didn't succeed.)
None of this happens with previous freetype versions.