Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Unicode >16 Bit JTextPane etc.. Date: Sun, 09 Jun 2013 00:23:01 -0700 Organization: A noiseless patient Spider Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 9 Jun 2013 07:18:22 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="fba3415ba68d85d643935af2f52f0b4b"; logging-data="9590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193mgc69NAnkf5PH16rlyLDy4LBeUp1Ofg=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: Cancel-Lock: sha1:uYm2Rn0jma0oBHIGLGEkjXWcVmU= Xref: csiph.com comp.lang.java.programmer:24341 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(); } } ); } }