开发者

How to get font folder path in Mac OS X?

开发者 https://www.devze.com 2023-03-03 21:20 出处:网络
In Windows O.S i can get the fonts folder pathus开发者_Python百科ing this java code : System.out.println( FontManager.getFontPath( true ) );// C:\\WINDOWS\\Fonts

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消