Posted on 2009-03-05 09:02
love1563 閱讀(487)
評論(0) 編輯 收藏 所屬分類:
j2me學習筆記
1
public final class Font
{
2
private Font(int face, int style, int size)
{
3
this.face = face;
4
this.style = style;
5
this.size = size;
6
7
init(face, style, size);
8
}
9
public native int charWidth(char ch);
10
public native int charsWidth(char[] ch, int offset, int length);
11
public native int stringWidth(java.lang.String str);
12
public native int substringWidth(String str, int offset, int len);
13
private int face;
14
private int style;
15
private int size;
16
private int baseline;
17
private int height;
18
private static final Font DEFAULT_FONT = new Font(FACE_SYSTEM,
19
STYLE_PLAIN,
20
SIZE_MEDIUM);
21
22
private static java.util.Hashtable table = new java.util.Hashtable(4);
23
private native void init(int face, int style, int size);
24
}
25
1、
Font的關鍵設置參數是face,style,size.
2、
Font的可讀屬性是字體的高度height和baseline。字體的高度通常是一定,而寬度則需要根據不同的字符來決定。
因為每個字都有字形Glaph,每個字形有自己的寬度。通常是同一系列的具有相同的寬度。
3、字體的創建是手機系統來實現的。
4、每個字的字形呢,需要手機系統來實現。
5、這里的
Font是非常簡化的,并限定了一些樣式和大小。
6、默認字體是無樣式的平字體。
7、注意:系統要求支持三種字體:SYSTEM,MONOSPACE,PROPORTIONAL。這些都是經典字體啦。我們都使用的是SYSTEM字體就可以了。
8、理解明白了字體的結構。在寫程序的時候可以注意很多東西啦。