@@ -964,10 +964,17 @@ void GraphicsContextRenderer::draw_path(
964
964
path_loaded = true ;
965
965
}
966
966
};
967
- if (auto const & sketch = get_additional_state ().sketch ) {
968
- path =
969
- path.attr (" cleaned" )(
970
- " transform" _a=transform, " curves" _a=true , " sketch" _a=sketch);
967
+ auto const & hatch_path =
968
+ py::cast (this ).attr (" get_hatch_path" )().cast <std::optional<py::object>>();
969
+ auto const & simplify =
970
+ path.attr (" should_simplify" ).cast <bool >() && !fc && !hatch_path;
971
+ auto const & sketch = get_additional_state ().sketch ;
972
+ if (simplify || sketch) {
973
+ // TODO: cairo internally uses vertex reduction and Douglas-Peucker, but it
974
+ // is unclear whether it also applies to vector output? See mplcairo#37.
975
+ path = path.attr (" cleaned" )(
976
+ " transform" _a=transform, " simplify" _a=simplify, " curves" _a=true ,
977
+ " sketch" _a=sketch);
971
978
mtx = cairo_matrix_t {1 , 0 , 0 , -1 , 0 , get_additional_state ().height };
972
979
}
973
980
if (fc) {
@@ -978,9 +985,7 @@ void GraphicsContextRenderer::draw_path(
978
985
cairo_fill_preserve (cr_);
979
986
cairo_restore (cr_);
980
987
}
981
- if (auto const & hatch_path =
982
- py::cast (this ).attr (" get_hatch_path" )()
983
- .cast <std::optional<py::object>>()) {
988
+ if (hatch_path) {
984
989
cairo_save (cr_);
985
990
auto const & dpi = int (get_additional_state ().dpi ); // Truncating is good enough.
986
991
auto const & hatch_surface =
0 commit comments