|
|
|
Re: How to correctly display the Angstrom symbol ? [message #518824 is a reply to message #518816] |
Fri, 05 March 2010 08:29 |
H.ORTIZ Messages: 22 Registered: July 2009 |
Junior Member |
|
|
The problem remains with the last version of SWT.
But I found something really strange: if I use a font height greater or equal to 15 it works. Here is a new snippet which shows this:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class DemoProblemWithAngstrom {
public static void main(String[] args) {
new DemoProblemWithAngstrom().run();
}
private void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(getGridData());
String angstrom = "\u00C5";
Font font14 = new Font(display, new FontData("Sans", 14, SWT.NONE));
Font font15 = new Font(display, new FontData("Sans", 15, SWT.NONE));
Label label = new Label(composite, SWT.LEFT | SWT.WRAP);
label.setFont(font14);
label.setText("the Angstrom symbol is " + angstrom);
label.setLayoutData(getGridData());
label.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
Label label2 = new Label(composite, SWT.LEFT | SWT.WRAP);
label2.setFont(font15);
label2.setText("the Angstrom symbol is " + angstrom);
label2.setLayoutData(getGridData());
label2.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
shell.setSize(400, 200);
shell.layout();
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose ();
}
public GridData getGridData() {
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
return gridData;
}
}
[Updated on: Fri, 05 March 2010 09:27] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07049 seconds