Font issues affecting Java OpenJDK (and other applications?)
|Reported by:||eliasen||Owned by:|
|Component:||not assigned||Version:||Development build as of this date|
|Keywords:||Java, OpenJDK, font, fontconfig||Cc:|
|Deployments affected:||Action Needed:||design|
I'm working on making it possible to get Java to run on the OLPC, and have a solution to the problem that any Java program uses a strange italicized serif font, no matter what font you request. This odd font is used everywhere, and no other fonts seem to work.
This is focusing on the OpenJDK 220.127.116.11 distribution as found in yum. (That's "yum install java-1.6.0-openjdk") I've also considered gcj, but gcj's implementations of things like AWT or Swing is far less complete than OpenJDK currently. My OLPC is running Joyride 2346. I was glad to see that despite what our Wiki says about Java, it's actually relatively easy to make graphical Java programs at least run on the OLPC, to switch to its window, etc. (I'm not talking about making it a full-blown activity, which is dependent on a lot of other things happening, such as not having to set raw X properties on windows, bug http://dev.laptop.org/ticket/5271 and having a clean C/Java implementation of the services currently built in Python.)
(By the way, I'm also experimenting with "java-gnome" which creates GTK bindings for gnome, so Java interfaces can look more like other Sugar applications, but due to several compounding bugs in our yum distribution, and pending patches to java-gnome, I can't build that on the OLPC.)
The problem is that our fontconfig files are not set up correctly for the fonts distributed on the OLPC. I've verified that adding one file fixes the problem, but there are several ways of fixing the problem and I wanted input from others on the proper way to do it.
Here's a page that gives background on how fonts are loaded in Java:
(It's Java 1.5 but it still seems to work the same in OpenJDK 1.6)
When looking at that page, note that Joyride 2346 sets the following:
JavaHome=/usr/lib/jvm/jre-1.6.0-openjdk OS=Fedora Version=9
Thus, it searches for a working font configuration in the following order:
/usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.Fedora.9.properties /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.Fedora.9.bfc /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.Fedora.properties * /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.Fedora.bfc /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.9.properties /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.9.bfc /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.properties /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.bfc
The one marked with * is the first one that exists. The .bfc files are a binary format.
In the above directory, there exists a file
By copying this file to the filename "fontconfig.Fedora.properties" in the same directory, we can create a file that is found before the .bfc file and test our changes.
Inside the new "fontconfig.Fedora.properties" file, at the end, there are lines like:
Unfortunately, those font files don't exist, but instead of, say DejaVuSans.ttf, we have files named DejaVuLGCSans.ttf.
Fixing the "fontconfig.fedora.properties" to change filenames of all DejaVu... to DejaVuLGC... fixes these problems, and Java implementations now display correctly.
Now, how is the proper way to fix it? Here are a few alternatives:
1.) Just add the fixed properties file as demonstrated above to the OLPC's OpenJDK distribution. Doing this is nice because it doesn't affect any existing files, and it's user-tweakable as opposed to the compiled .bfc file.
2.) Create symbolic links in the fonts directory, for example, DejaVuSans.ttf would be a symbolic link to DejaVuLGCSans.ttf. I don't know if this might help other applications. Note that Fedora 9 usually contains /usr/share/fonts/dejavu/ *AND* /usr/share/fonts/dejavu-lgc/ directories while the OLPC just contains the former. Other applications expecting a Fedora-like atmosphere may miss these fonts too.
3.) Add the missing fonts such as DejaVuSans.ttf. I'm not sure about the difference between these fonts and the LGC equivalents, but Fedora 9 seems to contain both.
4.) Do some unspecified font fallback trick?
5.) Change "osname" (probably fetched from the Java property os.name) in the OpenJava JVM from "Fedora" to something more specific to the OLPC, like "OLPC". This might allow us to push an OLPC configuration file upstream to the OpenJDK project. I'm not sure where os.name is set, or how it is detected, though.
Which of these (or some other alternative) is the best way to fix our Java font problem?
Is there anyone in charge of packaging the OpenJDK distribution? I can probably create a patch for it. By the way, I haven't verified if *all* fonts in our fontconfig file exist, such as Sazanami, Lohit, Baekmuk, etc., or if we should point it at other files on the OLPC.
By the way, what's the best way to:
a.) Create a patch for a *new* file
b.) compile a resource file to that .bfc format?