Implement the pathLength attribute
The pathLength
attribute should be used to calibrate librsvg's idea of a path's length with the SVG author's own. For example, the user may know that a circular path has exactly pi*D
units in perimeter, but since it is approximated from Bézier paths, librsvg's actual measurement may be different. If the user created a stroke-dasharray
whose dash/gap parts are spaced exactly pi
units apart, then they would expect the dasharray to appear exactly D
times around the circular path. Implementations are supposed to scale the dasharray by computed_path_length / user's-pathLength
so that their expectations match the results.
Note: Cairo cannot compute a path's length directly. It may be possible to use cairo_copy_path_flat
to get a flattened version and then add the lengths of the line segments. Alternatively, there are crates like lyon_path
or kurbo
that can provide those computations, and they also have nice things to obtain derivatives - which may be useful for textPath
support.
The pathLength
attribute is not strictly SVG2, but librsvg never implemented it for SVG1.1 - I'll mark this as SVG2 for the purposes of the Outreachy internship.