diff --git a/crates/eps/src/import/graphics/paint.rs b/crates/eps/src/import/graphics/paint.rs index d0f8cb6788..ca3b1dee82 100644 --- a/crates/eps/src/import/graphics/paint.rs +++ b/crates/eps/src/import/graphics/paint.rs @@ -446,13 +446,14 @@ pub(super) fn shading_extent(sh: &DictRef, m: Affine, area: Rect) -> Option = + let corners: Vec = [(area.x0, area.y0), (area.x1, area.y0), (area.x1, area.y1), (area.x0, area.y1)].map(|(x, y)| inv * Point::new(x, y)).to_vec(); + let mut poly = corners.clone(); let c = nums("Coords"); let at = |i: usize| c.get(i).copied().filter(|v| v.is_finite()).unwrap_or(0.0); match d.get(&Key::name("ShadingType")).and_then(Obj::as_num) { @@ -482,6 +483,10 @@ pub(super) fn shading_extent(sh: &DictRef, m: Affine, area: Rect) -> Option return None, } + // Nothing cut: it paints the whole area. + if poly.len() == 4 && poly.iter().zip(&corners).all(|(a, b)| (*a - *b).hypot2() < 1e-18) { + return None; + } Some(poly.into_iter().map(|p| m * p).collect()) }