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.
我不明白这是字体绘制问题,还是与输入法有关。到目前为止,如果我禁用该语言的自定义输入法(InputMethod.dispatchEvent()
),我就可以看到英文文本(但当然不会进行音译)。
我的发现:
- 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.
我无法理解dispatchEvent()
调用后会发生什么。字符正在被注册,即音译引擎能够检测并处理键入的字符,但它们不会显示在屏幕上。
解决方案
如果我让文本字段的方向和常规的从左到右语言一样,我可以看到英文文本。然而,这对于讲乌尔都语的用户来说是不可接受的。
有人能给我指正确的方向吗?