diff --git a/crates/usvg/src/writer.rs b/crates/usvg/src/writer.rs index 2c455cbc1..afacefcb8 100644 --- a/crates/usvg/src/writer.rs +++ b/crates/usvg/src/writer.rs @@ -831,16 +831,22 @@ fn write_group_element(g: &Group, is_clip_path: bool, opt: &WriteOptions, xml: & // Same with text. Text elements will be converted into groups, // but only the group's children should be written. for child in &g.children { - if let Node::Path(ref path) = child { - let clip_id = g.clip_path.as_ref().map(|cp| cp.id().to_string()); - write_path( - path, - is_clip_path, - g.transform, - clip_id.as_deref(), - opt, - xml, - ); + match child { + Node::Group(child_group) => { + write_group_element(child_group, is_clip_path, opt, xml); + } + Node::Path(child_path) => { + let clip_id = g.clip_path.as_ref().map(|cp| cp.id().to_string()); + write_path( + child_path, + is_clip_path, + g.transform, + clip_id.as_deref(), + opt, + xml, + ); + } + _ => {} } } return; diff --git a/crates/usvg/tests/files/clip-path-with-transform-expected.svg b/crates/usvg/tests/files/clip-path-with-transform-expected.svg new file mode 100644 index 000000000..c6afc3d45 --- /dev/null +++ b/crates/usvg/tests/files/clip-path-with-transform-expected.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/crates/usvg/tests/files/clip-path-with-transform.svg b/crates/usvg/tests/files/clip-path-with-transform.svg new file mode 100755 index 000000000..f3467d4de --- /dev/null +++ b/crates/usvg/tests/files/clip-path-with-transform.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/crates/usvg/tests/write.rs b/crates/usvg/tests/write.rs index 14edfbb92..4cd69d033 100644 --- a/crates/usvg/tests/write.rs +++ b/crates/usvg/tests/write.rs @@ -77,6 +77,11 @@ fn text_simple_case() { resave("text-simple-case"); } +#[test] +fn clip_path_with_transform() { + resave("clip-path-with-transform"); +} + #[test] fn preserve_id_filter() { resave("preserve-id-filter");