Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342881 - Unequal tab(\t) width in StyledText
Summary: Unequal tab(\t) width in StyledText
Status: NEW
Alias: None
Product: SWTBot
Classification: Technology
Component: SWTBot (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-14 14:58 EDT by phuc.ly CLA
Modified: 2011-04-14 14:58 EDT (History)
0 users

See Also:


Attachments

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