From c7983115e9f7bdee8bc76ec17612ef1a45bdc05e Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 8 Jan 2025 18:27:01 +0100 Subject: [PATCH] Fonts: Further tweaks for Ellipsis ("...") character width when automatically created from a single comma character: use AdvanceX as min. --- imgui_draw.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 9e155f592..8baaf8b11 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3796,11 +3796,11 @@ void ImFont::BuildLookupTable() } else if (dot_char != 0) { - const ImFontGlyph* glyph = FindGlyph(dot_char); + const ImFontGlyph* dot_glyph = FindGlyph(dot_char); EllipsisChar = dot_char; EllipsisCharCount = 3; - EllipsisCharStep = (float)(int)(glyph->X1 - glyph->X0) + 1.0f; - EllipsisWidth = glyph->X0 + EllipsisCharStep * 3.0f - 1.0f; + EllipsisCharStep = (float)(int)(dot_glyph->X1 - dot_glyph->X0) + 1.0f; + EllipsisWidth = ImMax(dot_glyph->AdvanceX, dot_glyph->X0 + EllipsisCharStep * 3.0f - 1.0f); // FIXME: Slightly odd for normally mono-space fonts but since this is used for trailing contents. } }