Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 which fontconfig file my system is using?

Thanks,

-John David

like image 322
jkndrkn Avatar asked Apr 06 '10 18:04

jkndrkn


People also ask

Where are Java fonts installed?

Support for Physical Fonts The JRE looks in two locations: the lib/fonts directory within the JRE itself, and the normal font location(s) defined by the host operating system. If fonts with the same name exist in both locations, the one in the lib/fonts directory is used.

What fonts does Java have?

Java defines five logical font families that are Serif, SansSerif, Monospaced, Dialog, and DialogInput.

What is Fontconfig in Ubuntu?

Fontconfig is a library designed to provide system-wide font configuration, customization and application access.


2 Answers

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
like image 85
Adam Avatar answered Sep 25 '22 20:09

Adam


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
like image 36
Markus Avatar answered Sep 24 '22 20:09

Markus