Using path expressions to override stencils

The stencil expression path can be used to override stencils for any printed object. The advantage of using path instead of embedded-ps is that path is supported by both the PostScript and SVG backends of LilyPond, and uses the same syntax.

There are six commands available to use in a path expression, and all commands use prefix notation. The six commands are moveto, rmoveto, lineto, rlineto, curveto, and rcurveto. Note that the commands that begin with r are the relative variants of the other three commands.

The commands moveto, rmoveto, lineto, and rlineto take two arguments; they are the X- and Y-coordinates for the destination point.

The commands curveto and rcurveto create cubic Bézier curves and take six arguments; the first two are the X- and Y-coordinates for the first control point, the second two are the X- and Y-coordinates for the second control point, and the last two are the X- and Y-coordinates for the destination point.

This snippet also shows how to create a ‘filled’ stencil using path, adding a Scheme function to automatically resize custom stencils when individual staves are resized.

Note that replacing the stencil of a grob doesn't change its dimensions. In case you experience strange spacing you have to adjust the X-extent and Y-extent properties. If you experience cropping, you might use the \with-true-dimensions trick shown below.

See also snippet Generate special note head shapes.

LilyPond rendering error

No release of LilyPond 2.24 found.