夢想飛翔

          自強不息
          posts - 111, comments - 30, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          解讀javax.microedition.lcdui.Font 轉

          Posted on 2009-03-05 09:02 love1563 閱讀(493) 評論(0)  編輯  收藏 所屬分類: j2me學習筆記
           1public 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、理解明白了字體的結構。在寫程序的時候可以注意很多東西啦。
          主站蜘蛛池模板: 沈阳市| 金溪县| 大关县| 中阳县| 华蓥市| 宁安市| 岫岩| 交城县| 湖口县| 陆川县| 青龙| 阿巴嘎旗| 凤冈县| 连州市| 保靖县| 青神县| 舟山市| 霍州市| 大方县| 上虞市| 贡嘎县| 方城县| 新疆| 南安市| 迭部县| 阿拉善左旗| 凌海市| 孝感市| 武功县| 临西县| 潜山县| 崇左市| 南涧| 河曲县| 辽中县| 宿迁市| 方正县| 建德市| 乌拉特后旗| 尤溪县| 四平市|