English characters are not displayed when entering text with Urdu fonts in Swing

This is similar to my own previous question , but this solution does not work here. As mentioned in the previous question, I am working on a cross platform (Windows / Ubuntu) which is supposed to transliterate English into one of several official Indian languages. The application has its own input method, and entering English text and pressing the space bar transliterate the entered text into a specific local language. Urdu differs from others in the right to be left, like Arabic / Hebrew. I managed to find an open licensed Urdu font that has both glyphs in English and Urdu, but when I type characters in English, nothing appears.

I don’t understand whether the problem is with the font or with the input method. So far, if I disable the user input method ( InputMethod.dispatchEvent() ) for this language, I can see the text in English (but, of course, transliteration does not occur).

My results:

  • Changing the font to one of the built-in Arabic Windows fonts is the same result.
  • Instead of using ComponentOrientation to align text in a text box, I used setHorizontalAlignment when the language is Urdu. The same result.
  • Decompiled the default JDK input method provider on Windows ( sun.awt.windows.WInputMethod ). Here I see that dispatchEvent() makes its own OS call to handle IME. I can not do it.
  • Found a custom IM for Hebrew - my version of dispatchEvent() is essentially the same.
  • Executed code for JTextField in Eclipse - could not find anything in AbstractDocument and subclasses. The AbstractDocument.insertUpdate() method checks and updates bidirectional text input, but there was nothing significant.

I cannot understand what happens after dispatchEvent() called. Characters are registered, that is, the transliteration mechanism is able to detect the entered characters and process them, but they simply do not appear on the screen.

Bypass

If I set the orientation of the text field in the same way as for ordinary languages ​​from left to right, I can see the text in English. However, this is not acceptable for a user speaking Urdu.

Can someone point me in the right direction?

+2
source share
1 answer

I set the locale ur_IN .

Unfortunately, ur_IN does not apply to supported locales ; I see only en_IN and hi_IN . In the example below, I used the following code to get the image below:

 spinner.setLocale(new Locale("hi", "IN")); 

JSpinnerTest Hindi

+2
source

Source: https://habr.com/ru/post/1383720/


All Articles