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

Correct on-screen keyboard behaviour for Arabic characters #17692

Merged
merged 2 commits into from
Apr 23, 2020
Merged

Correct on-screen keyboard behaviour for Arabic characters #17692

merged 2 commits into from
Apr 23, 2020

Conversation

AhmedAdelAbouzeid
Copy link
Contributor

Description of changes and context

1- Prevent Arabic characters from being dis-joined when using the on-screen keyboard
2- Prevent the flipping of existing Arabic text when editing (ex. renaming something) using the on-screen keyboard

Both the above points are cleared by turning off character flipping in calls to utf8ToW charset conversion function for ACTION_INPUT_TEXT and GUI_MSG_SET_TEXT (SetLabel2 function)

This fixes #16040

How Has This Been Tested?

The changes were tested using Kodi on Windows 10 x64 (1909)
The on-screen keyboard was tested using a RTL language (Arabic) and a LTR language (English) and behave correctly for both languages after the changes. Kodi's interface language was alternated between Arabic and English during the test and didn't affect the results.

Screenshots

kodi_KB_AR_Issue

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@AhmedAdelAbouzeid AhmedAdelAbouzeid changed the title Fixes #16040; Correct on-screen keyboard behaviour for Arabic characters Correct on-screen keyboard behaviour for Arabic characters Apr 17, 2020
@phunkyfish phunkyfish added Type: Fix non-breaking change which fixes an issue v19 Matrix labels Apr 18, 2020
Copy link
Contributor

@phunkyfish phunkyfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhmedAdelAbouzeid can you please prefix the commit message with what the change does. I.e. a speaking description.

Other than that it looks good to me, will also ask one of the skin guys.

@phunkyfish phunkyfish requested a review from ronie April 18, 2020 22:27
@phunkyfish
Copy link
Contributor

@ronie this looks reasonable.

@ronie
Copy link
Member

ronie commented Apr 19, 2020

screenshots look nice, but i have no idea what the code changes do.
this is far out of my league :-)

@phunkyfish
Copy link
Contributor

screenshots look nice, but i have no idea what the code changes do.
this is far out of my league :-)

No worries, thanks for taking a look.

@phunkyfish
Copy link
Contributor

@MilhouseVH can we put this in a testbuild and see if any side effects are reported?

@MilhouseVH
Copy link
Contributor

Will do, should be in tonight's #0419 build.

1- Prevent arabic characters from being disjoined when using the on-screen keyboard. Fixes #16040
2- Prevent the flipping of existing arabic text when editing (ex. renaming something) using the on-screen keyboard
@AhmedAdelAbouzeid
Copy link
Contributor Author

Thanks for reviewing. I changed the commit message's title.

The code changes are limited to the edit control and only affect RTL languages. The changes ultimately bypass calls to FriBiDi which doesn't do anything to LTR languages anyway unless they are mixed with RTL languages in the same line.

I will test these cases (mixed RTL/LTR) and text including numerical values and signs later today.

@phunkyfish phunkyfish added this to the Matrix 19.0-alpha 1 milestone Apr 20, 2020
@phunkyfish
Copy link
Contributor

Thanks @AhmedAdelAbouzeid

@AhmedAdelAbouzeid
Copy link
Contributor Author

I tested the keyboard with mixed RTL/LTR languages, numbers and signs and found no issues with characters getting separated nor reversed.

While testing I noticed that if the cursor is placed in the middle of an Arabic word, the characters to the left of the cursor are moved to the start of the word while the cursor is in its hidden state and then the characters return to their correct position again when the cursor is visible. This is easily fixed by modifying the character used to indicate the hidden cursor state to a simple space or null character.

Is it OK to add a commit for this to the pull request ?
Kodi_KB_AR_CR

@phunkyfish
Copy link
Contributor

Yes of course. Please add the commit.

@AhmedAdelAbouzeid
Copy link
Contributor Author

I will work on adjusting the arrow buttons as the cursor movement inside RTL text is reversed (clicking the left arrow moves the cursor right and vice versa). The code for the buttons' actions currently manipulate the cursor index without checking the text direction first.
The Arabic keyboard is fairly usable now though, I hope other changes can be done in a new PR.

@phunkyfish
Copy link
Contributor

Yes, i think other changes in a new PR is fine.

Let's just check with @MilhouseVH if there is any feedback on this PR. Otherwise we can push it in.

@@ -565,7 +565,7 @@ bool CGUIEditControl::SetStyledText(const std::wstring &text)
// show the cursor
unsigned int ch = L'|';
if ((++m_cursorBlink % 64) > 32)
ch |= (3 << 16);
ch = L' ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the blinking effect, the cursor will alternate between '|' and ' ' (simple space - 0x20) instead of between '|' and '𰁼' (It does look like a space in some fonts - 0x3007C)

The '𰁼' while looking like a space (or a double space), seem to reverse Arabic words around it even in word processors (If the paragraph direction is LTR).

Space VS 0x3007C

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks. Your explanation makes sense.

Although I’m not sure I understand why that was chosen for the original code! A mystery.

@MilhouseVH
Copy link
Contributor

No feedback so far (none good, none bad). All I can say with any certainty is that it doesn't appear to have broken anything!

@phunkyfish
Copy link
Contributor

That will do, thanks!

Copy link
Contributor

@phunkyfish phunkyfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@phunkyfish
Copy link
Contributor

Thanks @AhmedAdelAbouzeid for the contribution!

@phunkyfish phunkyfish merged commit 0fcc312 into xbmc:master Apr 23, 2020
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Apr 23, 2020
Correct on-screen keyboard behaviour for Arabic characters
@phunkyfish
Copy link
Contributor

@AhmedAdelAbouzeid

I think I found out why that special character was used for a space. Without it if you change a text setting the text will move left/right on each blink.

Is it possible to only use a real space for arabic and similar languages and use the old character otherwise?

@AhmedAdelAbouzeid
Copy link
Contributor Author

This is because the character width for ' ' and '|' may be different depending on the used font; for Arial they have the same width but this is not the case for the default font.
Using a figure space (U+2007) instead of basic space eliminates text movement for the default font but causes movement when using Arial.

I will work at solving this hopefully without going for language-specific nor font-specific solutions.

@phunkyfish
Copy link
Contributor

phunkyfish commented Apr 29, 2020

Amazing, thanks!

FYI @AlwinEsch

@AhmedAdelAbouzeid
Copy link
Contributor Author

PR #17790 solves the above issue, please check it. Thanks!

Maven85 pushed a commit to Maven85/kodi that referenced this pull request May 5, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 3, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 4, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 4, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 5, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 5, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
Correct on-screen keyboard behaviour for Arabic characters
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 7, 2020
Correct on-screen keyboard behaviour for Arabic characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arabic letters not connected when using virtual keyboard
4 participants