Bug 24240

Summary: PDF backend seems to rasterize when drawing to group
Product: cairo Reporter: Ken Treis <ken>
Component: pdf backendAssignee: Adrian Johnson <ajohnson>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: 1.8.8   
Hardware: x86-64 (AMD64)   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Test program
Output from cairo 1.8.8
Output from current git (1.9.3)
Screenshot of preview showing 1.9.3 output
output from current git with bug fix

Description Ken Treis 2009-09-30 17:50:53 UTC
Created attachment 29967 [details]
Test program

The attached test case shows an apparent rasterizing of fonts when text is drawn on a group rather than on the bare context.

On Mac OS X (the only platform I have available for test at present), Preview renders the first line using sub-pixel interpolation. The second line uses basic anti-aliasing instead. And when the result is printed, the first line is crisp while the second line looks like.... well, a printed raster graphic.

I don't know if fonts are the only things being rasterized; paths seem to show similar symptoms.

We have been using this technique when drawing items that may need to be wrapped onto another page (draw it on a group, and if you run out of room, pop it, show page, then paint the group) for quite a while. I have PDFs generated with Cairo 1.4 that don't seem to exhibit this problem, though I haven't run this exact test case against an older Cairo to verify.
Comment 1 Adrian Johnson 2009-10-01 02:01:01 UTC
Created attachment 29973 [details]
Output from cairo 1.8.8

It works for me. This is the PDF output I get from 1.8.8. I tested it with evince, okular, and acroread.

It is probably a bug in Preview.
Comment 2 Adrian Johnson 2009-10-01 02:05:54 UTC
Created attachment 29974 [details]
Output from current git (1.9.3)

There have been some changes in the current git version in the way groups are written to PDFs. Cairo now avoids using PDF Patterns (which are really only intended for repeating patterns) for sources with CAIRO_EXTEND_NONE. This makes it easier for PDF viewers to render. One of the benefits is text in groups is now selectable.

Try this version and see if it works with Preview.
Comment 3 Ken Treis 2009-10-01 09:31:21 UTC
Created attachment 29980 [details]
Screenshot of preview showing 1.9.3 output

(In reply to comment #2)
> There have been some changes in the current git version in the way groups are
> written to PDFs. Cairo now avoids using PDF Patterns (which are really only
> intended for repeating patterns) for sources with CAIRO_EXTEND_NONE. This makes
> it easier for PDF viewers to render. One of the benefits is text in groups is
> now selectable.

Nice -- this definitely sounds like a step in the right direction.

> Try this version and see if it works with Preview.

I can select the text that was grouped, but curiously Preview still doesn't render it with sub-pixel smoothing. It may well be a bug in Preview, since Adobe Reader doesn't show the apparent issue on the 1.8.8 output, either on-screen (it always uses antialiasing anyway) or in print (preview's print output is "blurry", where Adobe's is clean).

Also, the leading "A" on "Arial" doesn't show up in Preview (see attached screenshot). It shows up in Adobe Reader on-screen but not when printed -- in fact, after printing, Adobe Reader shows the following:

> An error exists on this page. Acrobat may not display the page correctly.
> Please contact the person who created the PDF document to correct the problem.
Comment 4 Adrian Johnson 2009-10-02 07:05:29 UTC
Created attachment 29998 [details]
output from current git with bug fix

I've fixed the bugs causing the missing 'A' and acroread error message.

Try this version.
Comment 5 Ken Treis 2009-10-02 08:36:37 UTC
I can confirm that your fix makes the missing "A" reappear in Preview and in Acrobat's printed output) and that the error message is gone. Thanks!

I will see if I can report the Preview bug to Apple.

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.