If you would like to check available font on Java environment, you should use this method.
The following code is utility class for Font.
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
The following code is utility class for Font.
package com.dukesoftware.utils.common; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.util.Arrays; public class FontUtils { public static void main(String[] args) { printAvailableFonts(); } public static void printAvailableFonts() { System.out.println(Arrays.toString(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames())); } public static boolean isAvailableFont(String font){ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final String[] fontNames = ge.getAvailableFontFamilyNames(); for(String name: fontNames){ if(name.equals(font)){ return true; } } return false; } }
コメント