Java Internationalization and Localization
Determining the font name
If you have IE (5.0 through 5.5), it is easy to find the font
used to display a particular language. For example, I would like to
find out the fonts available for displaying Chinese web pages.
I can do the following:
Access the IE menu: Tools/Internet Options/General/Fonts (see
Figure 1). Then use the following fonts to display Simplified Chinese text.
- Bitstream Cyberbit
- Microsoft Sans Serif
- MS Song
- NsimSun
- SimHei
- SimSun
- Tahoma

Figure 1. Web font listing in IE for Simplify Chinese text.
|
Due to the large character sets of many Asian languages, their font
file is larger than the character sets typical of most Western languages.
With this knowledge, we can sort the font listing based on file size as
shown in Figure 2 from Control Panel/Font.
 Figure
2. Font Listing on my system.
|
From the figure shown above, one or many of the above fonts
"Batang", "Bitstream Cyberbit", "SimSun & NsimSun", "SimHei", and "MS
Song" can be used to view Chinese characters. We can use Navigator 4
to test which particular font is suitable.
In Navigator 4, go to Edit/Preferences/Appearance/Fonts, and set
the preferences as shown in the following figure.
 Figure
3. Setting Preferences in Netscape 4.76
|
With the completion of the above setting, access the site http://www.zaobao.com to view
the text correctly when that particular font is used. In this case,
the SimSun font can be used to display Chinese characters.
Yet another way of knowing what font can be used to display native
text is to use Office 2000 for opening the native text file. It will
automatically detect the encoding, then format the text with the
necessary font.
Creating font.properties.en for Netscape 4
With the font on your system and the knowledge of what font name to
use, we can create font.properties.en for Navigator 4 so
that our Java applet will display Chinese characters.
First, create a copy of font.properties.zh file found
in Netscape's ..\classes directory. Then rename the file
font.properties.en in the same directory.
font.properties.zh for Netscape 4 can be found at
C:\program files\netscape\communicator\program\java\classes
Edit the font.properties.en by replacing all occurrences of
\uXXXX unicode strings related to the SimSun font. In our case, replace
\u5b8b\u4f53 with SimSun.
With this new font.properties.en your Navigator 4, we will be able
to display the Chinese characters when we use any of the logical fonts
in our Java applet.
We can make changes to the original font.properties
too. However, it is easier to distribute font.properties.en,
so that we aren't required to backup files.
The NEFontFactory Helper Class
Now we want to create a helper class, called NEFontFactory, which will
have the following features:
- "Write Once and Run Everywhere"
- Font caching
- Font creation
- Font name listing
- Able to compile
using JDK 1.1 and above since our target is an applet.
The Helper class makes use of a Factory Pattern to create Font
objects.