Unicode >16 Bit JTextPane etc..

Discussion in 'Java' started by Jan Burse, Jun 8, 2013.

  1. Jan Burse

    Jan Burse Guest

    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.
    Jan Burse, Jun 8, 2013
    #1
    1. Advertising

  2. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 07:42 AM, Jan Burse wrote:
    > Jan Burse schrieb:
    >> 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.

    >
    > 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.
    Jeff Higgins, Jun 8, 2013
    #2
    1. Advertising

  3. Jan Burse

    Joerg Meier Guest

    On Sat, 08 Jun 2013 10:31:27 -0400, Jeff Higgins wrote:

    > What's a 16 bit JTextPane?


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

    Liebe Gruesse,
    Joerg

    --
    Ich lese meine Emails nicht, replies to Email bleiben also leider
    ungelesen.
    Joerg Meier, Jun 8, 2013
    #3
  4. Jan Burse

    Jan Burse Guest

    Jeff Higgins schrieb:
    > On 06/08/2013 07:42 AM, Jan Burse wrote:
    >> Jan Burse schrieb:
    >>> 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.

    >>
    >> 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.


    [...]
    JTextPane t = new JTextPane();
    t.setText("\uD835\uDCC0");
    [...]
    Jan Burse, Jun 8, 2013
    #4
  5. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 02:35 PM, Joerg Meier wrote:
    > On Sat, 08 Jun 2013 10:31:27 -0400, Jeff Higgins wrote:
    >
    >> What's a 16 bit JTextPane?

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


    Ah. That makes sense.
    Thanks.
    Jeff Higgins, Jun 8, 2013
    #5
  6. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 06:15 PM, Jan Burse wrote:
    > Jeff Higgins schrieb:
    >> On 06/08/2013 07:42 AM, Jan Burse wrote:
    >>> Jan Burse schrieb:
    >>>> 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.
    >>>
    >>> 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.

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

    Sorry, too much trouble for me to wrap into compilable block.
    Jeff Higgins, Jun 8, 2013
    #6
  7. Jan Burse

    Jan Burse Guest

    Jan Burse, Jun 8, 2013
    #7
  8. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 06:25 PM, Jan Burse wrote:
    > Jeff Higgins schrieb:
    >>> [...]
    >>> 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.
    Jeff Higgins, Jun 9, 2013
    #8
  9. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 09:50 PM, Martin Gregorie wrote:
    > On Sun, 09 Jun 2013 11:42:23 +1000, Qu0ll wrote:
    >
    >> "Jeff Higgins" wrote in message news:kp0j0h$k1f$...
    >>
    >>> 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].
    Jeff Higgins, Jun 9, 2013
    #9
  10. Jan Burse

    Sven Köhler Guest

    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
    Sven Köhler, Jun 9, 2013
    #10
  11. On 6/8/2013 1:35 PM, Joerg Meier wrote:
    > On Sat, 08 Jun 2013 10:31:27 -0400, Jeff Higgins wrote:
    >
    >> What's a 16 bit JTextPane?

    >
    > 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.

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
    Joshua Cranmer ðŸ§, Jun 9, 2013
    #11
  12. Jan Burse

    Jeff Higgins Guest

    On 06/08/2013 10:48 PM, Jeff Higgins wrote:
    > On 06/08/2013 09:50 PM, Martin Gregorie wrote:
    >> On Sun, 09 Jun 2013 11:42:23 +1000, Qu0ll wrote:
    >>
    >>> "Jeff Higgins" wrote in message news:kp0j0h$k1f$...
    >>>
    >>>> 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>
    Jeff Higgins, Jun 9, 2013
    #12
  13. Jan Burse

    markspace Guest

    On 6/8/2013 9:16 PM, Jeff Higgins wrote:
    >
    > 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();
    }
    } );
    }
    }
    markspace, Jun 9, 2013
    #13
  14. Jan Burse

    Jan Burse Guest

    Thank you very much.
    This is very interesting.
    Didn't use canDisplay() so far.

    markspace schrieb:
    > On 6/8/2013 9:16 PM, Jeff Higgins wrote:
    >>
    >> 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();
    > }
    > } );
    > }
    > }
    >
    Jan Burse, Jun 9, 2013
    #14
  15. Jan Burse

    Jan Burse Guest

    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.

    markspace schrieb:
    > On 6/8/2013 9:16 PM, Jeff Higgins wrote:
    >>
    >> 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();
    > }
    > } );
    > }
    > }
    >
    Jan Burse, Jun 9, 2013
    #15
  16. Sun, 9 Jun 2013 11:42:23 +1000, /Qu0ll/:
    > "Jeff Higgins" wrote in message news:kp0j0h$k1f$...
    >
    >> 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.

    --
    Stanimir
    Stanimir Stamenkov, Jun 9, 2013
    #16
  17. Sun, 09 Jun 2013 17:37:42 +0300, /Stanimir Stamenkov/:
    > Sun, 9 Jun 2013 11:42:23 +1000, /Qu0ll/:
    >> "Jeff Higgins" wrote in message news:kp0j0h$k1f$...
    >>
    >>> 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

    --
    Stanimir
    Stanimir Stamenkov, Jun 9, 2013
    #17
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    4,370
  2. Replies:
    3
    Views:
    1,700
    Timothy Bendfelt
    Jan 19, 2007
  3. Replies:
    9
    Views:
    915
    Juha Nieminen
    Aug 22, 2007
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    361
    Fredrik Lundh
    Aug 13, 2008
  5. Jeff.M
    Replies:
    6
    Views:
    155
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page