夢想飛翔

          自強不息
          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、理解明白了字體的結構。在寫程序的時候可以注意很多東西啦。
          主站蜘蛛池模板: 丘北县| 斗六市| 沙湾县| 浪卡子县| 迁安市| 沂南县| 西峡县| 清原| 万州区| 南澳县| 临高县| 洛南县| 探索| 正安县| 文山县| 银川市| 长白| 青神县| 古丈县| 宁安市| 忻州市| 天祝| 若尔盖县| 许昌县| 抚宁县| 平阴县| 桑日县| 莒南县| 泾源县| 柳河县| 沅江市| 金沙县| 化隆| 交城县| 上杭县| 万盛区| 彭州市| 雷波县| 马尔康县| 什邡市| 宁都县|