Skip to content

Commit a41d799

Browse files
committed
Support fully-zero dash arrays.
1 parent f674857 commit a41d799

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/_mplcairo.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,14 @@ void GraphicsContextRenderer::set_dashes(
626626
for (auto i = 0; i < n; ++i) {
627627
buf[i] = points_to_pixels(dashes_raw[i]);
628628
}
629-
cairo_set_dash(cr_, buf.get(), n, points_to_pixels(*dash_offset));
629+
if (std::all_of(buf.get(), buf.get() + n, std::logical_not{})) {
630+
// Treat fully zero dash arrays as solid stroke. This is consistent with
631+
// the SVG spec (PDF and PS specs explicitly reject such arrays), and
632+
// also generated by Matplotlib for zero-width lines due to dash scaling.
633+
cairo_set_dash(cr_, nullptr, 0, 0);
634+
} else {
635+
cairo_set_dash(cr_, buf.get(), n, points_to_pixels(*dash_offset));
636+
}
630637
} else {
631638
cairo_set_dash(cr_, nullptr, 0, 0);
632639
}

0 commit comments

Comments
 (0)