Bug 92202 - Win32 printing surface can fail if rotation transforms are used
Summary: Win32 printing surface can fail if rotation transforms are used
Alias: None
Product: cairo
Classification: Unclassified
Component: win32 backend (show other bugs)
Version: unspecified
Hardware: Other Windows (All)
: medium normal
Assignee: Adrian Johnson
QA Contact: cairo-bugs mailing list
Depends on:
Reported: 2015-09-30 17:30 UTC by Lee Salzman
Modified: 2015-10-20 19:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

fix rotated strokes and images in Win32 printing surfaces (4.64 KB, text/plain)
2015-09-30 17:30 UTC, Lee Salzman

Description Lee Salzman 2015-09-30 17:30:35 UTC
Created attachment 118551 [details]
fix rotated strokes and images in Win32 printing surfaces

In Firefox, we noticed that when printing a PDF including rotations from pdf.js that both images and stroked paths would fail to show up in many print drivers.

We tracked this down to two bugs in cairo-win32-printing-surface.c.

The first bug is that stroked path are both being transformed by Cairo with the CTM, and then later again by supplying the CTM to GDI when StrokePath is called. Some print drivers ignore the transform and appear to work, others honor the transform and stuff fails to work, since the path is then double-transformed. So we just removed the big about supplying the transform to GDI and all is well again.

The second bug involves image patterns. StretchDIBits under some printing devices is simply broken if you give it a rotation transform. As a simple workaround that we found worked on all printer drivers we tested with, we just swap the X and Y axes of the image before giving it to StretchDIBits, so the rotation transform becomes a harmless scale and/or mirror that the drivers will honor.

Between these two, pdf.js printing resumed working for us.

The upstream Firefox bug report is here:

We've attached our patch that resolves the issue and it would be nice if we could get this upstreamed.
Comment 1 Adrian Johnson 2015-10-04 12:40:50 UTC
I've added some comments to the upstream bug.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.