1

In my application, I used custom font for table component using resource file. I created one font in resource file

Font.size = 10
Font.Face = Times new roman

Resources res = null;
res = Resources.open("/lang.res");      
font = res.getFont("SMALL_FONT");

Table table;
table = new Table(tableModel);
table.table.getStyle().setFont(font);

But I couldn't get the small font, it displays the default mobile font.

How to fix this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
selladurai
  • 6,491
  • 14
  • 56
  • 88

2 Answers2

1

In my opinion is possible that you are setting the ´Style´ to the wrong Component.

I am testing it with the LWUIT Resource editor and the Deafult MIDlet (wich have a table Form), and changing the TableCell UIID, I can modify the font style. Try with this UIID.

Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • The example is the next: Open the resource editor, create a new theme, and set in the preview options, the Default MIDlet. Press the table button and now you can see a table in the Preview screen. Change de unselected UIID of TableCell and see how the cell of the tables change. You can change TableHeader too... try it – Mun0n May 21 '12 at 11:17
  • 1
    You can also derive table and override createCell to customize the font of the individual cell. – Shai Almog May 22 '12 at 03:49
1

Depending on your phone it may not work. For instance, on BlackBerry it always returns the same font and I get the same behavior on Samsung B2710 J2ME phone. I get around the issue by using bitmap fonts and loading them from resources.

Alex Gdalevich
  • 685
  • 7
  • 15