Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Unicode >16 Bit JTextPane etc.. Date: Sun, 09 Jun 2013 09:35:08 +0200 Organization: albasani.net Lines: 64 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net PX6iJwaanf8mYX6gXXlw7rOCXc/989N40DmlLAoaXYPBKEH4v13xSGIxcnjEXU20zfN04eqPs4stvGePuBpiXA== NNTP-Posting-Date: Sun, 9 Jun 2013 07:35:09 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="t4Rr12pTx7AkUsEzTvtu7maJzaflqAoLbqjrygirc2MQgdakW0wzLBaHLHI5sUvtg28MFqHPMxPo3g1p+zco2ICjqBIbC8C/kYqMfocSgBvxxN85J/XFfbxfWRbtoKRn"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0 SeaMonkey/2.17.1 In-Reply-To: Cancel-Lock: sha1:uR7JqAIUwM3V3lNU/KwrJBUKxNI= Xref: csiph.com comp.lang.java.programmer:24342 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(); > } > } ); > } > } >