Community
Participate
Working Groups
Build Identifier: 3.7m3 Mac Cocoa 32-bit: When double-buffering, the text appears lighter than when drawing direct to screen. See example below Reproducible: Always Steps to Reproduce: import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class TestCanvas { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Canvas canvas = new Canvas(shell, SWT.NONE); FontData fd = new FontData("Lucida Grande", 16, SWT.NORMAL); final Font font = new Font(display, fd); final Image buffImg = new Image(display, 300, 100); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { drawText(e.gc); GC buffGC = new GC(buffImg); drawText(buffGC); buffGC.dispose(); e.gc.drawImage(buffImg, 0, 50); } private void drawText(GC gc) { gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); gc.fillRectangle(0, 0, 300, 100); gc.setFont(font); gc.drawString("Bennie And The Jets", 20, 20); } }); shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } font.dispose(); display.dispose(); } }
Yes, this is 329569, just fixed late last week. *** This bug has been marked as a duplicate of bug 329569 ***
Hi Scott - Are you sure this is related to bug 329569? When I run the snippet from this bug on build N20101109-2100 using OSX 10.6.4 it still shows that the 'image GC' text is much lighter than the 'screen GC'...? Thanks Mark
(In reply to comment #2) > Hi Scott - > > Are you sure this is related to bug 329569? When I run the snippet from this > bug on build N20101109-2100 using OSX 10.6.4 it still shows that the 'image GC' > text is much lighter than the 'screen GC'...? That's odd -- I'm using 10.6.4 as well. I used xScope (magnifier/color inspector tool) to compare the blues and they're identical now, whereas before the fix the blue pixels had different values.
Sorry for the misunderstanding - that is my fault. What I meant is that the text font looks different depending on whether it was drawn to the image or screen (the background color is fine). The text drawn to the image GC is so thin that it looks like a different font. This is causing me a problem because I have a custom widget which draws some parts directly to the screen, but double-buffers other parts. This makes the widget look a little odd. Thanks
OK, I understand now. I'll look at it again. The color difference came to light a day or so after your bug came in, which is probably why I assumed it was related.
Are you using 10.5 or 10.6? Lately that seems to be an important point.
Created attachment 182964 [details] Screenshot showing different text
I'm running OSX 10.6.4 ('Snow Leopard'). I've attached screenshots showing what the output of the example program looks like to me. Are you able to reproduce this problem?
(In reply to comment #8) > I'm running OSX 10.6.4 ('Snow Leopard'). I've attached screenshots showing > what the output of the example program looks like to me. Are you able to > reproduce this problem? If I turn off the 'Use LCD font smoothing when available' option in the Appearance preference panel the top line does look thinner for me, but it's nowhere near as dramatic as your screen shot. It is slightly different, though.
Created attachment 183018 [details] My screen shot
Wow - if I *untick* the 'Use LCD font smoothing when available' setting then the snippet works fine and there is no difference between the top and bottom text. After a bit of digging it seems this issue has something to do with what type of monitor you are using: http://www.macworld.com/article/145157/2009/12/smoothsnow.html One insightful comment is on this page: http://forums.macrumors.com/showthread.php?t=774761 "You're NOT supposed to combine sub-pixel anti-aliasing and regular anti-aliasing. It makes all the text look bold, especially light text on a dark background. That's because it's being anti-aliased twice. If you want your text to render properly, turn OFF sub-pixel anti-aliasing. Sure, it sounds cool, but it's actually really terrible, and distorts your text." I guess you can close this as being an OSX bug and not an SWT bug.
(In reply to comment #11) > Wow - if I *untick* the 'Use LCD font smoothing when available' setting then > the snippet works fine and there is no difference between the top and bottom > text. > > After a bit of digging it seems this issue has something to do with what type > of monitor you are using: > http://www.macworld.com/article/145157/2009/12/smoothsnow.html > > I guess you can close this as being an OSX bug and not an SWT bug. Well, maybe not so fast here... I think this is related to color premultiplication in NSBitmapImageRep. I made a change to how we created the bitmap that backs an Image when you call "new Image(display, height, width)", and that makes the two strings draw identically, with no difference in any of the pixel values. Unfortunately it won't work in 10.5, and also breaks too many other things. In any event, I'm going to mark this as a duplicate of bug 272592, since that bug is tracking the same problem in a different way. *** This bug has been marked as a duplicate of bug 272592 ***