FontResourcespublic 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_SMonospaced, plain, small | public static final int | MONO_I_SMonospaced, italic, small | public static final int | MONO_B_SMonospaced, bold, small | public static final int | MONO_BI_SMonospaced, bold italic, small | public static final int | MONO_U_SMonospaced, underline, small | public static final int | MONO_UI_SMonospaced, underline italic, small | public static final int | MONO_UB_SMonospaced, underline bold, small | public static final int | MONO_UBI_SMonospaced, underline bold italic, small | public static final int | MONO_P_MMonospaced, plain, medium | public static final int | MONO_I_MMonospaced, italic, medium | public static final int | MONO_B_MMonospaced, bold, medium | public static final int | MONO_BI_MMonospaced, bold italic, medium | public static final int | MONO_U_MMonospaced, underline, medium | public static final int | MONO_UI_MMonospaced, underline italic, medium | public static final int | MONO_UB_MMonospaced, underline bold, medium | public static final int | MONO_UBI_MMonospaced, underline bold italic, medium | public static final int | MONO_P_LMonospaced, plain, large | public static final int | MONO_I_LMonospaced, italic, large | public static final int | MONO_B_LMonospaced, bold, large | public static final int | MONO_BI_LMonospaced, bold italic, large | public static final int | MONO_U_LMonospaced, underline, large | public static final int | MONO_UI_LMonospaced, underline italic, large | public static final int | MONO_UB_LMonospaced, underline bold, large | public static final int | MONO_UBI_LMonospaced, underline bold italic, large | public static final int | PROP_P_SProportional, plain, small | public static final int | PROP_I_SProportional, italic, small | public static final int | PROP_B_SProportional, bold, small | public static final int | PROP_BI_SProportional, bold italic, small | public static final int | PROP_U_SProportional, underline, small | public static final int | PROP_UI_SProportional, underline italic, small | public static final int | PROP_UB_SProportional, underline bold, small | public static final int | PROP_UBI_SProportional, underline bold italic, small | public static final int | PROP_P_MProportional, plain, medium | public static final int | PROP_I_MProportional, italic, medium | public static final int | PROP_B_MProportional, bold, medium | public static final int | PROP_BI_MProportional, bold italic, medium | public static final int | PROP_U_MProportional, underline, medium | public static final int | PROP_UI_MProportional, underline italic, medium | public static final int | PROP_UB_MProportional, underline bold, medium | public static final int | PROP_UBI_MProportional, underline bold italic, medium | public static final int | PROP_P_LProportional, plain, large | public static final int | PROP_I_LProportional, italic, large | public static final int | PROP_B_LProportional, bold, large | public static final int | PROP_BI_LProportional, bold italic, large | public static final int | PROP_U_LProportional, underline, large | public static final int | PROP_UI_LProportional, underline italic, large | public static final int | PROP_UB_LProportional, underline bold, large | public static final int | PROP_UBI_LProportional, underline bold italic, large | public static final int | SYS_P_SSystem, plain, small | public static final int | SYS_I_SSystem, italic, small | public static final int | SYS_B_SSystem, bold, small | public static final int | SYS_BI_SSystem, bold italic, small | public static final int | SYS_U_SSystem, underline, small | public static final int | SYS_UI_SSystem, underline italic, small | public static final int | SYS_UB_SSystem, underline bold, small | public static final int | SYS_UBI_SSystem, underline bold italic, small | public static final int | SYS_P_MSystem, plain, medium | public static final int | SYS_I_MSystem, italic, medium | public static final int | SYS_B_MSystem, bold, medium | public static final int | SYS_BI_MSystem, bold italic, medium | public static final int | SYS_U_MSystem, underline, medium | public static final int | SYS_UI_MSystem, underline italic, medium | public static final int | SYS_UB_MSystem, underline bold, medium | public static final int | SYS_UBI_MSystem, underline bold italic, medium | public static final int | SYS_P_LSystem, plain, large | public static final int | SYS_I_LSystem, italic, large | public static final int | SYS_B_LSystem, bold, large | public static final int | SYS_BI_LSystem, bold italic, large | public static final int | SYS_U_LSystem, underline, large | public static final int | SYS_UI_LSystem, underline italic, large | public static final int | SYS_UB_LSystem, underline bold, large | public static final int | SYS_UBI_LSystem, underline bold italic, large |
Methods Summary |
---|
static javax.microedition.lcdui.Font | getFont(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.
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);
|
|