查看支持的字体
以下代码用于运行时在控制台打印支持的字体
GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
final String AvailableFontFamilyNames[] = gEnv.getAvailableFontFamilyNames();
Stream.of(AvailableFontFamilyNames).forEach(System.out::println);
设置全局字体
private void initGlobalFont(Font font) {
FontUIResource fontRes = new FontUIResource(font);
for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof FontUIResource) {
UIManager.put(key, fontRes);
}
}
}
标签:Java,keys,FontUIResource,字体,key,Swing,UIManager,全局
From: https://www.cnblogs.com/liu-im/p/17671973.html