Friday, December 21, 2007

A Tale of Java, Ubuntu and Fonts

As a part of an ongoing Java project, I had designed a rudimentary Java text editor. The project is a WIP, so every so-many-months I put my minds on it only to stray away in a few days. Last time I worked on the editor part of it, I was running Fedora core with Java 1.4, maybe 1.5. The code loads a non-English font into the editor and then you can see those fonts as you type. The font is ttf font which was loaded as System fonts in /usr/share/fonts directory with the updated font-cache. It worked just fine, loading and showing this font (the name, BTW, is itxBeng. It's a Benagli font) without any glitch.

A couple of weeks back, I opened up the code on my Ubuntu 7.04 with Java 1.5. And surprise, surprise!! When I am supposed to see Bengali characters, I now see gibberish. My first reaction was that I might have changed some code and forgot about it. I told you, I haven't touched this code in a while. So I looked at the font-loading code, but did not find any problem or resolution. I was furiously scratching my head. No clue, what's happening!?

Next day I ran the code on my office computer, which is running CentOS 4 (basically repackaged Redhat distribution) and Java 1.5. To my not-so-big-surprise, the fonts loaded just fine. So I narrowed down the issue to Ubuntu problem. So next I installed Java 1.6 on my Ubuntu machine. This time the fonts loaded fine. I haven't played extensively after that, so don't know if there are other problems. But the most intriguing problem is gone, or at least I ahve found a work-around.

Bottom line: Ubuntu 7.04, Java 1.5 and ttf fonts manually loaded in system do not play well.

No comments:

Post a Comment