3

Installed Oracle 8 jdk on Ubuntu, within jre/lib it has various fontProperties files plus a fonts dir containing fonts. But when installed OpenJdk 8 there is no such fonts folder on font files within jre/lib.

So where does it get its fonts from, does it come with any fonts on depen on the system having some fonts installed somewhere else.

Update Based on advise from gerynix

fc-list

returns no fonts

GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

gives

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)
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351

1 Answers1

1

It gets it from the environment on top of which you are running your application.

Look into:

GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

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

gerynix
  • 51
  • 3
  • 1
    so I assume if you have a stripped down linux machine with no fonts then any code that depended on some font being installed would fail, is there a linux command I can use to check what fonts are installed ? – Paul Taylor Mar 31 '17 at 15:41
  • fc-list, first google search result for "linux check available fonts" – gerynix Mar 31 '17 at 15:43
  • 1
    okay, Ive done both commands clearly have no fonts. So the machien is a piece of hardware running linux i cannot just update it like a usual machine, is there a way I can just install a font for use by my Java application by copying a file over without affecting anything else. – Paul Taylor Mar 31 '17 at 15:52
  • what flavour of linux are you using? – gerynix Mar 31 '17 at 15:52
  • Im not really sure but its arm32 hardware, uname -a gives Linux N1 3.3.4-ROMROOT-NT1 #1 Thu Feb 2 10:21:27 JST 2017 armv7l GNU/Linux – Paul Taylor Mar 31 '17 at 15:54
  • cat /etc/*release to reveal – gerynix Mar 31 '17 at 15:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/139611/discussion-between-gerynix-and-paul-taylor). – gerynix Mar 31 '17 at 15:56
  • Thanks in the end i found creating a dir called fonts within the jre lib folder and copying some fonts from your suggestion of https://github.com/google/fonts/archive/master.zip worked, I didnt need to run fc-cache -f – Paul Taylor Mar 31 '17 at 19:33