关键字:GraphicsEnvironment

1
2
3
4
5
6
7
8
//create the font
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(filepath + "demo.ttf"))
.deriveFont(250f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//register the font
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File(filepath + "demo.ttf")));

GraphicsEnvironment它针对默认语言环境进行了本地化,所以可以把外部的字体文件注册到本地中.