How to get font folder path in Mac OS X?
In Windows O.S i can get the fonts folder path us开发者_Python百科ing this java code :
System.out.println( FontManager.getFontPath( true ) ); // C:\WINDOWS\Fonts
But in Mac OS X this code returns nothing. Is there an alternative code for this in Mac ?
There are two paths for fonts on Mac OS X (that I know of), /Library/Fonts
and /System/Library/Fonts
.
If you're just looking for a list of fonts, you can use:
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()
A bit heavy handed, since it creates a GraphicsEnvironment
object, but it will return an array of java.awt.Font
containing an object that represents each font available on the system.
精彩评论