WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 075b975

Browse files
committed
Fonts: Fixed crash when manually specifying an EllipsisChar that doesn't exist. (#6480)
1 parent b476184 commit 075b975

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Other changes:
7373
- Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow
7474
opening another via simple hovering. (#3496, #4797)
7575
- Fonts: Fixed crash when merging fonts and the first font has no valid glyph. (#6446) [@JaedanC]
76+
- Fonts: Fixed crash when manually specifying an EllipsisChar that doesn't exist. (#6480)
7677
- Misc: Added ImVec2 unary minus operator. (#6368) [@Koostosh]
7778
- Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse
7879
hover hover when the identifier is at the end of the line. (#5855)

imgui_draw.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,7 +3200,25 @@ void ImFont::BuildLookupTable()
32003200
SetGlyphVisible((ImWchar)' ', false);
32013201
SetGlyphVisible((ImWchar)'\t', false);
32023202

3203-
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
3203+
// Setup Fallback character
3204+
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
3205+
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
3206+
if (FallbackGlyph == NULL)
3207+
{
3208+
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
3209+
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
3210+
if (FallbackGlyph == NULL)
3211+
{
3212+
FallbackGlyph = &Glyphs.back();
3213+
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
3214+
}
3215+
}
3216+
FallbackAdvanceX = FallbackGlyph->AdvanceX;
3217+
for (int i = 0; i < max_codepoint + 1; i++)
3218+
if (IndexAdvanceX[i] < 0.0f)
3219+
IndexAdvanceX[i] = FallbackAdvanceX;
3220+
3221+
// Setup Ellipsis character. It is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
32043222
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
32053223
// FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots.
32063224
const ImWchar ellipsis_chars[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
@@ -3221,25 +3239,6 @@ void ImFont::BuildLookupTable()
32213239
EllipsisCharStep = (glyph->X1 - glyph->X0) + 1.0f;
32223240
EllipsisWidth = EllipsisCharStep * 3.0f - 1.0f;
32233241
}
3224-
3225-
// Setup fallback character
3226-
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
3227-
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
3228-
if (FallbackGlyph == NULL)
3229-
{
3230-
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
3231-
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
3232-
if (FallbackGlyph == NULL)
3233-
{
3234-
FallbackGlyph = &Glyphs.back();
3235-
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
3236-
}
3237-
}
3238-
3239-
FallbackAdvanceX = FallbackGlyph->AdvanceX;
3240-
for (int i = 0; i < max_codepoint + 1; i++)
3241-
if (IndexAdvanceX[i] < 0.0f)
3242-
IndexAdvanceX[i] = FallbackAdvanceX;
32433242
}
32443243

32453244
// API is designed this way to avoid exposing the 4K page size

0 commit comments

Comments
 (0)