Community
Participate
Working Groups
I use a StyledText to show text in my application. StyledText text = new StyledText(shell, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); And I set the font like: FontData data = text.getFont().getFontData()[0]; Font font1 = new Font(text.getDisplay(),data.getName(),data.getHeight() *5 /4 , data.getStyle()); StyleRange[] styles = new StyleRange[1]; styles[0] = new StyleRange(); styles[0].font = font1; styles[0].fontStyle = SWT.NORMAL; int[] ranges = new int[]{0,text.getText().length()}; text.setStyleRanges(ranges,styles); On Win7 or Vista, if the content of text is longer, some words will be covered by the vertical scroll bar. Please find the attachment. Everything seems OK on XP.
Created attachment 191483 [details] the screen shot
Can you please attach a snippet that I can run here and reproduce the problem ? It works for me with examples I have here. Note: you should not set styles[0].font = font1; styles[0].fontStyle = SWT.NORMAL; at the same time, do not set fontStyle and font is being used. and, if you always going to apply the same font for the entire text, just use StyledText#setFont(). Based on your example, you do not need a StyledText, just Text should be enough for what you are trying to do.
package test; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Test { public static void main(String[] args) { Display dis = new Display(); Shell shell = new Shell(dis); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY); //set the style text.setLeftMargin(10); // left margin text.setTopMargin(10); //top margin text.setLineSpacing(2); //line spacing FontData data = new FontData(); text.setFont(new Font(dis, data)); text.append("http://pinyin.sogou.com/features/?v=5.2.0.5225&h=2B6168D8A8BFDBA33D1FE8C9D37C1F5B&r=5298_sogou_pinyin_51_5298&f=tcFeatures"); shell.setSize(250, 200); shell.open(); while(!shell.isDisposed()){ if(!dis.readAndDispatch()){ dis.sleep(); } } dis.dispose(); } } Run it in Windows XP, it works, but not looks so well in Vista or WIN7. I want to show the content in the StyledText with left and top margins, and want to show it with a bigger font. Please check.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. If the bug is still relevant please remove the stalebug whiteboard tag.