6

I am trying to debug a font-related issue in a third-party Java application. Specifically, ChemAxon JChem. I've been consulting this guide: http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html

Part of the problem, is that I'm not sure which fontconfig.properties.src file my Java setup is currently referencing.

Here are my fontconfig files:

$ ls fontconfig*src 
fontconfig.Fedora.properties.src  fontconfig.properties.src   
fontconfig.SuSE.properties.src  fontconfig.Ubuntu.properties.src

My system is a CentOS system, so I imagine it is probably either ferencing the default fontconfig.properties.src file or the fontconfig.Fedora.properties.src file, since CentOS and Fedora are both derived from Red Hat.

So, can I definitively tell which fontconfig file my system is using?

Thanks,

-John David

jkndrkn
  • 4,012
  • 4
  • 36
  • 41

5 Answers5

4

The JRE class sun.awt.FontConfiguration already has logging for this, you just need to enable it.

  • Add this option to Java -Dsun.java2d.debugfonts=true
  • Edit jre/lib/logging.properties

Change this line

java.util.logging.ConsoleHandler.level = ALL

Add this line

sun.awt.FontConfiguration.level = ALL

And you'll then see a line like this in your stderr (logger uses stderr for some reason)

CONFIG: Read logical font configuration from /your/path/jre/lib/fontconfig.RedHat.6.bfc
Adam
  • 35,919
  • 9
  • 100
  • 137
2

Just use strace to check which of those files is successfully opened:

$ strace -f -e open java ... 2>&1 | grep fontconfig
[pid  3321] open("/usr/java/jdk1.7.0_55/jre/lib/fontconfig.RedHat.6.bfc", O_RDONLY|O_LARGEFILE) = 115

If this doesn't tell you which file it is using, chances are that it is using system wide fonctconfig instead. You will get an output starting like this then:

[pid  3259] open("/usr/java/jdk1.7.0_55/jre/lib/i386/xawt/libfontconfig.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  3259] open("/usr/java/jdk1.7.0_55/jre/lib/i386/xawt/../libfontconfig.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  3259] open("/usr/java/jdk1.7.0_55/bin/../lib/i386/jli/libfontconfig.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  3259] open("/usr/lib/libfontconfig.so.1", O_RDONLY) = 116
Markus
  • 3,155
  • 2
  • 23
  • 33
2

You can use the above options but as of JDK 7 and 8 there is a issue with the JDK, fontconfig file are not picked up for any Linux operating system. Its defaulting to libfontconfig that is present in the OS.

Here is the defect URL http://bugs.java.com/view_bug.do?bug_id=7175487

1

It will never look at the X.properties.src files - those are essentially there to tell you what the content of the matching X.bfc is. This describes the exact order the files are checked:

http://docs.oracle.com/javase/1.5.0/docs/guide/intl/fontconfig.html#loading

wowest
  • 1,974
  • 14
  • 21
0

Try monitoring the files that are opened, using the command line tool lsof, e.g.

lsof -r | grep fontconfig
vickirk
  • 3,979
  • 2
  • 22
  • 37
  • 1
    Hey, thanks for the suggestion. Unfortunately, this only brings up binary files in my ~/.fontconfig directory. Opening up these files *does* show me some paths to font directories in my /usr/share/fonts/ directory, but not which fontconfig.properties files are actually being referenced. – jkndrkn Apr 07 '10 at 15:37
  • Maybe it isn't reading any of them! You could try stepping into the code in a debugger. – vickirk Apr 07 '10 at 16:54
  • I suspect it is reading the file and then closing it immediately.. . – Adam Feb 04 '16 at 14:04