English characters don't show up when entering text with Urdu fonts in Swing
This is similar to my own previous question, but that solution didn't work here. As mentioned in the previous question, I'm working on a cross platform(Windows/Ubuntu) application that has to transliterate English into one of several official Indian languages. The application has a custom input method, and typing in English and pressing space will transliterate the typed text into the specific local language. Urdu is different from the others in being right to left, like Arabic/Hebrew. I managed to find an open licensed Urdu font that has both English and Urdu glyphs, but when I type characters in English, nothing shows up.
I don't understand whether it's a font painting issue, or related to the input method. So far, if I disable the custom input method (InputMethod.dispatchEvent()
) for this language, I am able to see the English text (but of course no transliteration takes place).
My findings:
- Change font to one of Windows' built in Arabic fonts - same result.
- Instead of using
ComponentOrientation
to align text in the text field, I usedsetHorizontalAlignment
for when the locale is Urdu. Same result. - Decompiled the JDK's default input method provider on Windows (
sun.awt.windows.WInputMethod
). Here I see thedispatchEvent()
makes a native call to the OS for handling IME. I can't do that here. - Found a custom IM for Hebrew - my 开发者_运维技巧version of
dispatchEvent()
is essentially the same. - Stepped through code for
JTextField
in Eclipse - wasn't able to find anything in theAbstractDocument
and subclasses. TheAbstractDocument.insertUpdate()
method checks for and updates bidirectional text input, but there wasn't anything else significant.
I'm unable to understand what happens after the dispatchEvent()
call. The characters are being registered, i.e. the transliteration engine is able to detect the typed characters and process them, but they just don't show up on screen.
Workaround
If I let the text field's orientation be as it is for regular left to right languages, I can see the English text. However, this would not be acceptable to an Urdu speaking user.
Can someone point me in the right direction?
I set the locale to
ur_IN
.
Sadly, ur_IN
is not among the supported locales; I only see en_IN
and hi_IN
. In the example cited, I used the following code to get the image below:
spinner.setLocale(new Locale("hi", "IN"));
精彩评论