English 中文(简体)
在Swing中使用乌尔都语字体输入文本时,不会显示英文字符
原标题: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.

我不明白这是字体绘制问题,还是与输入法有关。到目前为止,如果我禁用该语言的自定义输入法(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 used setHorizontalAlignment 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 the dispatchEvent() 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 the AbstractDocument and subclasses. The AbstractDocument.insertUpdate() method checks for and updates bidirectional text input, but there wasn t anything else significant.

我无法理解dispatchEvent()调用后会发生什么。字符正在被注册,即音译引擎能够检测并处理键入的字符,但它们不会显示在屏幕上。

解决方案

如果我让文本字段的方向和常规的从左到右语言一样,我可以看到英文文本。然而,这对于讲乌尔都语的用户来说是不可接受的。

有人能给我指正确的方向吗?

问题回答

我将区域设置为ur_IN

遗憾的是,ur_IN不在支持的区域设置;我只看到en_INhi_IN引用的例子,我使用以下代码获得了下面的图像:

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





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...