Community
Participate
Working Groups
Build Identifier: M20110909-1335 Due to a fix in Printer made in Eclipse 3.7 as part of Bug 150870 the scaling of SWTGraphics is now broken. This is due to the fact that now some pre-scaling is being done in Printer#internal_new_GC: Cairo.cairo_translate(cairo, printX, printY); Cairo.cairo_scale(cairo, screenDPI.x / (float)dpi.x, screenDPI.y / (float)dpi.y); Doing SWTGraphics#scale will initialize a new Transform which is not multiplied with the one already set in the above method. So for example doing SWTGraphics#scale(1) changes the scale although the method should have no effect. There also a translate that I am sure is being lost too. I don't know if the fix should be in SWT for Draw2d but I though you should know about this issue. Currently I am doing transform multiplication manually to fix the bug in Eclipse 3.7. Reproducible: Always
Added dependency to #150870.
How can SWTGraphics be affected by changes to Printer? I suppose you mean ScaledGraphics?
Alexander, I am using SWTGraphics with Printer for native scaling which gets better results. I use code that looks something like this: printer.startPage(); GC gc = new GC(printer); Graphics graphics = new SWTGraphics(gc); Actually I have a PrinterGraphics subclass, similar to one based on ScaledGraphics, that does some device resource handling.
But the bug is not specific to scaling as it can be triggered by anything that sets a new Transform on GC: a non-integer translation or a rotation. So it should be also present in PrinterGraphics found in Draw2d.
Hi, Peter. Would you be able to provide an SWT-only test case? It would save us some time looking at the problem and testing what we think might be a possible fix. Thanks!
Created attachment 206526 [details] SWT-only test case I adapted on of the SWT snippets to show the bug. Normally this code should print two identical lines one below the other. However on Eclipse 3.7 the second line will be much bigger, depending on the Printer DPI / 72.0f ratio.
Thank-you, Peter! Reassigning to SWT.
Fixed in master: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=84b7f4eb839c40c67c06cf1cb3c34b24bf589c5a
Great, Carolyn! Will it be backported to 3.7/3.8 versions? I don't need it but just want to know from which version I can disable my workaround.
Backported to 3.7: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R3_7_maintenance&id=da1f7fdabbd2b4b4a76e6e27218cef07f95be1ce It is already in 3.8 because (most of) the SWT source for 3.8 and 4.2 are the same.