Hi sreeNarayana,
Assuming that you created a .res file with Resource Editor, you need to set the font of the style of a component (such as a Label) to your custom font. Here is a sample code:
Code:
import com.sun.lwuit.Display;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.Style;
import com.sun.lwuit.util.Resources;
public class LWUITfonts extends javax.microedition.midlet.MIDlet
{
public void startApp()
{
Resources r = null;
Display.init(this);
try
{
//Open your resource font
r = Resources.open("/myfont.res");
//get the Font object. Name should be the same as the one defined in Resource Editor
Font myfont=r.getFont("NameGivenInResourceEditor");
Form f = new Form();
Label mylabel=new Label("Hello");
//Set the style of this component to your custom style
mylabel.getStyle().setFont(myfont);
f.setTitle("Hello World");
f.setLayout(new BorderLayout());
f.addComponent("Center", mylabel);
f.show();
} catch (java.io.IOException e) {}
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
}
Make sure that the .res file is located in the resource folder of your working project.