如何在Java中以编程方式设置后备字体?
我想将我的应用程序本地化为泰米尔语。我很失望 Java 在所有印度语言中仅支持印地语 “开箱即用。”
我在互联网上搜索了一些解决方法。我从 John O'Conner 的博客文章 和 < a href="http://blogs.oracle.com/naotoj/entry/more_than_300_locales_in" rel="nofollow">Naotoj Sato 的博客文章我必须使用一种称为“字体回退”的技术。
我手动将 Windows 可用的“LATHA.TTF”泰米尔字体复制到 /jre/lib/fonts/fallback 目录。
成功了!但是如何以编程方式将字体复制到用户的 /jre/lib/fonts/fallback 目录?
我想添加一个代码,在第一次启动期间将包含的字体复制到该后备目录(如果它尚不存在)。它会导致任何权限问题,例如对该文件夹的“写入访问被拒绝”或其他问题吗?
或者有没有办法让应用程序搜索应用程序目录的后备字体而不是 /jre/lib/fonts/fallback?
请注意,仅当选择泰米尔语时,应用程序才必须使用此 LATHA 字体,并且所有其他语言都必须使用默认字体。
请大家发表意见。
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 selected and default font for all other languages.
Please give your opinions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果后备字体位于没有管理员权限的系统位置,则似乎无法以编程方式将后备字体复制到 jre。仅当 jre 位于其他位置时它才有效。所以我最终决定放置一个自述文件,要求用户如果需要的话手动复制字体。预计 Java 很快就会默认支持泰米尔语。
希望这对任何搜索此类内容的人都有用。
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.