mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
Merge ca1b44fec6183c496ccc896ca412528ad7f6b236 into 1f3ee75ee40c7f224714cd6896f152a902e81652
This commit is contained in:
commit
d212d9b2e9
3
imgui.h
3
imgui.h
@ -4180,6 +4180,9 @@ struct ImFont
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
float Scale; // 4 // in // Legacy base font scale (~1.0f), multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||
#endif
|
||||
// Optional pair kerning. Extra advance in pixels at 'size'. NULL = advance only (no extra cost).
|
||||
float (*KerningFn)(ImFont* font, ImWchar left, ImWchar right, float size, void* user);
|
||||
void* KerningUserData;
|
||||
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
|
||||
@ -7210,6 +7210,7 @@ ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wra
|
||||
|
||||
ImVec2 text_size = ImVec2(0, 0);
|
||||
float line_width = 0.0f;
|
||||
ImWchar prev_c = 0;
|
||||
|
||||
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
||||
const char* word_wrap_eol = NULL;
|
||||
@ -7230,6 +7231,7 @@ ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wra
|
||||
text_size.x = line_width;
|
||||
text_size.y += line_height;
|
||||
line_width = 0.0f;
|
||||
prev_c = 0;
|
||||
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags); // Wrapping skips upcoming blanks
|
||||
if (flags & ImDrawTextFlags_StopOnNewLine)
|
||||
break;
|
||||
@ -7251,6 +7253,7 @@ ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wra
|
||||
text_size.x = ImMax(text_size.x, line_width);
|
||||
text_size.y += line_height;
|
||||
line_width = 0.0f;
|
||||
prev_c = 0;
|
||||
if (flags & ImDrawTextFlags_StopOnNewLine)
|
||||
break;
|
||||
continue;
|
||||
@ -7263,6 +7266,8 @@ ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wra
|
||||
if (char_width < 0.0f)
|
||||
char_width = BuildLoadGlyphGetAdvanceOrFallback(baked, c);
|
||||
char_width *= scale;
|
||||
if (prev_c && font->KerningFn)
|
||||
char_width += font->KerningFn(font, prev_c, (ImWchar)c, size, font->KerningUserData);
|
||||
|
||||
if (line_width + char_width >= max_width)
|
||||
{
|
||||
@ -7271,6 +7276,7 @@ ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wra
|
||||
}
|
||||
|
||||
line_width += char_width;
|
||||
prev_c = (ImWchar)c;
|
||||
}
|
||||
|
||||
if (text_size.x < line_width)
|
||||
@ -7415,6 +7421,7 @@ begin:
|
||||
|
||||
const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
|
||||
const char* word_wrap_eol = NULL;
|
||||
ImWchar prev_c = 0;
|
||||
|
||||
while (s < text_end)
|
||||
{
|
||||
@ -7428,6 +7435,7 @@ begin:
|
||||
{
|
||||
x = origin_x;
|
||||
y += line_height;
|
||||
prev_c = 0;
|
||||
if (y > clip_rect.w)
|
||||
break; // break out of main loop
|
||||
word_wrap_eol = NULL;
|
||||
@ -7449,6 +7457,7 @@ begin:
|
||||
{
|
||||
x = origin_x;
|
||||
y += line_height;
|
||||
prev_c = 0;
|
||||
if (y > clip_rect.w)
|
||||
break; // break out of main loop
|
||||
continue;
|
||||
@ -7461,6 +7470,8 @@ begin:
|
||||
//if (glyph == NULL)
|
||||
// continue;
|
||||
|
||||
if (prev_c && KerningFn)
|
||||
x += KerningFn(this, prev_c, (ImWchar)c, size, KerningUserData);
|
||||
float char_width = glyph->AdvanceX * scale;
|
||||
if (glyph->Visible)
|
||||
{
|
||||
@ -7503,6 +7514,7 @@ begin:
|
||||
if (y1 >= y2)
|
||||
{
|
||||
x += char_width;
|
||||
prev_c = (ImWchar)c;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -7525,6 +7537,7 @@ begin:
|
||||
}
|
||||
}
|
||||
x += char_width;
|
||||
prev_c = (ImWchar)c;
|
||||
}
|
||||
|
||||
// Edge case: calling RenderText() with unloaded glyphs triggering texture change. It doesn't happen via ImGui:: calls because CalcTextSize() is always used.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user