views:

94

answers:

1

using the g.drawText function (two calls one for each text) is it possible to write text in two different sizes?

g.drawText("abc",0,0);

//whatever code to change font goes here

g.drawText("def",30,30);
+1  A: 

Try:

g.setFont(font);

to get the font you want there is a static method in the Font class:

Font.getFont(int face, int style, int size);

EDIT:

you are right, I jumped to the wrong Font class in the API. Try this:

FontFamily ff = FontFamily.forName("family-name"); // e.g. serif
Font f = ff.getFont(style, height); // Use style bits from Font class, e.g. Font.BOLD

If you want to know which FontFamilies are available you can use:

FontFamily.getFontFamilies();
DaveJohnston
Its a good try, but it won't work because the Font classes are different. The one required for the g.setFont is the net.rim.device.api.ui.Font class but the one with the getFont is the javax.microedition.lcdui.Font class
paullb
See the edit I made to my answer.
DaveJohnston
Worked like a charm! Thanks!FYI: As I was not sure what fonts were available, for my POC I simplified to:FontFamily all[] = FontFamily.getFontFamilies();FontFamily ff = all[0];
paullb