Using fonts in J2ME phone programming

Source: Internet
Author: User
Tags int size first row
Programming in J2ME mobile phone 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 is the method 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:
L face_monospace--Equal width font
L face_proportional--Balanced Font
L face_system--System fonts
The style parameter refers to the type of the font, and its value:
L style_bold--Bold
L style_italic--Oblique Body
L style_plain--Ordinary
L style_underlined--Underline
L Style_bold | style_italic--Bold Italic
L style_underlined | style_bold--underlined Bold
L style_underlined | style_italic--underlined italic
L style_underlined | Style_italic | style_bold--Bold Italic with underlined
The size parameter refers to the sizes of the fonts and their values:
L size_small--Small
L in size_medium--
L 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.
Finally, on the Nokia series of mobile phones, the font size of the specific parameters:

Platform
Default font size (in pixels)
S40
12
S60
16
S80
21st
Nokia7710
23



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.