Skip to content

Commit 6b9f554

Browse files
committed
Fix groups in clipping paths
1 parent fec20fb commit 6b9f554

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,15 @@ fn content_stream(
506506
fn apply_clip_path(
507507
path: Option<Rc<usvg::ClipPath>>,
508508
content: &mut Content,
509+
writer: &mut PdfWriter,
509510
ctx: &mut Context,
510511
) {
511512
let path = match path {
512513
Some(path) => path,
513514
None => return,
514515
};
515516

516-
apply_clip_path(path.clip_path.clone(), content, ctx);
517+
apply_clip_path(path.clip_path.clone(), content, writer, ctx);
517518

518519
let old = ctx.c.concat_transform(path.transform);
519520

@@ -524,6 +525,9 @@ fn apply_clip_path(
524525
content.clip_nonzero();
525526
content.end_path();
526527
}
528+
NodeKind::Group(ref group) => {
529+
group.render(&child, writer, content, ctx);
530+
}
527531
_ => unreachable!(),
528532
}
529533
}

src/render.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,10 @@ impl Render for usvg::Group {
522522
let num = ctx.alloc_xobject();
523523
let name = format!("xo{}", num);
524524
content.save_state();
525+
resources.finish();
526+
form.finish();
525527

526-
apply_clip_path(self.clip_path.clone(), content, ctx);
528+
apply_clip_path(self.clip_path.clone(), content, writer, ctx);
527529

528530
if let Some(reference) = apply_mask(self.mask.clone(), bbox, pdf_bbox, ctx) {
529531
let num = ctx.alloc_gs();

src/scale.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ impl CoordToPdf {
179179
pdf_writer::Rect::new(x1, y1, x2, y2)
180180
}
181181

182-
/// Transform a rectangle from SVG to PDF formats, disregarding transforms.
183-
pub fn pdf_rect_raw(&self, rect: usvg::Rect) -> pdf_writer::Rect {
184-
let (x1, y1) = self.point_raw((rect.x(), rect.y() + rect.height()));
185-
let (x2, y2) = self.point_raw((rect.x() + rect.width(), rect.y()));
186-
pdf_writer::Rect::new(x1, y1, x2, y2)
187-
}
188-
189182
/// Apply a transformation to a point.
190183
fn apply(&self, point: (f64, f64)) -> (f64, f64) {
191184
self.transform.apply(point.0, point.1)

0 commit comments

Comments
 (0)