Skip to main content

Regarding the use of createBitmapFont method in Font class

2 replies [Last post]
Joined: 2008-06-18

Hi Shai & Chen,

I am trying to use different font faces in my app. I know that i can use resource editor to create multiple fonts and put something such as "Label.font Bitmap : Vendana" in the theme configuration, this way i can apply new font to all labels in my app.

But the problem is that i want to use different font for different labels, say for the label beside userID and password textfield, i want to use Arial; but for the labels in list cells, i prefer using Vendana.

So i tried using the method,

public static Font createBitmapFont(Image bitmap, int[] cutOffsets, int[] charWidth, java.lang.String charsets)

but i have no idea about what i should pass to the second and third parameter, could you give me some examples of how to call this method?

BTW, Shai, the posts on your blog have always been very helpful to me!

Eric Liang (from Moblast)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-06-18

Thanks Shai, your solution works!!!

Joined: 2003-11-07

Hi Eric,
you shouldn't use createBitmapFont in normal circumstances it is mostly for internal/advanced usage and would also cost you in memory usage.
In the resource editor you can create multiple Font objects without actually placing them in a theme... After loading the resource use Font.getBitmapFont(fontName) to access this font to apply the font use cmp.getStyle().setFont(myFont);

Also notice that there is a bug in the current drop that makes Resources.getFontResource(fontName) somewhat wastetfull in some occasions so please try to avoid that method for now ;-)

Feel free to ask for subjects for future blog posts I will try to accommodate as much as possible.