Skip to content

ImGui::RenderTextEllipsis needs latin glyph #4269

@ghost

Description

Version/Branch of Dear ImGui:

Version: 1.83WIP
Branch: Unknown (Dear ImGui version provided by https://github.com/eliasdaler/imgui-sfml)

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_dx10.cpp + imgui_impl_win32.cpp
Compiler: MSVC 192930038
Operating System: Windows 10 Family VERSION(20H2) BUILD(19042.1052) EXPERIENCE(120.2212.2020.0)

My Issue:

Currently working with a chinese font, I don't need to push any latin glyph ranges when adding the font to the atlas.
But a latin character is used in the Dear ImGui code when calculating characters width for tables headers.

The Code

In ImGui::RenderTextEllipsis, EllipsisChar returns 65535

imgui/imgui.cpp

Line 2785 in 30224fd

ImWchar ellipsis_char = font->EllipsisChar;

which triggers the next if state to replace the character used

imgui/imgui.cpp

Line 2787 in 30224fd

if (ellipsis_char == (ImWchar)-1)

by the dot character

imgui/imgui.cpp

Line 2789 in 30224fd

ellipsis_char = (ImWchar)'.';

The Callstack

TLN.exe!ImGui::RenderTextEllipsis(ImDrawList * draw_list, const ImVec2 & pos_min, const ImVec2 & pos_max, float clip_max_x, float ellipsis_max_x, const char * text, const char * text_end_full, const ImVec2 * text_size_if_known) Ligne 2784 C++
TLN.exe!ImGui::TableHeader(const char * label) Ligne 2946 C++
TLN.exe!ImGui::TableHeadersRow() Ligne 2804 C++
TLN.exe!CManager_Window::Wnd_Tasks() Ligne 533 C++
TLN.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Ligne 53 C++ [external code]

Conclusion

Without the dot character (0x002E) pushed into the glyph ranges used by the font, it crashes.
Use the unknown character (0xFFFD) instead of the dot character (0x002E) seems to be a good alternative :
L2789 ellipsis_char = (ImWchar)0xFFFD;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions