[cairo] PDF backend starts to get interesting

Carl Worth cworth at cworth.org
Fri Apr 21 03:28:03 PDT 2006


On Wed, 19 Apr 2006 15:59:48 -0700, Carl Worth wrote:
>
> 1) As with the PostScript backend, the first page is triggering image
>    fallbacks. These should be much easier to avoid in PDF since the
>    PDF imaging model (as of PDF 1.4) allows for doing much more than
>    PostScript allows.
...
>    Then there are things like outputting image translucence via SMask
>    support.

As Ralph and Jeff so quickly pointed out, we already have good SMask
support in our PDF rendering tools such as ghostscript and poppler.

So I've now done the work to emit this from cairo's PDF backend. The
patchset still needs a tiny bit of cleanup before getting pushed to
cairo's central tree, but the results are interesting so I wanted to
share them right away. (And the code is available in my personal
tree---see below.)

Basically, the PDF backend now advertises itself within cairo as
supporting anything drawn with the (default) OVER operator. And this
is adequate for eliminating the image fallbacks we were getting from
Mozilla-based printing. So the minefield test is now rendering much
nicer:

http://cairographics.org/~cworth/images/minefield-mozilla-smask.pdf

I also tested a couple of pages with more challenging scripts, just to
see what the results look like:

http://cairographics.org/~cworth/images/bbc-co-uk_chinese.pdf

http://cairographics.org/~cworth/images/yahoo-co-jp.pdf

And I'm pretty happy with all of that progress so far. The files are
still much larger than they should be of course, and the text glyphs
won't render quite nicely at large scales. Those are due to the
remaining TODO item mentioned before:

> 2) Doing each show_text as a giant path is obviously not the right
>    thing.

The files are large because every glyph repeats an entire copy of its
path. Also the glyph rendering is rather ugly at large scales for a
couple of reasons:

1) The current output just has simple paths, so you won't get glyph
   hinting like you would prefer to see.

2) Worse, it appears that the paths that are being emitted have been
   pre-munged according to the hints that are appropriate for the
   original screen rendering. I'm not sure exactly why this is
   happening, but if you want to see what amazing contortions glyph
   shapes go through when rendered at small sizes, bring up one of the
   PDF files above in a viewer like evince or gv and zoom in a
   lot---yuck!  Or worse, print the thing. Clearly, hinting for the
   wrong scale is *much* worse than no hinting at all.

I'm not too worried about the mysterious cause of bug #2 here since
both of these will go away as soon as we start emitting actual PDF
fonts and glyphs instead of just paths. And as mentioned before,
Kristian already has done all the work necessary to embed TrueType
fonts, (which can then include all their hints), into cairo's PDF
output. You may have seen this before if you tried the PDF output in
the 1.0 series and got some reasonable results from it. So again,
that's just a matter of turning on some existing to be used when
appropriate.

So I don't think this last step should take long. And it looks like
we'll soon be able to provide high-quality printing from cairo, just
like we've always wanted. That will be very satisfying.

A 1.2 release of cairo by the end of the month still looks quite
possible, (though I still did want a longer period of snapshots
leading up to the final release). We can work that out next week.

-Carl

PS. So if you want to actually take a look at this stuff, you can get
a tree with my new PDF SMask patches, by simply cloning my personal
tree:

	git clone git://git.cairographics.org/~cworth/cairo

And if you'd like to try the branch that is suitable for compiling
mozilla with --enable-system-cairo, then after that clone, do the
following within the resulting cairo directory:

	git checkout mozilla-merged

Also, there's a fancy new optimization available in the latest 1.3
release of git. If you've already got a local cairo repository, (the
central tree, say), then you can clone my personal tree extremely
efficiently by passing the --reference option to git-clone and
pointing to your local tree. For example:

	git clone --reference=${HOME}/cairo git://git.cairographics.org/~cworth/cairo

This will be impressively fast as it will only transfer the small
number of objects that are missing between the repository you
reference and the repository you are cloning.

Happy hacking --- and have fun with cairo!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060421/cd9378bf/attachment.pgp


More information about the cairo mailing list