在Swing中使用乌尔都语字体输入文本时不显示英文字符 [英] English characters don't show up when entering text with Urdu fonts in Swing

查看:191
本文介绍了在Swing中使用乌尔都语字体输入文本时不显示英文字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这类似于我自己以前的问题,但是这个解决方案在这里不起作用。
正如上一个问题所提到的,我正在开发一个跨平台(Windows / Ubuntu)的应用程序,该应用程序必须将英语音译为几种印度语官方语言之一。该应用程序有一个自定义的输入法,输入英文和按空格键将输入的文本转换成特定的本地语言。乌尔都语不同于其他人,如阿拉伯语/希伯来语。
我设法找到开放许可的乌尔都语字体有英文和乌尔都语字形,但是当我用英文输入字符时,什么也没有显示出来。

我不明白这是字体绘画的问题,还是与输入法有关。到目前为止,如果我禁用这种语言的自定义输入法( InputMethod.dispatchEvent()),我可以看到英文文本(但当然没有音译发生)。



我的发现: b
$ b


  • 其中一个使用阿拉伯语字体构建的Windows,结果相同。
  • 使用 ComponentOrientation 来对齐文本字段中的文本,当语言环境是乌尔都语时, setHorizo​​ntalAlignment 。同样的结果。
  • 在Windows上反编译JDK的默认输入法提供程序( sun.awt.windows.WInputMethod )。在这里我看到 dispatchEvent()调用操作系统的本地调用来处理IME。我不能这样做。

  • 找到希伯来语自定义IM - 我的版本 dispatchEvent()基本上是一样的。

  • 在Eclipse中遍历 JTextField 的代码 - 无法在 AbstractDocument 和子类中找到任何东西。 AbstractDocument.insertUpdate()方法检查并更新双向文本输入,但是没有其他任何重要的东西。


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



解决方法



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

有人能指点我吗?

解决方案


我将语言环境设置为 ur_IN


ur_IN 不在支持的语言环境;我只看到 en_IN hi_IN 。在引用的示例中,我使用下面的代码来获取如下图:

pre $ spinner.setLocale(new locale(hi,IN));


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 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.

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"));

这篇关于在Swing中使用乌尔都语字体输入文本时不显示英文字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆