Urbanleg
Urbanleg

Reputation: 6542

How to get the directory of the windows fonts?

I want to create a function that retrieves the windows \ system \ fonts directory. It must not be hard-coded.

Iv'e heard there is somthing like :

%WINDIR%/fonts   

Any ideas?

Upvotes: 0

Views: 2997

Answers (3)

Nitesh
Nitesh

Reputation: 88

In java 1.7, FontManager has been discontinued. Hence, if you are using Java 1.7, you can use the following:-

String systemRoot = System.getenv().get("SystemRoot");

Upvotes: 1

Reimeus
Reimeus

Reputation: 159844

You could use sun.font.FontManager:

System.out.println( FontManager.getFontPath( true ) );

Upvotes: 6

RNJ
RNJ

Reputation: 15552

You can use the System.getEnv(...) command

Something like

String path = System.getEnv("WINDIR");
File fontDirectory = new File(path, "Fonts");

Upvotes: 3

Related Questions