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

Support for rtl text, and right-to-left languages #1228

Closed
traverseda opened this issue Jul 13, 2017 · 6 comments
Closed

Support for rtl text, and right-to-left languages #1228

traverseda opened this issue Jul 13, 2017 · 6 comments

Comments

@traverseda
Copy link

traverseda commented Jul 13, 2017

Or google-able documentation of same.

@ocornut
Copy link
Owner

ocornut commented Jul 14, 2017

Hello Alex,
Sorry, RTL isn't supported and I don't plan to support it as it would largely increase cpu cost (which is a highly desirable property to maintain for what imgui is designed for), as well as increasing maintenance cost (things like bi-di text or proper text shaping are not easy to get right). It's not really the expected use case of dear imgui to support all international languages.

@traverseda
Copy link
Author

That's too bad, as it limits the inclusion in more serious tools. As an example, solvespace, which is having to choose between

  • Their own homegrown immediate-mode gui
  • OS specific widget toolkits

and

  • ImGui

I'm advocating for ImGui, since portability is one of their big goals and I think OS specific UI toolkits are going to suck. But they're big on accessibility and internationalization, trying to make a good, easy to use, open source CAD.

Done right, this should save them a bunch of time, time that they can focus on making their project good.

So the big questions are

  • Are there any hacks what would allow limited support for RTL languages for the time being?

  • Would you accept pull requests for optional RTL support? Say, harfBuzz enabled text widgets?

@ocornut
Copy link
Owner

ocornut commented Jul 15, 2017

Are there any hacks what would allow limited support for RTL languages for the time being?

Probably/perhaps, if you are willing to dig into the font/text code, but I expect going from the quickly hacked version to the full internationally compliant version would be rather hard. If you are thinking Arabic for example, it's not just right-to-left (which would be the simple part), but things like bi-directional support and text shaping would be required.

Would you accept pull requests for optional RTL support? Say, harfBuzz enabled text widgets?

Definitively not on Master (because Harfbuzz is a non-trivial complex dependency).
In a branch in theory yes, in practice probably not unless you would be serious about using and maintaining it. It's really not in the DNA of dear imgui to go toward that direction. And I suspect it wouldn't be an easy patch: I don't think harfbuzz was designed for the IMGUI use case and you may need to introduce some extra layer of caching (keyed by e.g. text + render width/pos) because shaping text every frame will be costly.

I realize it's frustrating, but dear imgui is a small library developed mostly on my spare time with limited resources, and even if that sort of feature was easily reachable (which it isn't) I would maybe argue it isn't in the library or my interest to try being a replacement for e.g. QT because I don't have the resources to stretch it to satisfy everyone's needs.

@bluebear94
Copy link

Yep, maybe if someone has time to implement that, it could be included in imgui_club.

@ocornut
Copy link
Owner

ocornut commented Sep 6, 2017

Closing this as dropped.

Yep, maybe if someone has time to implement that, it could be included in imgui_club.

It'll most probably have to be a core element.
I think in practice there are a too many things to change and fix to make this doable - and it's quite outside the scope and typical use case of dear imgui to make it worth it. If anyone wants to try hacking something by all mean for go it.

@mwindowshz
Copy link

mwindowshz commented Oct 13, 2024

Hello Alex, Sorry, RTL isn't supported and I don't plan to support it as it would largely increase cpu cost (which is a highly desirable property to maintain for what imgui is designed for), as well as increasing maintenance cost (things like bi-di text or proper text shaping are not easy to get right). It's not really the expected use case of dear imgui to support all international languages.

it is possible to use hebrew and RTL with these steps
load font with the glyphs range to support the RTL language letters

then when calling ImGui.Text()
reverse the text and handle utf8 byte size changes

I did not test this on text input

see my example
https://github.com/mwindowshz/imgui_base/blob/main/imgui_add_hebrew.cpp
maybe you can add this to IMGUI source code by creating a set of glyph and using a reverse function

thanks to @harelw
for the support

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

4 participants