Posted on 2009-03-05 09:02
love1563 閱讀(495)
評(píng)論(0) 編輯 收藏 所屬分類:
j2me學(xué)習(xí)筆記
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的關(guān)鍵設(shè)置參數(shù)是face,style,size.
2、
Font的可讀屬性是字體的高度height和baseline。字體的高度通常是一定,而寬度則需要根據(jù)不同的字符來決定。
因?yàn)槊總€(gè)字都有字形Glaph,每個(gè)字形有自己的寬度。通常是同一系列的具有相同的寬度。
3、字體的創(chuàng)建是手機(jī)系統(tǒng)來實(shí)現(xiàn)的。
4、每個(gè)字的字形呢,需要手機(jī)系統(tǒng)來實(shí)現(xiàn)。
5、這里的
Font是非常簡(jiǎn)化的,并限定了一些樣式和大小。
6、默認(rèn)字體是無樣式的平字體。
7、注意:系統(tǒng)要求支持三種字體:SYSTEM,MONOSPACE,PROPORTIONAL。這些都是經(jīng)典字體啦。我們都使用的是SYSTEM字體就可以了。
8、理解明白了字體的結(jié)構(gòu)。在寫程序的時(shí)候可以注意很多東西啦。