在Swing中使用印度语输入法输入文本时不会显示英文字符 [英] English characters don't show up when entering text with Indic input method in Swing

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

问题描述

我正在研究接受英文文本的应用程序,并使用自定义的第三方API执行音译(印度语支持的其中一种)。该应用程序针对Windows XP / 7和Ubuntu。
我们使用自定义的输入方法,加载所需的印度语字体,并使用它呈现文本。此外,用户可以通过输入英文和按空格来更正音译文本(类似于Google Transliterate的工作方式)。



问题在于,对于某些印度语字体,键入用英文显示空框字符(即使输入的实际字符被相应地检测和音译)。

我使用了Ubuntu附带的ttf-indic-fonts-0.5.0字体包,并且能够替换其中的一些。对于其他人,如果我从Windows复制相应的字体(我在Windows 7上开发这个),那么所有的问题都解决了。

然而,我们不能重新分配Windows字体与我们的应用程序,并希望一个开放的替代品。

除了试图找到一个替代字体,还有什么我们做错了,或需要检查,以请确保在使用印度字体时可以在JTextField中键入英文字符?



例如,从上面提到的Ubuntu软件包中,lohit_pa.ttf字体对于旁遮普有这个问题。如果我复制旁遮普语(raavi.ttf)的默认Windows字体,那么它工作正常。

解决方案

我找到了解决方案问题。我在Windows上安装了字体(打开字体,单击安装),并使用字符映射浏览内容。这些字体只有用于所述语言的字形,而不是英语。
我用 FontForge 合并了2种字体。 (Fontforge的作者不再提供二进制文件 - 但是如果你有权访问Ubuntu,你可以从存储库安装它,如果你只有Windows,没有这样的运气)。
在此之后,我可以再次输入英文。


I'm working on an application that accepts text in English and performs transliteration with a custom 3rd party API into an Indic language (one of several that are supported). The application is targeted at Windows XP/7 and Ubuntu. We use a custom input method that loads the required Indic font, and uses it render text. Also, the user can correct the transliterated text by typing in English and pressing space (similar to how Google Transliterate works).

The problem is that with certain Indic fonts, typing in English shows up empty box characters (even though the actual characters typed are detected and transliterated accordingly).

I have used the ttf-indic-fonts-0.5.0 font pack that comes with Ubuntu, and was able to substitute some of them. For the others, if I copy the corresponding font from Windows (I'm developing this on Windows 7) then all problems are solved.

However, we cannot redistribute Windows fonts with our application and want an open alternative.

Other than trying to find a substitute font, is there anything else that we're doing wrong, or need to check, to make sure that English characters can be typed in a JTextField when an Indic font is being used?

As an example - from the Ubuntu package mentioned above, the lohit_pa.ttf font for Punjabi has this problem. If I copy the default Windows font for Punjabi (raavi.ttf) then it works fine.

解决方案

I found a solution to the problem. I installed the fonts on Windows (open the font, click install) and browsed the contents using Character Map. These fonts only have glyphs for the language in question, not English. I used FontForge to merge the 2 fonts. (Fontforge's author doesn't provide binaries anymore - but if you have access to Ubuntu you can install it from the repository. No such luck if you only have Windows). After this, I'm able to type in English again.

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

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