Unicode >16 Bit JTextPane etc..

J

Jan Burse

Dear All,

I tried a couple of fonts, but none of
these fonts were able to display the
Unicode 120000 (decimal).

I supplied the two surrogate pairs
D835 and DCC0. The JTextPane etc.. show
a single box, so that I assume the
code point is recognized.

What is wrong?

Bye

P.S.: My browser (mozilla) easily
shows the Mathematical Script Small K
which corresponds to the code point.
 
J

Jeff Higgins

The white box is shown on Windows. On the
Mac some chinese or so is shown. But both
don't show Mathematical Script Small K.
What's a 16 bit JTextPane?
If you'll give a small demo code I'll try it
on Debian Squeeze and Windows 7,8, several JDK versions available.
Mathematical Script Small K shows up in gedit and a Mozilla browser here.
 
J

Jan Burse

Jeff said:
What's a 16 bit JTextPane?
If you'll give a small demo code I'll try it
on Debian Squeeze and Windows 7,8, several JDK versions available.
Mathematical Script Small K shows up in gedit and a Mozilla browser here.

[...]
JTextPane t = new JTextPane();
t.setText("\uD835\uDCC0");
[...]
 
J

Jeff Higgins

Jeff said:
What's a 16 bit JTextPane?
If you'll give a small demo code I'll try it
on Debian Squeeze and Windows 7,8, several JDK versions available.
Mathematical Script Small K shows up in gedit and a Mozilla browser here.

[...]
JTextPane t = new JTextPane();
t.setText("\uD835\uDCC0");
[...]
Sorry, too much trouble for me to wrap into compilable block.
 
J

Jeff Higgins

Jeff said:
[...]
JTextPane t = new JTextPane();
t.setText("\uD835\uDCC0");
[...]
Sorry, too much trouble for me to wrap into compilable block.

http://docs.oracle.com/javase/tutor...moProject/src/components/TextSamplerDemo.java

Wow! Really?

import javax.swing.*;

public class SmallDemo {

private JFrame frame = new JFrame("A Small Demo");
private JTextPane textpane = new JTextPane();

public SmallDemo() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textpane.setText("\uD835\uDCC0");
frame.add(textpane);
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
SmallDemo demo = new SmallDemo();
}
});
}
}

Works here. You're welcome.
 
J

Jeff Higgins

"Jeff Higgins" wrote in message

Not here. Same result as OP.

Windows 7 64-bit with Java 7 Update 21 64-bit.

Same here [little white square] running (Fedora 18 fully patched on
Friday, PAE kernel, Java 1.6.0_45).
Hmm. Shrugs. Java 1.7.0_21, Debian 6.0.7 works here [Mathematical Script
Small K].
 
S

Sven Köhler

Am 08.06.2013 14:29, schrieb Jan Burse:
P.S.: My browser (mozilla) easily
shows the Mathematical Script Small K
which corresponds to the code point.

So did you make sure that JTextPane and your Browser use the same font?
Did you try copy/pasting from your Browser to the JTextPane or the other
way round?


Regards,
Sven
 
J

Joshua Cranmer ðŸ§

I believe the topic is to be read as "a unicode symbol above 16 bit in a
regular JTextPane".

The proper terminology is "non-BMP character", such as what exists in my
From header.
 
J

Jeff Higgins

"Jeff Higgins" wrote in message
Works here. You're welcome.

Not here. Same result as OP.

Windows 7 64-bit with Java 7 Update 21 64-bit.

Same here [little white square] running (Fedora 18 fully patched on
Friday, PAE kernel, Java 1.6.0_45).
Hmm. Shrugs. Java 1.7.0_21, Debian 6.0.7 works here [Mathematical Script
Small K].

Just to be sure I was seeing what I was looking at, I've added:
....
textpane.setFont(new Font("Dialog", Font.PLAIN, 60));
textpane.setText("\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F");
....

Yep. a Mathematical Script kACD.

Here is a screenshot:
<http://picpaste.com/Screenshot-A_Small_Demo-LrwiLMJy.png>
 
M

markspace

textpane.setFont(new Font("Dialog", Font.PLAIN, 60));
textpane.setText("\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F")


This ends up printing Cambria Math for the font name on my system.


class SmallDemo
{

private JFrame frame = new JFrame( "A Small Demo" );
private JTextPane textpane = new JTextPane();
private static final String TEST =
"\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F";

public SmallDemo()
{
try {
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
Font usingFont = null;
for( Font font : allFonts ) {
if( font.canDisplay( 120000 ) ) {
usingFont = new Font( font.getFontName(), Font.PLAIN, 30 );
textpane.setFont( usingFont );
break;
}
}
textpane.setText( TEST );
StyledDocument doc = textpane.getStyledDocument();
doc.insertString( doc.getLength(), usingFont.getFontName(), null);
frame.add( textpane );
frame.pack();
frame.setVisible( true );
} catch( BadLocationException ex ) {
Logger.getLogger( SmallDemo.class.getName() ).log(
Level.SEVERE, null,
ex );
}
}

public static void main( String[] args )
{
SwingUtilities.invokeLater( new Runnable()
{
@Override
public void run()
{
SmallDemo demo = new SmallDemo();
}
} );
}
}
 
J

Jan Burse

Thank you very much.
This is very interesting.
Didn't use canDisplay() so far.
textpane.setFont(new Font("Dialog", Font.PLAIN, 60));
textpane.setText("\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F")


This ends up printing Cambria Math for the font name on my system.


class SmallDemo
{

private JFrame frame = new JFrame( "A Small Demo" );
private JTextPane textpane = new JTextPane();
private static final String TEST =
"\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F";

public SmallDemo()
{
try {
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
Font usingFont = null;
for( Font font : allFonts ) {
if( font.canDisplay( 120000 ) ) {
usingFont = new Font( font.getFontName(), Font.PLAIN, 30 );
textpane.setFont( usingFont );
break;
}
}
textpane.setText( TEST );
StyledDocument doc = textpane.getStyledDocument();
doc.insertString( doc.getLength(), usingFont.getFontName(),
null);
frame.add( textpane );
frame.pack();
frame.setVisible( true );
} catch( BadLocationException ex ) {
Logger.getLogger( SmallDemo.class.getName() ).log(
Level.SEVERE, null,
ex );
}
}

public static void main( String[] args )
{
SwingUtilities.invokeLater( new Runnable()
{
@Override
public void run()
{
SmallDemo demo = new SmallDemo();
}
} );
}
}
 
J

Jan Burse

Doesn't give something useful on Mac.

I get for (note the not before the canDisplay()):

public static void main(String[] args) {
Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int i = 0; i < allFonts.length; i++) {
Font font = allFonts;
if (!font.canDisplay(120000))
System.out.println("font=" + font.getFontName());
}
}

The following list:

font=Lucida Bright Demibold
font=Lucida Bright Demibold Italic
font=Lucida Bright Italic
font=Lucida Bright Regular
font=Lucida Sans Demibold
font=Lucida Sans Regular
font=Lucida Sans Typewriter Bold
font=Lucida Sans Typewriter Regular

But every font not on the above list, does erroreously
display some chinese character instead of the math symbol.

The fonts on the above list, on the other hand seem
to show a white box on the Mac.

Bye


P.S.: I am using 1.7.0_15. Let me try a newer version.
textpane.setFont(new Font("Dialog", Font.PLAIN, 60));
textpane.setText("\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F")


This ends up printing Cambria Math for the font name on my system.


class SmallDemo
{

private JFrame frame = new JFrame( "A Small Demo" );
private JTextPane textpane = new JTextPane();
private static final String TEST =
"\uD835\uDCC0\uD835\uDC9C\uD835\uDC9E\uD835\uDC9F";

public SmallDemo()
{
try {
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
Font usingFont = null;
for( Font font : allFonts ) {
if( font.canDisplay( 120000 ) ) {
usingFont = new Font( font.getFontName(), Font.PLAIN, 30 );
textpane.setFont( usingFont );
break;
}
}
textpane.setText( TEST );
StyledDocument doc = textpane.getStyledDocument();
doc.insertString( doc.getLength(), usingFont.getFontName(),
null);
frame.add( textpane );
frame.pack();
frame.setVisible( true );
} catch( BadLocationException ex ) {
Logger.getLogger( SmallDemo.class.getName() ).log(
Level.SEVERE, null,
ex );
}
}

public static void main( String[] args )
{
SwingUtilities.invokeLater( new Runnable()
{
@Override
public void run()
{
SmallDemo demo = new SmallDemo();
}
} );
}
}
 
S

Stanimir Stamenkov

Sun, 9 Jun 2013 11:42:23 +1000, /Qu0ll/:
"Jeff Higgins" wrote in message
textpane.setText("\uD835\uDCC0");
[...]
Works here. You're welcome.

Not here. Same result as OP.

Windows 7 64-bit with Java 7 Update 21 64-bit.

I don't see the character rendered with the expected glyph by my
side, but I see a single rectangle box rendered which deems the text
component is doing its job right by interpreting the surrogate pair
as a single character.
 
S

Stanimir Stamenkov

Sun, 09 Jun 2013 17:37:42 +0300, /Stanimir Stamenkov/:
Sun, 9 Jun 2013 11:42:23 +1000, /Qu0ll/:
"Jeff Higgins" wrote in message
textpane.setText("\uD835\uDCC0");
[...]
Works here. You're welcome.

Not here. Same result as OP.

Windows 7 64-bit with Java 7 Update 21 64-bit.

I don't see the character rendered with the expected glyph by my
side, but I see a single rectangle box rendered which deems the text
component is doing its job right by interpreting the surrogate pair
as a single character.

Using "Symbola" or "Cambria Math" which appear to contain glyph for
the character on my system:

textpane.setFont(new Font("Symbola", Font.PLAIN, 24));

I see the character all right now, too. I use an utility called
"BabelMap" to find and analyze fonts under Windows.

http://www.babelstone.co.uk/Software/BabelMap.html
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top