Java: How to tell which fontconfig file my system is currently using?
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 开发者_JAVA百科which fontconfig
file my system is using?
Thanks,
-John David
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
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
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
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
Try monitoring the files that are opened, using the command line tool lsof, e.g.
lsof -r | grep fontconfig
精彩评论