Posted on 2009-03-05 09:02
love1563 阅读(481)
评论(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、理解明白了字体的结构。在写程序的时候可以注意很多东西啦。