Java如何获得可用的字体名称?
package org.nhooo.example.awt; import java.awt.Font; import java.awt.GraphicsEnvironment; public class FontNameList { public static void main(String[] args) { //从GraphicsEnvironment获取所有可用字体 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); //迭代所有可用字体并获取其名称和姓氏 for (Font font : fonts) { String fontName = font.getName(); String familyName = font.getFamily(); System.out.println("Font: " + fontName + "; family: " + familyName); } } }