[cairo] [Bisected] Bugs in cairo's "contour" stroking

Chris Wilson chris at chris-wilson.co.uk
Sun Jun 24 02:58:41 PDT 2012

On Sat, 23 Jun 2012 11:21:29 -0700, Carl Worth <cworth at cworth.org> wrote:
> Carl Worth <cworth at cworth.org> writes:
> > A cairo user recently reported to me that cairo is not robust when
> > stroking wide splines with tight curvature, (and showed me a rather
> > striking example).
> In my previous report, it might have appeared that the bug only showed
> up in obscure cases with huge line widths and near-degenerate path
> shapes.

It is just a bug in the detection of a cusp within the spline. The
current method was just to detect the inflection by looking for a
flip in the tangents. As these cases demonstrate that is insufficient
due to the approximation of the spline using de Castleau removing the
inflection point. One approach would be to replace that method with a
piecewise parabolic approximation (the first step of which is to split
the spine into its inflection points). The claimed advantage for that
approach is that it generates fewer segments to reach the same error
tolerance. (When I tried long ago, it looked like the increased
computation expense of the parabolic approximation was more expensive
than generating a few more segments.) The second advantage of such an
approach is that it can be used to generate offset curves, useful for
stroke-to-path and further reducing the polygon segments around the
stroked outline.

A simple fix in the meantime is just to look at the cosine between the
two segments and decide whether the bevel join the two is within
tolerance of the ideal round join.

Chris Wilson, Intel Open Source Technology Centre

More information about the cairo mailing list