(Breaking) Fonts: CalcWordWrapPositionA() -> CalcWordWrapPosition(), takes size instead of scale.
This will be needed for upcoming changes.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index f620796..f45fa17 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -43,6 +43,12 @@
- TreeNode: renamed ImGuiTreeNodeFlags_NavLeftJumpsBackHere to ImGuiTreeNodeFlags_NavLeftJumpsToParent
for clarity. Kept inline redirection enum (will obsolete). (#1079, #8639)
+- Fonts: changed ImFont::CalcWordWrapPositionA() to ImFont::CalcWordWrapPosition():
+ - old: const char* CalcWordWrapPositionA(float scale, const char* text, ....);
+ - new: const char* CalcWordWrapPosition (float size, const char* text, ....);
+ The leading 'float scale' parameters was changed to 'float size'.
+ This was necessary as 'scale' is assuming standard font size which is a concept we aim to
+ eliminate in an upcoming update. Kept inline redirection function.
- Commented out PushAllowKeyboardFocus()/PopAllowKeyboardFocus() which was obsoleted
in 1.89.4 (March 2023). (#3092)
- PushAllowKeyboardFocus(bool tab_stop) --> PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop);
@@ -51,7 +57,7 @@
in 1.89.6 (June 2023).
- ForceDisplayRangeByIndices() --> IncludeItemsByIndex()
- Backends: SDL3: Fixed casing typo in function name: (#8509, #8163, #7998, #7988) [@puugz]
- - Imgui_ImplSDLGPU3_PrepareDrawData() -> ImGui_ImplSDLGPU3_PrepareDrawData()
+ - Imgui_ImplSDLGPU3_PrepareDrawData() --> ImGui_ImplSDLGPU3_PrepareDrawData()
- Internals: RenderTextEllipsis() function removed the 'float clip_max_x' parameter directly
preceding 'float ellipsis_max_x'. Values were identical for a vast majority of users. (#8387)
@@ -109,7 +115,7 @@
- Fonts: reworked text ellipsis logic to ensure a "..." is always displayed instead
of a single character. (#7024)
- Fonts: word-wrapping code handle ideographic comma & full stop (U+3001, U+3002). (#8540)
-- Fonts: fixed CalcWordWrapPositionA() fallback when width is too small to wrap:
+- Fonts: fixed CalcWordWrapPosition() fallback when width is too small to wrap:
would use a +1 offset instead of advancing to the next UTF-8 codepoint. (#8540)
- Style, InputText: added ImGuiCol_InputTextCursor to configure color of
the InputText cursor/caret. (#7031)
diff --git a/imgui.cpp b/imgui.cpp
index 16632d8..30263ba 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -431,6 +431,10 @@
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
+ - 2025/05/23 (1.92.0) - Fonts: changed ImFont::CalcWordWrapPositionA() to ImFont::CalcWordWrapPosition()
+ - old: const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, ....);
+ - new: const char* ImFont::CalcWordWrapPosition (float size, const char* text, ....);
+ The leading 'float scale' parameters was changed to 'float size'. This was necessary as 'scale' is assuming standard font size which is a concept we aim to eliminate in an upcoming update. Kept inline redirection function.
- 2025/05/15 (1.92.0) - TreeNode: renamed ImGuiTreeNodeFlags_NavLeftJumpsBackHere to ImGuiTreeNodeFlags_NavLeftJumpsToParent for clarity. Kept inline redirection enum (will obsolete).
- 2025/05/15 (1.92.0) - Commented out PushAllowKeyboardFocus()/PopAllowKeyboardFocus() which was obsoleted in 1.89.4. Use PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop)/PopItemFlag() instead. (#3092)
- 2025/05/15 (1.92.0) - Commented out ImGuiListClipper::ForceDisplayRangeByIndices() which was obsoleted in 1.89.6. Use ImGuiListClipper::IncludeItemsByIndex() instead.
diff --git a/imgui.h b/imgui.h
index f4b692a..8e0e09b 100644
--- a/imgui.h
+++ b/imgui.h
@@ -29,7 +29,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.92.0 WIP"
-#define IMGUI_VERSION_NUM 19196
+#define IMGUI_VERSION_NUM 19197
#define IMGUI_HAS_TABLE
/*
@@ -3533,10 +3533,14 @@
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL); // utf8
- IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width);
+ IMGUI_API const char* CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width);
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip = NULL);
IMGUI_API void RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false);
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) { return CalcWordWrapPosition(FontSize * scale, text, text_end, wrap_width); }
+#endif
+
// [Internal] Don't use!
IMGUI_API void BuildLookupTable();
IMGUI_API void ClearOutputData();
diff --git a/imgui_draw.cpp b/imgui_draw.cpp
index dbc659d..78b0e15 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -3936,7 +3936,7 @@
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
// This will return the next location to wrap from. If no wrapping if necessary, this will fast-forward to e.g. text_end.
// FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
-const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width)
+const char* ImFont::CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width)
{
// For references, possible wrap point marked with ^
// "aaa bbb, ccc,ddd. eee fff. ggg!"
@@ -3952,6 +3952,7 @@
float line_width = 0.0f;
float word_width = 0.0f;
float blank_width = 0.0f;
+ const float scale = size / FontSize;
wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters
const char* word_end = text;
@@ -4055,7 +4056,7 @@
{
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
if (!word_wrap_eol)
- word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width);
+ word_wrap_eol = CalcWordWrapPosition(size, s, text_end, wrap_width - line_width);
if (s >= word_wrap_eol)
{
@@ -4175,10 +4176,10 @@
const char* line_end = (const char*)ImMemchr(s, '\n', text_end - s);
if (word_wrap_enabled)
{
- // FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPositionA().
- // If the specs for CalcWordWrapPositionA() were reworked to optionally return on \n we could combine both.
+ // FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPosition().
+ // If the specs for CalcWordWrapPosition() were reworked to optionally return on \n we could combine both.
// However it is still better than nothing performing the fast-forward!
- s = CalcWordWrapPositionA(scale, s, line_end ? line_end : text_end, wrap_width);
+ s = CalcWordWrapPosition(size, s, line_end ? line_end : text_end, wrap_width);
s = CalcWordWrapNextLineStartA(s, text_end);
}
else
@@ -4223,7 +4224,7 @@
{
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
if (!word_wrap_eol)
- word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - origin_x));
+ word_wrap_eol = CalcWordWrapPosition(size, s, text_end, wrap_width - (x - origin_x));
if (s >= word_wrap_eol)
{