Skip to content

Commit bdf080b

Browse files
Fix bug in rewriting of clip paths with transformed path (#988)
1 parent 072148a commit bdf080b

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

crates/usvg/src/writer.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -831,16 +831,22 @@ fn write_group_element(g: &Group, is_clip_path: bool, opt: &WriteOptions, xml: &
831831
// Same with text. Text elements will be converted into groups,
832832
// but only the group's children should be written.
833833
for child in &g.children {
834-
if let Node::Path(ref path) = child {
835-
let clip_id = g.clip_path.as_ref().map(|cp| cp.id().to_string());
836-
write_path(
837-
path,
838-
is_clip_path,
839-
g.transform,
840-
clip_id.as_deref(),
841-
opt,
842-
xml,
843-
);
834+
match child {
835+
Node::Group(child_group) => {
836+
write_group_element(child_group, is_clip_path, opt, xml);
837+
}
838+
Node::Path(child_path) => {
839+
let clip_id = g.clip_path.as_ref().map(|cp| cp.id().to_string());
840+
write_path(
841+
child_path,
842+
is_clip_path,
843+
g.transform,
844+
clip_id.as_deref(),
845+
opt,
846+
xml,
847+
);
848+
}
849+
_ => {}
844850
}
845851
}
846852
return;
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Loading

crates/usvg/tests/write.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ fn text_simple_case() {
7777
resave("text-simple-case");
7878
}
7979

80+
#[test]
81+
fn clip_path_with_transform() {
82+
resave("clip-path-with-transform");
83+
}
84+
8085
#[test]
8186
fn preserve_id_filter() {
8287
resave("preserve-id-filter");

0 commit comments

Comments
 (0)