`TextWrapped` looks bad with decimal numbers due to hardcoded separators
Version/Branch of Dear ImGui:
1.91.9b
Back-ends:
Custom VRSFML (SFML Fork) + OpenGL ES 3.x Backend
Compiler, OS:
Windows 11 + MSYS2/UCRT64
Full config/build information:
No response
Details:
When using ImGui::TextWrapped to render text containing decimal numbers, the . character used to separate the integral part from the decimal part is considered as a wrap point, causing the end result to look quite bad as the number can be split across multiple lines.
The same issue occurs with the , character. The only workaround I've found is using the ' character, which looks quite weird, but at least it makes the numbers legible.
A probably-reasonable "fix" would be for the wrapping function to avoid wrapping . and , if both the preceding and succeeding characters are digits.
Screenshots/Video:
Screenshots from my game BubbleByte:
Minimal, Complete and Verifiable Example code:
No response
As an example, this addition to ImFont::CalcWordWrapPositionA solves my problem:
const auto isDigit = [](unsigned int c) { return c >= '0' && c <= '9'; };
if (c == '.' && s+1 < text_end && isDigit(*(s + 1)))
inside_word = true;
Linking to #8439 #8139 for text wrapping code.
My problem is that text size calculation is generally very hot path (admittedly wrapped text not as frequent).
I've got another version of the code for the new text function, I might be tempted to backport it, and then as those two new cases in Test Suite and come up with a fix.