Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359101 - StyledText - line for underlined text with a 'rise' other than zero is not shifted
Summary: StyledText - line for underlined text with a 'rise' other than zero is not sh...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-27 11:50 EDT by Radu Vlasov CLA
Modified: 2012-04-25 11:03 EDT (History)
4 users (show)

See Also:


Attachments
StyledText when rendered on screen (740 bytes, image/png)
2011-09-27 11:52 EDT, Radu Vlasov CLA
no flags Details
patch fix for underline and strikeout shift when 'rise' is used (3.79 KB, patch)
2011-10-04 12:59 EDT, George Cheng CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.