Unicode fonts in Java

M

maxwell

(I confess to having posted this query last week. I got no
responses. I don't believe this is off-topic, and I'm puzzled why I
didn't get any responses. So I'm trying again, under a different
subject line. I'll shut up if I don't hear anything.)

I'm using a Java-based application (XMLmind) on MsWindows XP SP2,
which is relevant, because the support for rendering Bengali Unicode
was fixed in SP2. However, I'm unable to get the fix to be used by
this Java app.

Specifically, I want the app to use a particular font, the Vrinda.ttf
font, for Unicode Bengali (but not for other regions of Unicode).
Can't seem to make it work.

I've been advised to edit the fontconfig file, using the instructions
at http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html.
The instructions seem (to me) a bit unclear; apparently Java looks for
a file with a name like 'fontconfig.properties' (there are no
fontconfig.XP.properties files, etc. on my PC). I don't have such a
file, only the compiled version, but I also have the source for that
compiled version, namely fontconfig.properties.src. If I'm
understanding the instructions correctly, you just copy that
fontconfig.properties.src file to fontconfig.properties, and edit the
latter; I guess Java then reads the fontconfig.properties file at
startup rather than the fontconfig.properties.bfc file, which
presumably means starting takes fractionally longer. If on the other
hand I need to compile my modified fontconfig.properties file, that
probably explains my lack of results--but I don't know how to compile
it.

I'm also not certain what I have to do to make Java re-load the
fontconfig.properties file. I'm assuming that if I shut down XMLmind,
and re-start it, that Java also shuts down and re-starts, and in re-
starting it reads in the modified fontconfig.properties file.
(Actually, I just checked that with the Windows Task Manager, and
indeed Java is shutting down when I close XMLmind. Whether Java is
reading in my munged fontconfig.properties file, I can't tell.)

Assuming I've guessed right thus far, I made the following changes to
the fontconfig.properties file, following the existing code for
Devanagari:

--Added a line at the top of the 'Component Font Mappings':
allfonts.bengali=Vrinda
--Modifed the UTF-8 Search Sequence line to include Bengali:
sequence.allfonts.UTF-8.hi=alphabetic/
1252,devanagari,bengali,dingbats,symbol
--Added a line at the top of the 'Font File Names':
filename.Vrinda=VRINDA.TTF
(The vrinda.ttf file is indeed in my Windows/fonts directory.)

This has no effect; XMLmind is still not using the Vrinda font to
render UTF-8 Bengali text.

A couple things occur to me. How does Java know what to do with the
string 'bengali'? Does it in fact know that this refers to the
Unicode range U+0980 to U+09FF? Does Java actually read the
fontconfig.properties file, i.e. is fontconfig.properties.src the
correct format, or do I need to compile this file? If so, how? Or is
it perhaps the case that XMLmind overrides what Java thinks it's
supposed to do for rendering Bengali text? (The XMLmind people are
the ones who told me to mung the fontconfig.properties file, so I
don't think this is the case; but how could I test it, i.e. how can I
get raw Java to render some Bengali text for me?)

Suggestions?

Mike Maxwell
CASL/ U MD
 
T

Thomas Fritsch

(I confess to having posted this query last week. I got no
responses. I don't believe this is off-topic, and I'm puzzled why I
didn't get any responses. So I'm trying again, under a different
subject line. I'll shut up if I don't hear anything.)

I'm using a Java-based application (XMLmind) on MsWindows XP SP2,
which is relevant, because the support for rendering Bengali Unicode
was fixed in SP2. However, I'm unable to get the fix to be used by
this Java app.

Specifically, I want the app to use a particular font, the Vrinda.ttf
font, for Unicode Bengali (but not for other regions of Unicode).
Can't seem to make it work.

I've been advised to edit the fontconfig file, using the instructions
at http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html. [...]

Suggestions?

I checked the bengali characters on my system (WindowsXP, with SP2) with
my "Unicode Character Table" applet at
<http://www.myjavaserver.com/~thomasfritsch/unicode.html> (selected font
"Vrinda" in the toolbar, and selected block "980:BENGALI" from the
"Block" menu).
As far as I can say (without knowing any bengali), the bengali
characters are rendered correctly.

Note that I did *not* touch any of Java's fontconfig files.
Having the "Vrinda.ttf" file in my Windows/fonts directory seems to be
just enough.
 
T

Thomas Fritsch

Thomas said:
I checked the bengali characters on my system (WindowsXP, with SP2) with
my "Unicode Character Table" applet at
<http://www.myjavaserver.com/~thomasfritsch/unicode.html> (selected font
"Vrinda" in the toolbar, and selected block "980:BENGALI" from the
"Block" menu).
As far as I can say (without knowing any bengali), the bengali
characters are rendered correctly.

Note that I did *not* touch any of Java's fontconfig files.
Having the "Vrinda.ttf" file in my Windows/fonts directory seems to be
just enough.
I'm afraid I have completely misunderstood your goal.

Now I think you want your application to correctly display the Bengali
characters (0980-09FF) when any Java's logical font (like "Dialog",
"Serif", "SansSerif") is selected.
When writing my previous answer I thought you wanted to display Bengali
characters when the selected font is "Vrinda" (which is almost trivial).

So I created a file "fontconfig.properties" (as a copy of
"fontconfig.properties.src") and did the 3 modifications you described:
--Added a line at the top of the 'Component Font Mappings':
allfonts.bengali=Vrinda
--Modifed the UTF-8 Search Sequence line to include Bengali:
sequence.allfonts.UTF-8.hi=alphabetic/1252,devanagari,bengali,dingbats,symbol
--Added a line at the top of the 'Font File Names':
filename.Vrinda=VRINDA.TTF
When checking it with
<http://www.myjavaserver.com/~thomasfritsch/unicode.html> (selecting
font "Dialog", and going to block "980:BENGALI"), the Bengali characters
were all rendered as a sqare box.
So far the same disappointing result like you got.

I made one further change to "fontconfig.properties":
--Modifed the Default Search Sequence line to include Bengali:
sequence.allfonts=alphabetic/default,bengali,dingbats,symbol
When again checking it with
<http://www.myjavaserver.com/~thomasfritsch/unicode.html> (selecting
font "Dialog", and going to block "980:BENGALI"), the Bengali
characters are rendered correctly!!!
 
M

maxwell

I'm afraid I have completely misunderstood your goal.

Now I think you want your application to correctly display the Bengali
characters (0980-09FF) when any Java's logical font (like "Dialog",
"Serif", "SansSerif") is selected.

Correct, although I guess I didn't explain it very well.
So I created a file "fontconfig.properties" (as a copy of
"fontconfig.properties.src") and did the 3 modifications you described
...
I made one further change to "fontconfig.properties":
--Modifed the Default Search Sequence line to include Bengali:
sequence.allfonts=alphabetic/default,bengali,dingbats,symbol
When again checking it with
<http://www.myjavaserver.com/~thomasfritsch/unicode.html> (selecting
font "Dialog", and going to block "980:BENGALI"), the Bengali
characters are rendered correctly!!!

Thanks! I verified that this works using another applet that someone
gave me, and it works there too. Unfortunately, XMLmind still shows
blocks instead of Bengali characters (as does jEdit, another Java
app). But at least now I can go back to the XMLmind folks and tell
them what I found.

Mike Maxwell
CASL / U MD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top