FileDocCategorySizeDatePackage
FontResources.javaAPI DocphoneME MR2 API (J2ME)12875Wed May 02 18:00:20 BST 2007com.sun.midp.chameleon.skins.resources

FontResources

public class FontResources extends Object
There are three different font faces available in MIDP: Monospace, Proportional, and System. There are eight different styles available: Plain, Italic, Bold, Bold Italic, Underline, Underline Italic, Underline Bold, and Underline Bold Italic. There are three different sizes available: Small, Medium, and Large. That presents a matrix of 72 different font possibilities. This class serves to manage those different possibilities. Identifiers use a FACE_STYLE_SIZE naming scheme, where FACE is one of [MONO|PROP|SYS], STYLE is one of [P|I|B|BI|U|UI|UB|UBI], and SIZE is one of [S|M|L].

Fields Summary
public static final int
MONO_P_S
Monospaced, plain, small
public static final int
MONO_I_S
Monospaced, italic, small
public static final int
MONO_B_S
Monospaced, bold, small
public static final int
MONO_BI_S
Monospaced, bold italic, small
public static final int
MONO_U_S
Monospaced, underline, small
public static final int
MONO_UI_S
Monospaced, underline italic, small
public static final int
MONO_UB_S
Monospaced, underline bold, small
public static final int
MONO_UBI_S
Monospaced, underline bold italic, small
public static final int
MONO_P_M
Monospaced, plain, medium
public static final int
MONO_I_M
Monospaced, italic, medium
public static final int
MONO_B_M
Monospaced, bold, medium
public static final int
MONO_BI_M
Monospaced, bold italic, medium
public static final int
MONO_U_M
Monospaced, underline, medium
public static final int
MONO_UI_M
Monospaced, underline italic, medium
public static final int
MONO_UB_M
Monospaced, underline bold, medium
public static final int
MONO_UBI_M
Monospaced, underline bold italic, medium
public static final int
MONO_P_L
Monospaced, plain, large
public static final int
MONO_I_L
Monospaced, italic, large
public static final int
MONO_B_L
Monospaced, bold, large
public static final int
MONO_BI_L
Monospaced, bold italic, large
public static final int
MONO_U_L
Monospaced, underline, large
public static final int
MONO_UI_L
Monospaced, underline italic, large
public static final int
MONO_UB_L
Monospaced, underline bold, large
public static final int
MONO_UBI_L
Monospaced, underline bold italic, large
public static final int
PROP_P_S
Proportional, plain, small
public static final int
PROP_I_S
Proportional, italic, small
public static final int
PROP_B_S
Proportional, bold, small
public static final int
PROP_BI_S
Proportional, bold italic, small
public static final int
PROP_U_S
Proportional, underline, small
public static final int
PROP_UI_S
Proportional, underline italic, small
public static final int
PROP_UB_S
Proportional, underline bold, small
public static final int
PROP_UBI_S
Proportional, underline bold italic, small
public static final int
PROP_P_M
Proportional, plain, medium
public static final int
PROP_I_M
Proportional, italic, medium
public static final int
PROP_B_M
Proportional, bold, medium
public static final int
PROP_BI_M
Proportional, bold italic, medium
public static final int
PROP_U_M
Proportional, underline, medium
public static final int
PROP_UI_M
Proportional, underline italic, medium
public static final int
PROP_UB_M
Proportional, underline bold, medium
public static final int
PROP_UBI_M
Proportional, underline bold italic, medium
public static final int
PROP_P_L
Proportional, plain, large
public static final int
PROP_I_L
Proportional, italic, large
public static final int
PROP_B_L
Proportional, bold, large
public static final int
PROP_BI_L
Proportional, bold italic, large
public static final int
PROP_U_L
Proportional, underline, large
public static final int
PROP_UI_L
Proportional, underline italic, large
public static final int
PROP_UB_L
Proportional, underline bold, large
public static final int
PROP_UBI_L
Proportional, underline bold italic, large
public static final int
SYS_P_S
System, plain, small
public static final int
SYS_I_S
System, italic, small
public static final int
SYS_B_S
System, bold, small
public static final int
SYS_BI_S
System, bold italic, small
public static final int
SYS_U_S
System, underline, small
public static final int
SYS_UI_S
System, underline italic, small
public static final int
SYS_UB_S
System, underline bold, small
public static final int
SYS_UBI_S
System, underline bold italic, small
public static final int
SYS_P_M
System, plain, medium
public static final int
SYS_I_M
System, italic, medium
public static final int
SYS_B_M
System, bold, medium
public static final int
SYS_BI_M
System, bold italic, medium
public static final int
SYS_U_M
System, underline, medium
public static final int
SYS_UI_M
System, underline italic, medium
public static final int
SYS_UB_M
System, underline bold, medium
public static final int
SYS_UBI_M
System, underline bold italic, medium
public static final int
SYS_P_L
System, plain, large
public static final int
SYS_I_L
System, italic, large
public static final int
SYS_B_L
System, bold, large
public static final int
SYS_BI_L
System, bold italic, large
public static final int
SYS_U_L
System, underline, large
public static final int
SYS_UI_L
System, underline italic, large
public static final int
SYS_UB_L
System, underline bold, large
public static final int
SYS_UBI_L
System, underline bold italic, large
Constructors Summary
Methods Summary
static javax.microedition.lcdui.FontgetFont(int fontID)
This is a static convenience method for retrieving a system Font object based on an identifier. The identifier must be one of the values defined in FontResourcesConstants, ie, MONO_S_P, SYS_L_UBI, etc.

param
fontID the integer identifier for the Font to retrieve
return
the system Font corresponding to the given integer id, null if the fontID is not a valid identifier. Note, this Font may not be exactly what is requested and has the same caveats as the normal Font constructor in terms of what gets returned versus the parameters given.



                                                                                                                                    
        
        int face, size, style;
        
        if (fontID >= 700) {
            face = Font.FACE_SYSTEM;
            fontID -= 700;   
        } else if (fontID >= 400) {
            face = Font.FACE_PROPORTIONAL;
            fontID -= 400;
        } else if (fontID >= 100) {
            face = Font.FACE_MONOSPACE;
            fontID -= 100;
        } else {
            return null;
        }
            
        if (fontID >= 200) {
            size = Font.SIZE_LARGE;
            fontID -= 200;
        } else if (fontID >= 100) {
            size = Font.SIZE_MEDIUM;
            fontID -= 100;
        } else {
            size = Font.SIZE_SMALL;
        }
        
        switch (fontID) {
            case 0:
                style = Font.STYLE_PLAIN;
                break;
            case 1:
                style = Font.STYLE_ITALIC;
                break;
            case 2:
                style = Font.STYLE_BOLD;
                break;
            case 3:
                style = Font.STYLE_ITALIC | Font.STYLE_BOLD;
                break;
            case 4:
                style = Font.STYLE_UNDERLINED;
                break;
            case 5:
                style = Font.STYLE_UNDERLINED | Font.STYLE_ITALIC;
                break;
            case 6:
                style = Font.STYLE_UNDERLINED | Font.STYLE_BOLD;
                break;
            case 7:
                style = Font.STYLE_UNDERLINED | Font.STYLE_BOLD |
                    Font.STYLE_ITALIC;
                break;
            default:
                return null;
        }
        
        return Font.getFont(face, style, size);