mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 15:46:35 +00:00
Fonts: Fixed crash when manually specifying an EllipsisChar that doesn't exist. (#6480)
This commit is contained in:
parent
b476184574
commit
075b975fed
@ -73,6 +73,7 @@ Other changes:
|
||||
- Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow
|
||||
opening another via simple hovering. (#3496, #4797)
|
||||
- Fonts: Fixed crash when merging fonts and the first font has no valid glyph. (#6446) [@JaedanC]
|
||||
- Fonts: Fixed crash when manually specifying an EllipsisChar that doesn't exist. (#6480)
|
||||
- Misc: Added ImVec2 unary minus operator. (#6368) [@Koostosh]
|
||||
- Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse
|
||||
hover hover when the identifier is at the end of the line. (#5855)
|
||||
|
@ -3200,7 +3200,25 @@ void ImFont::BuildLookupTable()
|
||||
SetGlyphVisible((ImWchar)' ', false);
|
||||
SetGlyphVisible((ImWchar)'\t', false);
|
||||
|
||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// Setup Fallback character
|
||||
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackGlyph = &Glyphs.back();
|
||||
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
|
||||
}
|
||||
}
|
||||
FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
|
||||
// Setup Ellipsis character. It is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||
// FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||
const ImWchar ellipsis_chars[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
||||
@ -3221,25 +3239,6 @@ void ImFont::BuildLookupTable()
|
||||
EllipsisCharStep = (glyph->X1 - glyph->X0) + 1.0f;
|
||||
EllipsisWidth = EllipsisCharStep * 3.0f - 1.0f;
|
||||
}
|
||||
|
||||
// Setup fallback character
|
||||
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackGlyph = &Glyphs.back();
|
||||
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
|
||||
}
|
||||
}
|
||||
|
||||
FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
}
|
||||
|
||||
// API is designed this way to avoid exposing the 4K page size
|
||||
|
Loading…
Reference in New Issue
Block a user