In the mobile programming of j2-based mobile phones, we can use the Font class to achieve better performance in the low-level user interface. How can we use the Font class?
First, due to restrictions on mobile phone devices, the Font types supported by mobile phones are very limited. Therefore, you can only use the default Font supported by mobile phones to construct Font-type objects. The following method is used to create a Font Class Object: getFont (int face, int style, int size); for example: Font font = Font. getFont (Font. FACE_SYSTEM, Font. STYLE_BOLD, Font. SIZE_MEDIUM); no matter which parameter, only the values set by the system can be used. The specific sizes of these values may vary on different mobile phones. The following describes in detail the values of the three parameters: the face parameter indicates the font appearance and its values: l FACE_MONOSPACE -- equal width font l FACE_PROPORTIONAL -- balanced font l FACE_SYSTEM -- the system font style parameter indicates the font style. The value can be: l STYLE_BOLD -- bold l STYLE_ITALIC -- italic l STYLE_PLAIN -- Common l italic -- underline l STYLE_BOLD | STYLE_ITALIC -- bold italic l STYLE_UNDERLINED | STYLE_BOLD -- bold with underline l Italic STYLE_UNDERLINED | STYLE_ITALIC | STYLE_BOLD -- the bold italic size parameter indicates the font size, value: l SIZE_SMALL -- small l SIZE_MEDIUM -- l SIZE_LARGE -- the value of the pass-through parameter in SIZE_MEDIUM can combine the font objects you need. Below are some common font operations: 1. obtain the default Font of the system: font Font = Font. getDefaultFont (); 2. in the panit method, if the Graphics parameter is named g, the method for obtaining the current Font is: font Font = g. getFont (); 3. in the panit method, if the Graphics parameter is named g, the current font is set to g. setFont (font); font indicates the font object you have constructed. 4. in MIDP2.0, you can set the font format of each line in List by: list. setFont (0, font); then the code above sets the first line in the list as a font.
The following describes the font size parameters of Nokia mobile phones:
Platform
Default font size (in pixels)
S40
12
S60
16
S80
21
Nokia7710
23