Skip to content

Commit b9f1513

Browse files
authored
Fix bug with softmask on images and add more test cases (#70)
1 parent dfd0309 commit b9f1513

14 files changed

Lines changed: 24 additions & 43 deletions

File tree

src/render/group.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ pub fn render(
4545
gs.finish();
4646
content.set_parameters(rc.add_graphics_state(gs_ref).to_pdf_name());
4747

48+
// We need to render the mask here instead of in `create_to_stream` so that
49+
// if we have a child as an image with a SMask, it won't override
50+
// the soft mask of the group. Unfortunately, this means we need this ugly
51+
// hack of setting and then reversing the transform.
52+
if let Some(mask) = group.mask() {
53+
content.transform(group.transform().to_pdf_transform());
54+
mask::render(group, mask, chunk, content, ctx, rc);
55+
content.transform(group.transform().invert().unwrap().to_pdf_transform());
56+
}
57+
4858
// We don't need to pass the accumulated transform here because if a pattern appears in a
4959
// XObject, it will be mapped to the coordinate space of where the XObject was invoked, meaning
5060
// that it will also be affected by the transforms in the content stream. If we passed on the
@@ -115,10 +125,6 @@ fn create_to_stream(
115125
content.transform(group.transform().to_pdf_transform());
116126
let accumulated_transform = accumulated_transform.pre_concat(group.transform());
117127

118-
if let Some(mask) = &group.mask() {
119-
mask::render(group, mask, chunk, content, ctx, rc);
120-
}
121-
122128
if let Some(clip_path) = &group.clip_path() {
123129
clip_path::render(group, clip_path, chunk, content, ctx, rc);
124130
}
156 Bytes
Loading
10 Bytes
Loading
644 Bytes
Loading
1.28 KB
Loading
697 Bytes
Loading
789 Bytes
Loading
789 Bytes
Loading
1.74 KB
Loading
1.55 KB
Loading

0 commit comments

Comments
 (0)