Skip to content

Commit

Permalink
Support fully-zero dash arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Jun 3, 2020
1 parent f674857 commit a41d799
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/_mplcairo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,14 @@ void GraphicsContextRenderer::set_dashes(
for (auto i = 0; i < n; ++i) {
buf[i] = points_to_pixels(dashes_raw[i]);
}
cairo_set_dash(cr_, buf.get(), n, points_to_pixels(*dash_offset));
if (std::all_of(buf.get(), buf.get() + n, std::logical_not{})) {
// Treat fully zero dash arrays as solid stroke. This is consistent with
// the SVG spec (PDF and PS specs explicitly reject such arrays), and
// also generated by Matplotlib for zero-width lines due to dash scaling.
cairo_set_dash(cr_, nullptr, 0, 0);
} else {
cairo_set_dash(cr_, buf.get(), n, points_to_pixels(*dash_offset));
}
} else {
cairo_set_dash(cr_, nullptr, 0, 0);
}
Expand Down

0 comments on commit a41d799

Please sign in to comment.