在Linux上为Openjdk Java定义/安装的字体在哪里

时间:2017-03-31 15:32:30

标签: java fonts openjdk

在Ubuntu上安装了Oracle 8 jdk,在jre / lib中它有各种fontProperties文件和一个包含字体的字体dir。但是当安装OpenJdk 8时,jre / lib中的字体文件上没有这样的字体文件夹。

那么从哪里获取它的字体,它是否依赖于在其他地方安装了某些字体的系统上的任何字体。

更新 根据gerynix的建议

fc-list

不返回字体

GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

给出

java.lang.NullPointerException
        at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
        at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
        at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
        at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
        at sun.font.SunFontManager$2.run(SunFontManager.java:431)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<init>(SunFontManager.java:376)
        at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
        at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
        at sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:190)
        at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:224)
        at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:252)
        at sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:94)
        at Fonts.main(Fonts.java:10)

1 个答案:

答案 0 :(得分:1)

它从您运行应用程序的环境中获取它。

查看:

GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

https://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsEnvironment.html