FONT problems with UNICODE - URGENT
i'm trying to present text in different languages, like english, greek or cyrillic and so on. i want to work with the Arial Unicode MS font, that is installed on my system and which DOES appear in the getAvailableFonts() list!!!
But when i try to display a greek text i see not all glyphs correctly. What have i to do?
Have I still to set up my font.properties file and if so how can i manage this
thanx a lot
[442 byte] By [
11037803] at [2007-9-26 1:58:59]

hi Michael,
You don't have to change the font*.properties files. The alternative (which, in fact I prefer) is to set the font directly for the component on which you are displaying text.
Can you give more details about what you are trying to do and what you observe that is unexpected?
Regards,
Joe
joefk at 2007-6-29 3:17:31 >

i tried to set the font of the component to "Arial Unicode MS" which appears in the getAvailableFont list! but that didnt work!
I'm trying to display values of a property resource file!
a greek version has the words as unicode combinations like \uxxxx and so on. but this doesnt work!
i only see a rectangle!
what else can i do?
Which version of Java are you using? Up through JDK 1.2.2 there was a bug that required a workaround to actually have the font render correctly. Try placing the following code directly after instantiating the font:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.getAllFonts();
Andy
i'm using jdk 1.2.2!
i also tried that, but without success! my code is:
this.setFont(new Font("Arial Unicode MS",Font.PLAIN, 12));
GraphicsEnvironment g= GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] f = g.getAllFonts();
=============================
i found something else:
text that is in my property file (written in unicode \uxxxx) is not rendered correctly! but a date is rendered correctly with the correct glyphs!
Try placing the two lines relating to GraphicsEnvironment *BEFORE* your call to creating a new Font (this.setFont(...)).
Hopefully this will do the trick.
-David
> i'm using jdk 1.2.2!
>
> i also tried that, but without success! my code is:
> this.setFont(new Font("Arial Unicode MS",Font.PLAIN,
> 12));
> GraphicsEnvironment g=
> GraphicsEnvironment.getLocalGraphicsEnvironment();
> Font[] f = g.getAllFonts();
> =============================
> i found something else:
> text that is in my property file (written in unicode
> \uxxxx) is not rendered correctly! but a date is
> rendered correctly with the correct glyphs!
>
thanx, but still the same problem!
my app is able to render the glyphs - but not when read in the unicode string from the property file! seems to me like a unicode problem! i'm reading the unicode string from the property file. do i have to do something else as reading in, e.g. converting or so?
I encountered the same problem before, after upgrade JRE to 1.3.1 International, it works, hope helpsKevin
Hello,
I facing the same problem. the thing is something like I set the font for the frame and i can see the different lenguage characters on the Graphics string but when i try this on the button the button or other componant show me the squares. So if my frame have the font Arial Unicode MS then the Button also have the same font which i tested even then its showing me squre. Can u help me out how can i show different language label on button.
Thanking you.
jignesh
To me, it looks as if your problem is that you're only calling setFont on "this".
That's only going to set it for the top level frame, and doesn't always do it for every individual component. The easy way to get around this is to go berserk with the setFont call. Set it on anything (heck, set it on your dog if it makes you feel any better)! ;D
The slightly harder but smarter way to do this is to write a recursive function that drills down your component list.
public void setFontRecursively(Font myFont, Component comp) {
comp.setFont(myFont);
if (comp instanceof Container) {
Component[] childComps = ((Container)comp).getComponents();
if (childComps != null) {
for (int i=0; i < childComps.length; i++) {
setFontRecursively(myFont, childComps[i]);
}
}
}
}
That should basically cover anything bar popup menus and drop-down submenus. You have to recall this as they appear, or they don't get the font straight off.
Hope that helps!
Martin Hughes