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

Bug 342881

Summary: Unequal tab(\t) width in StyledText
Product: [Technology] SWTBot Reporter: phuc.ly
Component: SWTBotAssignee: Project Inbox <swtbot-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description phuc.ly CLA 2011-04-14 14:58:26 EDT
Build Identifier: 20110218-0911

First of all forgive me if I post this in the wrong section.  This is the first time I report a bug.
In 2006 Sunil Kamath reported the non legitimate bug about unequal tab and it was rejected.  But it seems to be a real bug.  
I generated a list of characters with tab between them and it shows that StyledText does not account for the actual character width in each character.  For example, the position of next tab stop on a line that have "llll" would be before those that have "mmmmm" or "WWWWW".  See steps to produce for details.


Reproducible: Always

Steps to Reproduce:
1. Copy the SampleStyledText from http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SampleStyledText.htm
2. replace the line "styledText.setText("123456789\r\nABCDEFGHI");" with the following:
styledText.setTabs(10);
    styledText.setText("Text with Courier New\r\n");
    styledText.append("22222\tl\r\n");
    styledText.append("lllll\tl\r\n");
    styledText.append("mmmmm\tl\r\n");
    styledText.append("WWWWW\tl\r\n");
    
    font = new Font(shell.getDisplay(), "Tahoma", 12, SWT.NORMAL);
    styledText.setFont(font);
    styledText.append("Text with Tahoma\r\n");
    styledText.append("22222\tl\r\n");
    styledText.append("lllll\tl\r\n");
    styledText.append("mmmmm\tl\r\n");
    styledText.append("WWWWW\tl\r\n");
    
    font = new Font(shell.getDisplay(), "Arial", 12, SWT.NORMAL);
    styledText.setFont(font);
    styledText.append("Text with Arial\r\n");
    styledText.append("22222\tl\r\n");
    styledText.append("lllll\tl\r\n");
    styledText.append("mmmmm\tl\r\n");
    styledText.append("WWWWW\tl\r\n");


3. Run it.