Feeling

    三人行,必有我师焉

   ::  :: 新随笔 :: 联系 ::  :: 管理 ::
  185 随笔 :: 0 文章 :: 392 评论 :: 0 Trackbacks

Eclipse下的插件开发如果需要用到什么字体或其他的工具时,尽量避免使用AWT GraphicsEnvironment ,这会导致Vista Aero效果暂停工作。如果有需要得到Font字体列表的话,可以使用SWT的FontList拿到:

 1    public static String[] getSystemFontNames( Comparator comparator )
 2    {
 3        FontData[] fontDatas = (FontData [])Display.getCurrent( ).getFontList( nullfalse );
 4        SortedSet set = new TreeSet(comparator);
 5        for(int i=0;i<fontDatas.length;i++){
 6            set.add( fontDatas[i].getName( ) );
 7        }

 8        fontDatas = ( FontData [] )Display.getCurrent( ).getFontList( nulltrue );
 9        for(int i=0;i<fontDatas.length;i++){
10            set.add( fontDatas[i].getName( ));
11        }

12        String[] fonts = new String[set.size( )];
13        set.toArray( fonts );
14        return fonts;
15    }

/**
 * Returns <code>FontData</code> objects which describe
 * the fonts that match the given arguments. If the
 * <code>faceName</code> is null, all fonts will be returned.
 *
 * 
@param faceName the name of the font to look for, or null
 * 
@param scalable if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.
 * 
@return the matching font data
 *
 * 
@exception SWTException <ul>
 *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
 * </ul>
 
*/

public FontData [] getFontList (String faceName, boolean scalable)
posted on 2007-04-30 16:34 三人行,必有我师焉 阅读(1102) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
GitHub |  开源中国社区 |  maven仓库 |  文件格式转换