Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to correctly display the Angstrom symbol ?(The circle on top of the Angstrom symbol is always cut in my label)
How to correctly display the Angstrom symbol ? [message #518581] Thu, 04 March 2010 14:46 Go to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
Hi,

I'm trying to display the Angstrom symbol in a Label. The problem I have is that the little circle among the capital "A" is always cut, even if I use a "grabbing" GridData or if I set it to a specific height (heightHint).

Here is my snippet:

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
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 FillLayout());

		Composite composite = new Composite(shell, SWT.NONE);
		composite.setLayout(new GridLayout());

		String angstrom = "\u00C5";

		Label label = new Label(composite, SWT.LEFT | SWT.WRAP);
		label.setText("the Angstrom symbol is " + angstrom);
		label.setLayoutData(getGridData());
		label.setBackground(display.getSystemColor(SWT.COLOR_CYAN));


		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;
	}


Thanks in advance for your help
Helene
Re: How to correctly display the Angstrom symbol ? [message #518740 is a reply to message #518581] Thu, 04 March 2010 20:46 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
To clarify, you're saying that the top of circle gets cut? Which platform
do you see this on? Running your snippet seemed fine for me on Windows
2000, Ubuntu 9.10 and OS X (actually it looked slightly cheesy on OS X but
this wasn't due to space constraints).

Grant


"H.ORTIZ" <hortiz@objetdirect.com> wrote in message
news:hmoh4q$l35$1@build.eclipse.org...
> Hi,
>
> I'm trying to display the Angstrom symbol in a Label. The problem I have
is that the little circle among the capital "A" is always cut, even if I use
a "grabbing" GridData or if I set it to a specific height (heightHint).
>
> Here is my snippet:
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> 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 FillLayout());
>
> Composite composite = new Composite(shell, SWT.NONE);
> composite.setLayout(new GridLayout());
>
> String angstrom = "\u00C5";
>
> Label label = new Label(composite, SWT.LEFT | SWT.WRAP);
> label.setText("the Angstrom symbol is " + angstrom);
> label.setLayoutData(getGridData());
> label.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
>
>
> 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;
> }
>
>
> Thanks in advance for your help
> Helene
>
Re: How to correctly display the Angstrom symbol ? [message #518816 is a reply to message #518740] Fri, 05 March 2010 07:46 Go to previous messageGo to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
Hi Grant,

I use Linux with Suse version 11 and my version of the SWT library is 3.4.
I'm going to test with the last version of SWT (3.5.2).


Re: How to correctly display the Angstrom symbol ? [message #518824 is a reply to message #518816] Fri, 05 March 2010 08:29 Go to previous messageGo to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
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

Re: How to correctly display the Angstrom symbol ? [message #518964 is a reply to message #518824] Fri, 05 March 2010 14:54 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
What does " System.out.println(label.getFont().getFontData()[0].toString ()); "
print for you? On my RHEL4 machine, where your snippet looks fine, this is
1|Sans|10.0|0|GTK|1|. Can you see if it looks better for you if you set the
Label's font to this?

label.setFont(new Font(display, "Sans", 10, 0)); // just leaking the font

Grant


"H.ORTIZ" <hortiz@objetdirect.com> wrote in message
news:hmqfdi$isl$1@build.eclipse.org...
> The problem remains with the last version of SWT.
Re: How to correctly display the Angstrom symbol ? [message #518986 is a reply to message #518964] Fri, 05 March 2010 16:00 Go to previous messageGo to next message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
Grant,

System.out.println(label.getFont().getFontData()[0].toString ());


prints : 1|Sans|10.0|0|GTK|1|

and it does not work either if I set the font as you adviced.

Thanks

Re: How to correctly display the Angstrom symbol ? [message #520895 is a reply to message #518986] Mon, 15 March 2010 16:43 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
I've asked around about this, and the original thought was that if Sans does
not contain this symbol then perhaps it was being substituted from another
font on your OS with different metrics. However it looks like this symbol
is supposed to be in Sans, so there shouldn't be a substitution happening.
The only other thing I can think of is a difference in the pango versions on
SuSE 11 and RHEL4. There's a SuSE 11 machine here, but it's currently not
available. I'll give your snippet a try there when I get a chance, to see
what happens.

Grant


"H.ORTIZ" <hortiz@objetdirect.com> wrote in message
news:hmr9qv$25r$1@build.eclipse.org...
> Grant,
>
>
> System.out.println(label.getFont().getFontData()[0].toString ());
>
>
> prints : 1|Sans|10.0|0|GTK|1|
>
> and it does not work either if I set the font as you adviced.
>
> Thanks
>
>
Re: How to correctly display the Angstrom symbol ? [message #521941 is a reply to message #520895] Fri, 19 March 2010 12:09 Go to previous message
H.ORTIZ  is currently offline H.ORTIZ Friend
Messages: 22
Registered: July 2009
Junior Member
thanks for your help Grant
Previous Topic:Windows Transparent
Next Topic:Ton futur PC
Goto Forum:
  


Current Time: Sun Aug 18 05:34:54 GMT 2019

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

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

Back to the top