tags:

views:

225

answers:

1

Hi,

I have been trying to develop a simple J2ME application using LWUIT in Bengali language. However, because of heavy usage of vowels as conjuncted letters in Bengali language, I am facing some problems with LWUIT.

For example let us say, “X” is a consonant letter and “@” works as a vowel in Bengali; now they are combined together when needed becoming a conjuncted format “X@”. Using LWUIT, when I add such vowels and try to display them as the conjuncted format with a consonant in a real application, they are combined with their previous letter (which is in a consecutive order) as defined in the charset. Although interestingly, in the LWUIT designer display/preview, the characters appear correctly.

For details, kindly download this document here (http://dibbaa.com/lwuit/doc/lwuit.doc) and see the real-life examples.

I will appreciate if anybody can help me out on this. Just let me know how can I set LWUIT framework in such a way so that it doesn’t combine the letters as they defined in the charset by consecutive order while painting them. I have used LWUIT version 1.3 and font “KarnaphuliP.ttf” for my application.

Thanks

A: 

I know nothing about Bangali, and I cannot find the font you mentioned. But I managed to get an alternative font for recreating the problem:"Bengali-Progoty.TTF" (which, unfortunately, is not a bit similar to yours). You can get the font here:Bengali-Progoty.TTF.

Those vowels are special, in that their width are zero ,and I bet their origin point is the right-top point, instead of left-top. This way, vowels can be drawn on top of other characters preceding them.

When lwuit designer generates bitmap font, it draws every character (What I mean is, unicode character) onto a big bitmap, calculates the width of current character, add that width to current offset, and draws the next character. As a vowel has a width of zero, it will be combined into the last non-vowel character preceding it.

To solve this problem, you can either switch to unicode font (Bangali has a place in unicode), or you can stick to the current font and do some customization work to the font generation process.

1 Create your own class overriding the EditorFont class in lwuit's editor.jar.
2 Override EditorFont#getBitmapFont() method, do your own drawing of every character. You can test if any character is a vowel, and if so, draw it with a preceding space.
3 Override the FontTask Ant task provided in lwuit's editor.jar.
4 Override the FontTask#addToResources() method, insert your own EditorFont instance instead of the original one.
5 Override the LWUITTask class, add an AddXXX method to support your overriden FontTask.
6 Build a resource using ant, and use your own version of LWUITTask and FontTask instead of the original version.
7 As vowels have become regular characters, they will take up the same space as other characters and cannot be drawn on top of other characters any more. You have to draw them on top of other characters manually. The com.sun.lwuit.CustomFont class may have to be overriden in order to draw these vowels correctly.

Given the complexity introduced, I highly recommend switching to unicode font. But as I have said, I know nothing about Bangali and cannot tell if it is adequate to use a unicode font. Maybe you have to do it the hard way after all.

Good luck.

Smithy