Jul 25 2008

java 字体选择

Category: 技术ssmax @ 14:26:31

显示java能读到的系统字体,注释掉的是显示可以支持中文的字体。。。

import java.awt.*;

public class testfont
{
    public static void main(String [] args) throws Exception
    {
        Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        System.out.println(“All Fonts: “);
        for (int i = 0; i < fonts.length; i ++)
        {
            System.out.println(fonts[i].getFontName());
            /*
            if (fonts[i].canDisplayUpTo(“u4e00”) > 0) // ? 3
            {
                System.out.println(fonts[i].getFontName());
            }*/
        }
    }
}

Leave a Reply