Unicode Characters on Screen

P

Phillip Lord

I'm a little confused over unicode support within java.

If I do something like....

JLabel label = new JLabel();
label.setText( "0" + (char)0x2800 + 1 + (char)0x2801 + 2 + (char)0x2802 );

which I expect to put the three characters "0 1 2" onto screen
separated by the three characters which turn out to be the first three
braille dot characters, in fact I get "0 1 2" separated by little
boxes which in my experience tends to indicate "I don't know how to
draw this character".

Does anyone know how I get the actual characters to appear?

Phil
 
J

John C. Bollinger

Phillip said:
I'm a little confused over unicode support within java.

If I do something like....

JLabel label = new JLabel();
label.setText( "0" + (char)0x2800 + 1 + (char)0x2801 + 2 + (char)0x2802 );

which I expect to put the three characters "0 1 2" onto screen
separated by the three characters which turn out to be the first three
braille dot characters, in fact I get "0 1 2" separated by little
boxes which in my experience tends to indicate "I don't know how to
draw this character".

Does anyone know how I get the actual characters to appear?

Use a Font for the JLabel that contains glyphs for those characters.
I'm not certain offhand what fonts might be suitable.


John Bollinger
(e-mail address removed)
 
M

Manish Jethani

Phillip said:
I'm a little confused over unicode support within java.

If I do something like....

JLabel label = new JLabel();
label.setText( "0" + (char)0x2800 + 1 + (char)0x2801 + 2 + (char)0x2802 );

which I expect to put the three characters "0 1 2" onto screen
separated by the three characters which turn out to be the first three
braille dot characters, in fact I get "0 1 2" separated by little
boxes which in my experience tends to indicate "I don't know how to
draw this character".

Does anyone know how I get the actual characters to appear?

Use a suitable font.

-Manish
 
J

John O'Conner

Phillip said:
I'm a little confused over unicode support within java.

If I do something like....

JLabel label = new JLabel();
label.setText( "0" + (char)0x2800 + 1 + (char)0x2801 + 2 + (char)0x2802 );
label.setText("0\u28001\u28012\u2802");



Does anyone know how I get the actual characters to appear?

Use a font that contains the Braille characters.

Regards,
John O'Conner
 
P

Phillip Lord

David> Does the font you're using have those glyphs?


Okay, from the four identical responses that I got (use the right
font) I realise that I have been remiss in asking the question.

From the results I got, the font does not have those glyphs. Clearly
such font's do exist.

So the real questions are

1) Do any of the standard defined fonts for java have these glyphs?
2) If not can I install new fonts into Java, that will have these
glyphs?
3) If I can how do I install such fonts? Can I do it programmatically?
4) Can any one suggest a good set of fonts with these characters in?


I'm starting to think that the sane course of action would be just to
draw these glyphs on screen "by hand" rather than with unicode. They
are, after all, fairly simple glyphs.


Phil
 
A

Andy Flowers

This may or may not help.

But the SDK comes with a nifty little font viewer. In my JDK this is <JDK
Root>\demo\jfc\Font2DTest\Font2DTest.jar

This may help you have a look at what fonts produce what output.

The caveat may be that you may find a font on a Windows machine that has
what you want, but this might not be there on Linux/Unix, but as most of the
worlds graphical clients are Windows this may not be too much of a
problem...
 
P

Phillip Lord

Andy> This may or may not help.

Andy> But the SDK comes with a nifty little font viewer. In my JDK
Andy> this is <JDK Root>\demo\jfc\Font2DTest\Font2DTest.jar

Andy> This may help you have a look at what fonts produce what
Andy> output.

Andy> The caveat may be that you may find a font on a Windows
Andy> machine that has what you want, but this might not be there on
Andy> Linux/Unix, but as most of the worlds graphical clients are
Andy> Windows this may not be too much of a problem...

Indeed it does. Sadly none of the fonts on my system has the braille
fonts. A bit of a pity.

I think its looking more likely that the appropriate solution is to
draw the glyphs by hand.

Cheers

Phil
 
P

Phillip Lord

Andy> There are fonts that can be downloaded to display the Braille
Andy> character set. Some are free, other not.

Andy> A quick google search on "Braille font download" should give
Andy> some ideas, especially at
Andy> http://www.tsbvi.edu/braille-resources/1087-download-braille-and-asl-specialty-fonts which includes,
Andy> amongst others, a font from the UK Royal National Institute
Andy> for the Blind (RNIB) which should have all you need.

Yeah, I found these. The problem is that I have absolutely no idea
what to do with these wrt java. It would also be nice to have stuff
work cross platform.

Phil
 
J

Jon A. Cruz

Phillip said:
1) Do any of the standard defined fonts for java have these glyphs?

Depends on the system they are on. :)


2) If not can I install new fonts into Java, that will have these
glyphs?
Yes.



3) If I can how do I install such fonts? Can I do it programmatically?

Kinda.

;-)

See java.awt.Font.createFont(int fontFormat,InputStream fontStream)
(Since JDK 1.3)

4) Can any one suggest a good set of fonts with these characters in?

Might check if the Vera fonts have them. Otherwise walk all fonts on the
runtime to find one.

This method will be *very* helpful in a programmatic search:

java.awt.Font.canDisplay(char c)

and find them with

java.awt.GraphicsEnvironment.getAllFonts()
 
D

Dale King

David> Does the font you're using have those glyphs?


Okay, from the four identical responses that I got (use the right
font) I realise that I have been remiss in asking the question.

From the results I got, the font does not have those glyphs. Clearly
such font's do exist.

So the real questions are

1) Do any of the standard defined fonts for java have these glyphs?

Java is more flexible than that. It doesn't exactly have standard defined
fonts. You can change and extend the font definitions yourself by
changing the font'properties files. A logical font like dialog in Java
isn't even necessarily a single font. It can be a combination of fonts
over various ranges.

See:

http://java.sun.com/j2se/1.4.2/docs/guide/intl/fontprop.html
 
P

Phillip Lord

Dale> Java is more flexible than that. It doesn't exactly have
Dale> standard defined fonts. You can change and extend the font
Dale> definitions yourself by changing the font'properties files. A
Dale> logical font like dialog in Java isn't even necessarily a
Dale> single font. It can be a combination of fonts over various
Dale> ranges.



Okay, thanks for the information, and likewise all to all the other
people who have offered.

I am reaching the conclusion here that while it would be possible to
install fonts with support for the braille glyphs, its actually going
to be easier to just draw them by hand. I think I could probably get
them installed on my development machine, but is anyone else going to
do this?

Still the information is useful. Braille glyphs are easy to draw, but
this is not true in general. Were they more complex, then going to
route of existing fonts would clearly be the way.

Cheers

Phi
 
J

Jon A. Cruz

Phillip said:
I am reaching the conclusion here that while it would be possible to
install fonts with support for the braille glyphs, its actually going
to be easier to just draw them by hand. I think I could probably get
them installed on my development machine, but is anyone else going to
do this?


Given that Braille fonts are relatively small (small number of
characters, etc), dynamically loading the font via
java.awt.Font.createFont() could be the way to go.
 

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

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top