Jump to content
We've recently updated our Privacy Statement, available here ×
  • How do I list the fonts that are available to my JVM?


    gregd

    Issue:

    How do I know what fonts are available to my JVM?


    Resolution:

    ListFonts.java

    You can use this small java program to list all the fonts known to your JVM:

     

    import java.awt.GraphicsEnvironment;

     

    public class ListFonts {

        public static void main(String args[]) {

            GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();

            for(String font:e.getAvailableFontFamilyNames()) {

                System.out.println(font);

            }

        }

    }

    Simply add the above to a file called ListFonts.java, then run a command to compile:

    javac ListFonts.java

    And another command to list the fonts:

    java ListFonts

    You should get something like this:

    Century Schoolbook L

    DejaVu Sans

    DejaVu Sans Mono

    DejaVu Serif

    Dialog

    DialogInput

    Dingbats

    FreeMono

    FreeSans

    FreeSerif


     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...