Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Testing for Unicode support in an SWT font
Testing for Unicode support in an SWT font [message #457454] Sat, 25 June 2005 09:44 Go to next message
Dan Winterstein is currently offline Dan WintersteinFriend
Messages: 33
Registered: July 2009
Member
How can you test for Unicode support in an SWT font?
That is, test whether a font has a glyph for a character, or will it
just draw a box.
In an AWT Font, you can call the canDisplay(char c) method. Is there an
SWT equivalent?
Thank you for any help.
-Dan
Re: Testing for Unicode support in an SWT font [message #457458 is a reply to message #457454] Sat, 25 June 2005 11:43 Go to previous message
Dan Winterstein is currently offline Dan WintersteinFriend
Messages: 33
Registered: July 2009
Member
The following is ugly but works:

/**
* Test whether or not a font can display a specific unicode character.
* This creates and disposes an awt font, so it is probably not
efficient. Caching the answers is recommended.
*/
public static boolean unicodeCharTest(Font swtFont, char c) {
FontData fd = swtFont.getFontData()[0];
java.awt.Font awtFont = new java.awt.Font(fd.getName(),0,fd.getHeight());
return awtFont.canDisplay(c);
}


Daniel Winterstein wrote:
> How can you test for Unicode support in an SWT font?
> That is, test whether a font has a glyph for a character, or will it
> just draw a box.
> In an AWT Font, you can call the canDisplay(char c) method. Is there an
> SWT equivalent?
> Thank you for any help.
> -Dan
Previous Topic:noob swt canvas question
Next Topic:Bug in Text.setSelection?
Goto Forum:
  


Current Time: Thu Apr 25 09:42:40 GMT 2024

Powered by FUDForum. Page generated in 0.02652 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top