Font problems (affecting Java and others?)

Alan Eliasen eliasen at
Sun Sep 7 21:17:22 EDT 2008

    I'm working on making it possible to get Java to run on the OLPC, 
and have a solution to what many of you may have seen:  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 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 X properties on windows, bug and having a clean implementation of 
the services currently built in Python, and making a C/Java binding to 

    (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, I can't build that on the OLPC, and can't emulate the OLPC 
due to bug .  I'll file those later.) 
  I know that there may be involved workarounds for some of these bugs, 
but I think it's important for everyone to know which bugs are seriously 
hampering developers who want to contribute, but don't have the time to 
research and duplicate lots of workarounds.  BTW, is there any progress 
on 7813?

    The problem is that our 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:


    Thus, it searches for a working font configuration in the following 

*  /usr/lib/jvm/jre-1.6.0-openjdk/lib/fontconfig.Fedora.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 "" 
in the same directory, we can create a file that is found before the 
.bfc file and test our changes.

    Inside the new "" 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 "" 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.

    3.) Add the missing fonts?

    4.) Do some unspecified font fallback trick?

    5.) Change "osname" (probably fetched from the Java property 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 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?

    I'll file a bug on this.  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?

    Alan Eliasen
    eliasen at

More information about the Devel mailing list