Reputation: 6542
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
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
Reputation: 159844
You could use sun.font.FontManager
:
System.out.println( FontManager.getFontPath( true ) );
Upvotes: 6
Reputation: 15552
You can use the System.getEnv(...) command
Something like
String path = System.getEnv("WINDIR");
File fontDirectory = new File(path, "Fonts");
Upvotes: 3