Using fonts
In J2ME mobile programming, you can use the Font class--font in the low-level user interface to achieve better performance, then how to use the Font class?
First of all, due to the limitations of mobile devices, the type of font supported in mobile phones is limited, so the font class object can only be constructed using the default font supported by the mobile phone in J2ME. The following are the methods to use when creating objects for the Font class:
GetFont (int face,int style,int size);
For example:
Font font = Font.getfont (font.face_system,font.style_bold,font. Size_medium);
Regardless of which parameter, you can use only the values that are set by the system, which can vary in size from one phone to another. The following is a detailed description of the values of the three parameters:
The face parameter refers to the appearance of the font and its value:
face_monospace--Equal width font
face_proportional--Balanced Fonts
face_system--system fonts
The style parameter refers to the type of the font, and its value:
style_bold--Bold
style_italic--Oblique Body
style_plain--Ordinary
style_underlined--Underline
Style_bold | style_italic--Bold Italic
style_underlined | style_bold--underlined Bold
style_underlined | style_italic--underlined italic
style_underlined | Style_italic | style_bold--Bold Italic with underlined
The size parameter refers to the sizes of the fonts and their values:
size_small--Small
In size_medium--
size_large--Big
By the value of the above parameter, you can assemble the Font object you want.
Here are some common font actions:
1. Get the default font for the system:
Font font = Font.getdefaultfont ();
2. Within the Panit method, assuming the name of the graphics parameter is G, the method for obtaining the current font is:
Font font = G.getfont ();
3. Within the Panit method, assuming the name of the graphics parameter is g, the current font method is set:
G.setfont (font);
The Font object that font constructs for you.
4. In MIDP2.0, the list can set the font format for each row by:
List.setfont (0,font);
The code above is to set the first row in the list to the font type.