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

Bug 359101

Summary: StyledText - line for underlined text with a 'rise' other than zero is not shifted
Product: [Eclipse Project] Platform Reporter: Radu Vlasov <vlasov.r>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse.felipe, Silenio_Quarti, y29cheng
Version: 4.1   
Target Milestone: 3.8 M3   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
StyledText when rendered on screen
none
patch fix for underline and strikeout shift when 'rise' is used none

Description Radu Vlasov CLA 2011-09-27 11:50:07 EDT
Build Identifier: I20110620-1631

In StyledText when a range of characters are underlined and in the same time have a 'rise' attribute different than zero, the line is drawn as if 'rise' would be zero.

The same thing happens for strikeout.

Reproducible: Always

Steps to Reproduce:
StyledText st = new StyledText (parentComposite, SWT.NORMAL);

st.setText ("ABCDE");
      
StyleRange sr = new StyleRange ();

sr.start          = 1;
sr.length         = 3;
sr.underlineStyle = SWT.UNDERLINE_SINGLE;
sr.underline      = true;
sr.rise           = +20;

st.setStyleRange (sr);
Comment 1 Radu Vlasov CLA 2011-09-27 11:52:58 EDT
Created attachment 204098 [details]
StyledText when rendered on screen
Comment 2 Felipe Heidrich CLA 2011-10-03 14:37:03 EDT
Indeed, this is a testcode
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.addListener(SWT.Paint, new Listener() {
		public void handleEvent(Event e) {
			TextLayout layout = new TextLayout(e.display);
			String underline = "underline";
			String strike = "strike";		
			layout.setText("abc"+underline+"abc"+strike+"abc");
			TextStyle style0 = new TextStyle();
			style0.underline = true;
			style0.rise = +20;
			TextStyle style1 = new TextStyle();
			style1.strikeout = true;
			style1.rise = +20;
			int index = layout.getText().indexOf(underline);
			layout.setStyle(style0, index, index + underline.length()-1);
			index = layout.getText().indexOf(strike);
			layout.setStyle(style1, index, index + strike.length()-1);
			layout.draw(e.gc, 10, 10);
		}
	});
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
Comment 3 Felipe Heidrich CLA 2011-10-03 14:41:41 EDT
George, can you fix this for me ?
Comment 4 George Cheng CLA 2011-10-04 12:59:38 EDT
Created attachment 204526 [details]
patch fix for underline and strikeout shift when 'rise' is used
Comment 6 Dani Megert CLA 2012-04-25 03:07:46 EDT
(In reply to comment #5)
> Good work
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=e9f12754015493ac55bc996c9b2b653951ebc7cd

Actually, not so good. The fix causes bug 377472 and should be reverted.
Comment 7 Dani Megert CLA 2012-04-25 11:03:10 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > Good work
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=e9f12754015493ac55bc996c9b2b653951ebc7cd
> 
> Actually, not so good. The fix causes bug 377472 and should be reverted.

Sorry, all is good. I picked the wrong bug.