[cairo] Stroke adjust for filled rectangles?

Andreas Lobinger lobingera at gmail.com
Fri Jul 24 08:29:55 PDT 2015

Hello colleague,

first to your question, if it would be possible to detect the case;
closely looking at the rendering model which consecutively puts paint
onto a surface it think it would be hard to do. The detection would
need to look at consecutive stroke and fill operations and delaying
the rendering until decision.

Traditionally the concept of stroke adjustment is considered in
rendering lines and in the first place i'd rather try to find a path
construction of stems that is essentially a line stroked, that would
have the bonus that you can at least ask the PDF viewer to apply
stroke adjustment and see what it tries to forward to cairo path
construction. Because if i understand 10.6.5 of the PDF spec (iso
version) correctly stroke adjustment happens before rendering (so in
pdf interpretation) and not in rendering (cairo).

Putting the stems into a font would also be an idea. Usually the font
rendering (to bitmap) is more advanced in handling pixel problems for
line widths.

On Fri, Jul 24, 2015 at 10:06 AM, David Kastrup <dak at gnu.org> wrote:
> Hi,
> I encountered the problem in the past that note stems in LilyPond render
> rather inconsistently and generally too thick in PDF viewers using Cairo.
> Now the stems are rounded rectangles, and they are unsurprisingly done
> by stroking a closed rectangle with a circular pen (or rather with a
> given line thickness and rounded corners) and then filling the path.
> Now what happens is that the stroke adjustment for the left and right
> edges of the note stem is applied independently, based on the visual
> thickness of the outline rather than of the resulting filled shape.
> Which causes more rather than less jitter on the overall thickness of
> the stem.  Also the antialiasing considers left stroke, right stroke,
> and filling as independent applications of ink, resulting in too much
> ink applied when the scale of the stem would make it cover a breadth of
> 2 pixels or less.
> So the basic question is whether it would be possible to detect the case
> of slender and/or filled rectangular shapes to a sufficient degree to
> make their edges and innards render like one coherent entity rather than
> five independent ones (4 edges and one inner rectangle).
> --
> David Kastrup
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list