-
Notifications
You must be signed in to change notification settings - Fork 199
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 Unicode Bidi-algorithm #2982
Comments
Actually hooking in ICU BIDI isn't that hard. Quick proof of concept: Before: After: UErrorCode errorCode = U_ZERO_ERROR;
UBiDi *bidi = ubidi_open();
// Set the input text and specify its direction
auto input = icu_75::UnicodeString::fromUTF32(reinterpret_cast<const UChar32*>(tx.data()), tx.length());
ubidi_setPara(bidi, input.getBuffer(), -1, UBIDI_DEFAULT_LTR, NULL, &errorCode);
// Get the visual order of the characters
int32_t length = ubidi_getProcessedLength(bidi);
UChar *output = (UChar *)malloc(sizeof(UChar) * (length + 1));
auto outlen = ubidi_writeReordered(bidi, output, length + 1, UBIDI_DO_MIRRORING, &errorCode);
icu_75::UnicodeString us(output, outlen);
std::string s;
us.toUTF8String(s);
std::u32string txt = Utils::DecodeUTF32(s);
free(output);
ubidi_close(bidi); |
there is one more complex problem: When a message contains any command codes or ExFont it will have the same "reverse rendering" issue as the help text. That must be rewritten to shape the entire line in one go and just assign "attributes" like the color to the individual glyphs. Instead of shaping and rendering everytime a command code is encountered. |
Glad that all the Harfbuzz shaping stuff was already implemented over multiple weeks. This made the Bidi implementation pretty straightforward (only needed one day) Here a message box with bidirectional text. Each text segment flows in based on its direction (is slowed down to show this better, normal message box is much faster). simplescreenrecorder-2024-07-08_22.10.18.mp4Command codes work but I havn't fully tested them yet. @MAZ12211 was so kind to give me a Yume Nikki translation in "the proper way" (how you would type it when the application has proper RTL-Bidi-Support). Here the current progress (the width calculation is still a bit bugged as you can see from the inconsistent right alignment). |
Pushed the current (incomplete) code here: https://github.com/Ghabry/easyrpg-player/tree/bidi |
I just tested the bidi build with Toilet In Wonderland and Ib and both ended up crashing the Player explorer_8JOtxATMi2.mp4 |
Actually the dump file doesn't help because I do not have access right now to the computer where I compiled it 😅. Currently easier is when you provide me with the translation files that crash. |
Lol alright |
Fix the display of the Hebrew translation, by adding a font, and rewriting how the text is displayed. Change the name of the language on the menu to Hebrew due to not being able to be displayed until being selected if the language was written in its original language, and remove useless files. Adjust the spacing of some lines to be centered. While this will work for some time, due to a lack of Bidi-algorithm in the EasyRPG Player at the moment (EasyRPG/Player#2982), every description in the RPG_RT.ldb.po file (+ save, load, quit lines) will have to be edited another time due to the . character altering how the text is written + how descriptions are handled, so I had to edit lines to take into account this. Fix to do for the future once said algorithm is supported: take the RPG_RT.ldb.po version of this translation prior to this pull request, take all of the lines of text, and revert the text without having to deal with manually adjusting the text.
Text can be mixed direction like e.g. mixing Hebrew and English or numbers:
שדחHallo קח42שמ
Player does not apply bidi here as Harfbuzz does not support such mixed-bidi:
The text was updated successfully, but these errors were encountered: