Skip to content
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

InputText caret position is not rounded to the next integer #4080

Closed
elvissteinjr opened this issue Apr 27, 2021 · 1 comment
Closed

InputText caret position is not rounded to the next integer #4080

elvissteinjr opened this issue Apr 27, 2021 · 1 comment

Comments

@elvissteinjr
Copy link

Version/Branch of Dear ImGui:

Version: 1.82
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler: MSVC19
Operating System: Windows 10

My Issue/Question:

This is overall really, really minor. But now that I've noticed it, it does bug me a little bit.
As the issue title suggests, the caret position in InputText widgets may end up with a non-integer value depending on character widths, causing the caret to appear blurry.
I think the y-coordinate is not affected by this. At least I haven't been able to get it to be an issue on that axis. Only on the x-axis.

The fix for this isn't really dramatic and Dear ImGui does seem to round coordinates in many places, so I believe it would be reasonable to have the same for the caret.
Typing this up I realized this may even be intentional when navigating between characters. In that case I'd still think it would be nice to at least have it rounded when the caret's at the end of the text.

But yeah, very minor thing. Thanks for your time here.

Screenshots/Video

caret

Standalone, minimal, complete and verifiable example:

This can be observed in the demo code with a font resulting in non-integer character widths loaded.
In my case I've loaded Segoe UI ("segoeui.ttf") straight from the Windows font folder at 32.0f size.
Font loader is the default stb_truetype.

@ocornut
Copy link
Owner

ocornut commented Apr 27, 2021

Thank you @elvissteinjr for the report.
Applied the fix 2dec7b3

@ocornut ocornut closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants