• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to change Font in j2me

 
Rishi Tyagi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
Is there anybody who has worked on Fonts in j2me.
Actually i want to write some text on the canvas screen using drawString() method of Graphics class but in the font of my choice.
waiting for the reply..
Rishi
[ August 29, 2002: Message edited by: Rishi Tyagi ]
 
a sanjuan
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
font are limited.
you must first try to get a font, if available from the device.
the method is
static Font getFont (int face, int style, int size);
e.g
the 4 styles are:
STYLE_BOLD, STYLE_ITALIC, STYLE_PLAIN, STYLE_UNDERLINED
the sizes are:
SIZE_LARGE, SIZE_MEDIUM, SIZE_SMALL
the faces are:
FACE_MONOSPACE, FACE_PROPORTIONAL,FACE_SYSTEM
Font theFont=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
on the Graphics class you are using, use the method: void setFont(Font theFont)
for example:
g.setFont (theFont)
then use the drawString() method as usual to draw the text.
 
Rishi Tyagi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sanjuan,
It really works.
Regards,
Rishi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic