-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in text width calculation? #792
Comments
I believe this is worth a flag in CalcTextSize, because both behaviors are correct, just doing different things (calculate size of a text fragment within a string vs. calculate size of a displayed text string) |
If I understand you correctly fixed-width font is not rendered like
but contains spacing between them
In which case rendering string as a whole and symbol by symbol would cause different results. If this is true, how is developer supposed to pad strings when working with fixed-width font? Copying padding and rendered string into a buffer is not an option for me (would make rendering functions way too complicated). |
…m erroneously subtracting 1.0f*scale to calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls not align the same as a single call, and create mismatch between high-level size calculation and those performed with the lower-level ImDrawList api. (#792)
Hello, You'll find it amusing but I have finally fixed this! Better late than never. I'll removed the subtraction now. Thanks and sorry for taking so long to tackle this! Omar |
I assume that text rendered as a whole (i.e. by calling
ImGui::TextUnformatted("text")
) and symbol by symbol like this:should give the same result. However,
ImGui::CalcTextSize
does some substraction that does not seem to be right.This demonstration is copied from opengl_example. It contains two functions to output text: as a whole and symbol by symbol. They give different results. First string is rendered as a whole and second string is rencder symbol by symbol.
However, if we change
ImGui::CalcTextSize
like this:two functions render the same result:
Tested on Ubuntu 16.04 64 bit.
The text was updated successfully, but these errors were encountered: