开发者

How to programmatically set up fallback font in Java?

I wanted to localize my app to my Tamil language. I was disappointed that Java supports only Hindi out of all Indian Languages "out of the box."

I searched the internet for some workaround. I learnt from John O'Conner's blog post and Naotoj Sato's blog post that I've to use a technique called "Font Fallback."

I manually copied the "LATHA.TTF" Tamil font available for Windows to /jre/lib/fonts/fallback directory.

It worked! But how can I copy the font programmatically to my users' /jre/lib/fonts/fallback directory?

I thought to add a code that will copy the included font to that fallback directory during the first launch and if it is not already there. Will it cause any permission problems like "Write access denied" to that folder or something?

Or is there a way to make the app search for the fallback font to application directory instead of /jre/lib/fonts/fallback?

Note that the app will have to use this LATHA font only when Tamil language is sele开发者_如何学运维cted and default font for all other languages.

Please give your opinions.


There seems to be no way to programmatically copy the fallback font to jre if it is in system location without admin rights. It works only if the jre is in some other location. So I have finally decided to put a readme file asking users to copy the font manually if they want it. Expecting Java to support Tamil by default soon.

Hope this will be useful for anyone searching for something like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜