Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 446182

Summary: Label sizes calculated wrong for some fonts on Chrome
Product: [RT] RAP Reporter: John Gymer <jgymer>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan, rsternberg
Version: 2.3   
Target Milestone: 3.0 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard: sr232

Description John Gymer CLA 2014-10-07 11:34:44 EDT
RAP appears to calculate the width/height of a Label incorrectly on Chrome (37) for certain fonts.
I used "Bauhaus 93" font, and for an instance the Label displays the full text, then after a momentary delay, it shrinks the size of the Label hiding the last word of text in the Label as a consequence.

Here is a snippet:
/* DEMONSTRATES RAP issue with unusual font sizes/styles - label not big enough */
package bug.snippet;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class Bugsy {
	private Display display;
	private Shell shell;
	private static Label lab;
	
	public void begin() {
		System.out.println("BugSnippy Starting...");
		
		// create the Shell
		display = new Display();
		shell = new Shell(display, SWT.TITLE|SWT.CLOSE|SWT.RESIZE);
		shell.setText("Shell");
		shell.setFullScreen(true);
		shell.setBackground(new Color(null, new RGB(255,192,255)));
		FormLayout layout = new FormLayout();
		shell.setLayout(layout);

		//create the label
		lab = new Label(shell, SWT.NONE);
		lab.setText("Wonderful stuff is great and fab");

		FontData fontData;
		fontData = new FontData();
		fontData.setName("Bauhaus 93");
		fontData.setStyle(SWT.NONE);
		fontData.setHeight(20);
		Font font = new Font(display, fontData);
		
		lab.setFont(font);

		//set label's position
		FormData fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.top = new FormAttachment(0, 50);
		lab.setLayoutData(fd);

		shell.open();

		System.out.println("BugSnippy Done!");
	}

}

See forum issue for screen shot:
https://www.eclipse.org/forums/index.php?t=msg&th=823251&

Specific to Chrome and Bauhau93 font!

Thanks, John
Comment 1 Ivan Furnadjiev CLA 2014-10-08 03:54:16 EDT
Strange... if you add another dummy empty label the measurement is correct. Still under investigation why the client measure the size of this element wrong.
Comment 2 Ivan Furnadjiev CLA 2014-10-09 08:24:28 EDT
Actually, the issue is related to fonts with spaces in their names. There is a bug in FontSizeCalculation.js#_measureItem where the array with font names sent by the server is not correctly converted to valid CSS font family.
Comment 3 Ivan Furnadjiev CLA 2014-10-10 04:19:28 EDT
Pending change - https://git.eclipse.org/r/#/c/34649/.
Comment 4 Ivan Furnadjiev CLA 2014-10-10 05:13:50 EDT
Fixed in master with change – https://git.eclipse.org/r/#/c/34649/.
Comment 5 Ralf Sternberg CLA 2015-01-27 05:40:08 EST
+1 for backporting to 2.3.2
Comment 6 Ivan Furnadjiev CLA 2015-01-28 05:21:50 EST
Backported to 2.3-maintenance branch with change https://git.eclipse.org/r/40523