You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason, ImGui is crashing while building the font atlas. I build a font range based on the user’s locale setting, then I loop through a list of fonts (configurable by the user). For the first font in the list I set MergeMode to false. For every other font in the list I set MergeMode to true so that these fonts will be used as a fallback in case a glyph is not found in a font earlier in the list. I do this first for a variable‐width font, then again for a monospaced font.
The crash happens when the locale is set to en and the font list contains a Japanese font. (Other combinations crash as well; the key seems to be that the Japanese font has no glyphs needed by the chosen locale). Notably it does not crash if the locale is set to ja, or if the Japanese font is removed from the font list.
Here is what the font atlas looks like when the locale is ja and the Japanese font is included in the list:
You can see that the atlas is still a fairly reasonable size and everything is working fine.
Here’s what the stack looks like:
0x000000000543db61 in ImFont::AddGlyph (this=0x76de130, cfg=0x76c1e58, codepoint=32, x0=0, y0=0, x1=0, y1=0, u0=0.998046875, v0=0.2265625, u1=0.998046875, v1=0.2265625,
advance_x=3) at src/third-party/imgui/imgui_draw.cpp:3318
3318 float pad = ContainerAtlas->TexGlyphPadding + 0.99f;
(gdb) p ContainerAtlas
$1 = (ImFontAtlas *) 0x0
(gdb) bt
#0 0x000000000543db61 in ImFont::AddGlyph
(this=0x76de130, cfg=0x76c1e58, codepoint=32, x0=0, y0=0, x1=0, y1=0, u0=0.998046875, v0=0.2265625, u1=0.998046875, v1=0.2265625, advance_x=3)
at src/third-party/imgui/imgui_draw.cpp:3318
#1 0x000000000544586f in ImFontAtlasBuildWithFreeTypeEx (ft_library=0x6e14c80, atlas=0x768e160, extra_flags=0) at src/third-party/imgui/imgui_freetype.cpp:668
#2 0x0000000005446c21 in ImFontAtlasBuildWithFreeType (atlas=0x768e160) at src/third-party/imgui/imgui_freetype.cpp:761
#3 0x000000000543abb2 in ImFontAtlas::Build (this=0x768e160) at src/third-party/imgui/imgui_draw.cpp:2280
#4 0x0000000003127512 in cataimgui::client::load_fonts
(this=0x7688570, gui_font=std::unique_ptr<Font> = {...}, mono_font=std::unique_ptr<Font> = {...}, windowsPalette=..., gui_typefaces=std::vector of length 4, capacity 4 = {...}, mono_typefaces=std::vector of length 2, capacity 2 = {...}) at src/cata_imgui.cpp:447
#5 0x00000000051d329d in catacurses::init_interface () at src/sdltiles.cpp:3742
#6 0x00000000042633a4 in main (argc=2, argv=0x7fffffffdff8) at src/main.cpp:780
This avoids the crash, but when in the English locale it loses the names of the constituent fonts. I haven't dug deeper into how that information is tracked.
Version/Branch of Dear ImGui:
Version 1.86, Branch: master
Back-ends:
SDL
Compiler, OS:
Linux + clang 18.1.8
Full config/build information:
Details:
For some reason, ImGui is crashing while building the font atlas. I build a font range based on the user’s locale setting, then I loop through a list of fonts (configurable by the user). For the first font in the list I set
MergeMode
tofalse
. For every other font in the list I setMergeMode
totrue
so that these fonts will be used as a fallback in case a glyph is not found in a font earlier in the list. I do this first for a variable‐width font, then again for a monospaced font.The crash happens when the locale is set to
en
and the font list contains a Japanese font. (Other combinations crash as well; the key seems to be that the Japanese font has no glyphs needed by the chosen locale). Notably it does not crash if the locale is set toja
, or if the Japanese font is removed from the font list.Here is what the font atlas looks like when the locale is
ja
and the Japanese font is included in the list:You can see that the atlas is still a fairly reasonable size and everything is working fine.
Here’s what the stack looks like:
And here’s what’s in my
load_fonts
function:For each language I have pulled a set of characters from the CLDR database
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
First, define these functions:
Check the args:
Then, call them from
main
just after the renderer is initialized:./example_sdl_sdlrenderer "en"
crashes,./example_sdl_sdlrenderer "ja"
does not.The text was updated successfully, but these errors were encountered: