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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.