Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions crates/usvg/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions crates/usvg/tests/files/clip-path-with-transform-expected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions crates/usvg/tests/files/clip-path-with-transform.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions crates/usvg/tests/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down