|
@@ -2795,23 +2795,6 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
|
for (int i = 0; i < atlas->Fonts.Size; i++)
|
|
for (int i = 0; i < atlas->Fonts.Size; i++)
|
|
if (atlas->Fonts[i]->DirtyLookupTables)
|
|
if (atlas->Fonts[i]->DirtyLookupTables)
|
|
atlas->Fonts[i]->BuildLookupTable();
|
|
atlas->Fonts[i]->BuildLookupTable();
|
|
-
|
|
|
|
- // Ellipsis character 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: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots.
|
|
|
|
- for (int i = 0; i < atlas->Fonts.size(); i++)
|
|
|
|
- {
|
|
|
|
- ImFont* font = atlas->Fonts[i];
|
|
|
|
- if (font->EllipsisChar != (ImWchar)-1)
|
|
|
|
- continue;
|
|
|
|
- const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
|
|
|
- for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
|
|
|
|
- if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
|
|
|
|
- {
|
|
|
|
- font->EllipsisChar = ellipsis_variants[j];
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// Retrieve list of range (2 int per range, values are inclusive)
|
|
// Retrieve list of range (2 int per range, values are inclusive)
|
|
@@ -3110,8 +3093,9 @@ ImFont::ImFont()
|
|
{
|
|
{
|
|
FontSize = 0.0f;
|
|
FontSize = 0.0f;
|
|
FallbackAdvanceX = 0.0f;
|
|
FallbackAdvanceX = 0.0f;
|
|
- FallbackChar = (ImWchar)'?';
|
|
|
|
|
|
+ FallbackChar = (ImWchar)-1;
|
|
EllipsisChar = (ImWchar)-1;
|
|
EllipsisChar = (ImWchar)-1;
|
|
|
|
+ DotChar = (ImWchar)-1;
|
|
FallbackGlyph = NULL;
|
|
FallbackGlyph = NULL;
|
|
ContainerAtlas = NULL;
|
|
ContainerAtlas = NULL;
|
|
ConfigData = NULL;
|
|
ConfigData = NULL;
|
|
@@ -3142,6 +3126,14 @@ void ImFont::ClearOutputData()
|
|
MetricsTotalSurface = 0;
|
|
MetricsTotalSurface = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static ImWchar FindFirstExistingGlyph(ImFont* font, const ImWchar* candidate_chars, int candidate_chars_count)
|
|
|
|
+{
|
|
|
|
+ for (int n = 0; n < candidate_chars_count; n++)
|
|
|
|
+ if (font->FindGlyphNoFallback(candidate_chars[n]) != NULL)
|
|
|
|
+ return candidate_chars[n];
|
|
|
|
+ return (ImWchar)-1;
|
|
|
|
+}
|
|
|
|
+
|
|
void ImFont::BuildLookupTable()
|
|
void ImFont::BuildLookupTable()
|
|
{
|
|
{
|
|
int max_codepoint = 0;
|
|
int max_codepoint = 0;
|
|
@@ -3184,9 +3176,31 @@ void ImFont::BuildLookupTable()
|
|
SetGlyphVisible((ImWchar)' ', false);
|
|
SetGlyphVisible((ImWchar)' ', false);
|
|
SetGlyphVisible((ImWchar)'\t', false);
|
|
SetGlyphVisible((ImWchar)'\t', false);
|
|
|
|
|
|
- // Setup fall-backs
|
|
|
|
|
|
+ // Ellipsis character 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 };
|
|
|
|
+ const ImWchar dots_chars[] = { (ImWchar)'.', (ImWchar)0xFF0E };
|
|
|
|
+ if (EllipsisChar == (ImWchar)-1)
|
|
|
|
+ EllipsisChar = FindFirstExistingGlyph(this, ellipsis_chars, IM_ARRAYSIZE(ellipsis_chars));
|
|
|
|
+ if (DotChar == (ImWchar)-1)
|
|
|
|
+ DotChar = FindFirstExistingGlyph(this, dots_chars, IM_ARRAYSIZE(dots_chars));
|
|
|
|
+
|
|
|
|
+ // Setup fallback character
|
|
|
|
+ const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
|
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
|
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
|
- FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
|
|
|
|
|
+ if (FallbackGlyph == NULL)
|
|
|
|
+ {
|
|
|
|
+ FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
|
|
|
+ FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
|
|
|
+ if (FallbackGlyph == NULL)
|
|
|
|
+ {
|
|
|
|
+ FallbackGlyph = &Glyphs.back();
|
|
|
|
+ FallbackChar = FallbackGlyph->Codepoint;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
|
for (int i = 0; i < max_codepoint + 1; i++)
|
|
for (int i = 0; i < max_codepoint + 1; i++)
|
|
if (IndexAdvanceX[i] < 0.0f)
|
|
if (IndexAdvanceX[i] < 0.0f)
|
|
IndexAdvanceX[i] = FallbackAdvanceX;
|
|
IndexAdvanceX[i] = FallbackAdvanceX;
|