-
-
Notifications
You must be signed in to change notification settings - Fork 873
desktop: Add basic support for RTL scripts in GUI #20265
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
base: master
Are you sure you want to change the base?
Conversation
This refactors moves locale-related code away from generic GUI-related code into a separate file.
Given that RTL support in egui is closer than ever with emilk/egui#5784, I'm not sure this hack is worth it still - but of course I can't tell the future of that PR either... |
I'm not sure if it's a hack, as something like that is done normally but on a different level. (But here, e.g. text selection will not work properly.) But IMO this workaround is so simple and so loosely coupled to the existing code that we might as well do it instead of waiting for several months for RTL support in egui. Removing it will be very easy in the future. |
https://github.com/emilk/egui/blob/ba67ccc81eabe156dc0519e54571592f64d0bc20/parley-todo.md is also still somewhat of a long list. |
fn mirror_char(c: char) -> char { | ||
match c { | ||
'(' => ')', | ||
')' => '(', | ||
'[' => ']', | ||
']' => '[', | ||
'{' => '}', | ||
'}' => '{', | ||
'<' => '>', | ||
'>' => '<', | ||
_ => c, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's worth adding another dependency, as the set of strings we mirror is finite (we do that only for translated strings), but I'll add it if you think it's better :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, either way is fine for me.
This patch implements a workaround for egui not supporting RTL scripts. RTL text runs are being reversed and some characters are being mirrored.
This patch implements a workaround for egui not supporting RTL scripts. RTL text runs are being reversed and some characters are being mirrored.
It does not fix the interface being LTR though, and I assume ligatures also won't be drawn properly. But at least RTL text is readable now. Also text selection will not work properly (text will be reversed), and user-inputted text will not be fixed.