Java, unicode and fonts.

From: William Overington (
Date: Wed Sep 20 2000 - 13:00:30 EDT

I am having a problem with Java, unicode and fonts.

I have written the following test program and an HTML file which demonstrate
the problem.

Here is

import java.awt.*;

public class TestUnicode extends java.applet.Applet
    String textstring;

    public void init()
        textstring="The Caf\u00e9. \u0108u ne\u011das?";

    public void paint(Graphics screen)
        Font typeface = new Font("Helvetica", Font.PLAIN, 36);

    public void update(Graphics screen)


Here is TestUnicode.htm
<TITLE>The TestUnicode program</TITLE>
The TestUnicode program.
<APPLET code=TestUnicode.class height=300 width=500>

The desired effect is that blue lettering appears on a yellow background.
On the computer on which I developed the program, with the Sun Java
Development Kit 1.3, available free from the program
works well. It displays the sentence The Cafe with an acute accent on the e
of Cafe and it asks the question, in Esperanto, Is it snowing?, which, in
the best that 7 bit ascii will allow, is C^u neg^as? In the applet the C
and g are both expressed using accented characters.

However, as I had in mind the adding of applets capable of such unicode
character effects to our family webspace with the intention that they would
be usable by people who did not have the Java Development Kit installed, I
decided to first run the applet on another PC which has Internet Explorer 4
but not the Java Development Kit.

I copied across the files TestUnicode.htm and TestUnicode.class and double
clicked on the TestUnicode.htm file as displayed in Windows Explorer. The
text appeared in about 12 point with the e acute present but the C^ and the
g^ replaced with black vertical bars. Upon using View Source and then
closing the window thus opened, the text reappeared drawn in 36 point type,
with the C^ and g^ each replaced with an outline of a square.

In the program I have specified the font as Helvetica. I first used this a
couple of months ago in order to be able to get the Esperanto accents onto
the screen on the computer that has the Java Development Kit installed.
However, having been trying to solve this present problem, I have found that
there is no Helvetica font on the computer, either in the windows font
folder or in the font folder within the Java Development Kit: yet the name
Helvetica does appear as text within an alias section of a
file within the Java Development Kit. The Java Development Kit contains 12
TrueType font files, all types of Lucida, appearing to be essentially a
serifed face, a sanserif face and a constant width typewriter style face
each provided in Regular, Italic, Bold and Bold Italic, though the names are
a little different using the name oblique here and there rather than italic,
and so on. LucidaSansRegular.ttf at 238KB and LucidaSansOblique.ttf at
248KB are the largest by quite a margin.

Now, although I have included the short program in this
document, the real life problem that I am trying to solve concerns the
distribution of Engine1456.class and other files related to the 1456 object
code system which is described in various documents that are available on which is our family webspace.

My model of what I want to achieve is that someone interested in authoring
distance education packages and working on a computer in a library, maybe a
public library, with web access and probably allowed to use a floppy disc
drive, can achieve good results. The computer has a Java enabled browser,
but does not have a Java Development Kit. The computer has a text editor
available. I am aware that the scenario might be somewhat less convenient
in that the library might have one computer avilable with internet access
and a few others with text editing facilities available for use; that is,
although the internet machine has a text editor on it, the librarian tries
to maximize usage by having people doing text editing use the other machines
so as not to tie up the internet machine when someone else might wish to use
it to access the internet. Hopefully they might have a Java enabled browser
on them so that locally stored HTML files can be viewed. Our hypothetical
author is not allowed to do things such as add extra font files into the
windows system. Now hopefully our hypothetical distance education author
could achieve good results using the English language, by downloading copies
of Engine1456.class and the class file of a 1456 applet landscape file and
an HTML file and proceeding to customize the HTML file by adding 1456 object
code, using a text editor, into the param statements of the applet call.
Yes, it might all take place on a floppy disc within a library with going
backwards and forwards to the internet machine at times, as available, yet
it could be achieved. Stylish results which could perhaps be added onto
a free webspace somewhere or maybe posted into the newgroup. Yet suppose that our hypothetical
author now wishes to use Esperanto accented characters, or some characters
from a language other than the widely used languages of western europe. How
may he or she proceed? Can results such as the C^u neg^as? example be
achieved in such circumstances? Indeed, can a person, sat at the internet
machine in the library seeking to learn from an applet written elsewhere,
get to view the characters if they are from a language other than the widely
used languages of western europe.

I am aware that, subject to my checking on the license regarding
redistributables, I might be able to place a copy of one or more of the
fonts from the Java Development Kit on our family webspace. Is there some
way that I can make the applet TestUnicode access that font file directly
rather than rely upon a suitable font being available ready installed in the
computer being used by the end viewer? In that the files provided are quite
large, can they be downloaded and stored on and used from floppy disc if the
hypothetical author or the hypothetical learner cannot add them into the
windows system of the library computer? Indeed, is the adding of the font
files to the local machine something that someone who does have access needs
to do, or is there something more that needs to be done as well or is there
something different that needs to be done instead?

Can anyone help please?

William Overington

20 September 2000

This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:21:13 EDT