[cairo] Zero length segment and SVG

Carl Worth cworth at cworth.org
Sun Jun 25 08:40:37 PDT 2006


On Sat, 24 Jun 2006 23:41:20 -0400, Jeff Muizelaar wrote:
> 
> Just an update. Here is my current patch. It should actually fix both of
> the bugs pointed out by Keith Wells.

Thanks Jeff, this looks fantastic!

> It still needs more work though.

Can you describe in more detail what you mean here?

I've gone ahead and made a new branch that applies your code in two
commits, (one for the test case, then one for the functional
stuff). Then I added documentation and a few very minor style cleanups
on top of this. That branch is visible as the top 6 commits here:

http://gitweb.cairographics.org/?p=users-cworth-cairo;a=shortlog;h=degenerate-path

I feel really good about the state this ends up with, and I would be
glad to push this out right away and have it in place for 1.2. There
are still ps and svg failures for the degenerate-path tests, but I
don't think those will be too bad to clean up.

I checked over the PDF specification, and I was quite happy to see
that the semantics we have in this branch now match PDF exactly,
(namely, cap styles of ROUND or SQUARE cause drawing for zero-length
dash segments, but only a cap style of ROUND causes any degenerate
sub-path to be drawn).

Here is the documentation I added to cairo_set_dash:

 * Each "on" segment will have caps applied as if the segment were a
 * separate sub-path. In particular, it is valid to use an "on" length
 * of 0.0 with CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE in order
 * to distributed dots or squares along a path.

And here is the documentation I added to cairo_stroke:

 * Note: Degenerate segments and sub-paths are treated specially and
 * provide a useful result. These can result in two different
 * situations:
 *
 * 1. Zero-length "on" segments set in cairo_set_dash(). If the cap
 * style is CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE then these
 * segments will be drawn as circular dots or squares respectively. In
 * the case of CAIRO_LINE_CAP_SQUARE, the orientation of the squares
 * is determined by the direction of the underlying path.
 *
 * 2. A sub-path created by cairo_move_to() followed by either a
 * cairo_close_path() or one or more calls to cairo_line_to() to the
 * same coordinate as the cairo_move_to(). If the cap style is
 * CAIRO_LINE_CAP_ROUND then these sub-paths will be drawn as circular
 * dots. Note that in the case of CAIRO_LINE_CAP_SQUARE a degenerate
 * sub-path will not be drawn at all, (since the correct orientation
 * is indeterminate).
 *
 * In no case will a cap style of CAIRO_LINE_CAP_BUTT cause anything
 * to be drawn in the case of either degenerate segments or sub-paths.

> Note: the test case exercises a bug in the postscript surface that
> causes it to split the ~> of a base85 stream across two lines.
> Ghostscript doesn't like this very much.

Hmmm... will have to look at that.

Anyway, thanks again.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060625/3e4bd4a3/attachment.pgp


More information about the cairo mailing list