From 9ad1879e9d0978d828790fdf7978ba4aff240a71 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 9 Jul 2025 14:02:13 +0200 Subject: Anti-alias clip paths (#6570) --- crates/typst-render/src/lib.rs | 4 ++-- tests/ref/block-clip-svg-glyphs.png | Bin 1862 -> 1938 bytes tests/ref/block-clip-text.png | Bin 908 -> 965 bytes tests/ref/block-clipping-multiple-pages.png | Bin 2029 -> 2085 bytes tests/ref/box-clip-radius-without-stroke.png | Bin 1255 -> 1256 bytes tests/ref/box-clip-radius.png | Bin 1250 -> 1255 bytes tests/ref/box-clip-rect.png | Bin 1680 -> 1691 bytes tests/ref/closure-path-resolve-in-layout-phase.png | Bin 2256 -> 2263 bytes tests/ref/hide-image.png | Bin 8877 -> 9123 bytes tests/ref/image-baseline-with-box.png | Bin 6375 -> 6613 bytes tests/ref/issue-5499-text-fill-in-clip-block.png | Bin 1502 -> 1518 bytes tests/ref/issue-6267-clip-anti-alias.png | Bin 0 -> 251 bytes tests/ref/transform-rotate-relative-sizing.png | Bin 2414 -> 2491 bytes tests/ref/transform-scale-relative-sizing.png | Bin 2023 -> 2034 bytes tests/ref/transform-skew-relative-sizing.png | Bin 828 -> 834 bytes tests/suite/layout/container.typ | 7 +++++++ 16 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/ref/issue-6267-clip-anti-alias.png diff --git a/crates/typst-render/src/lib.rs b/crates/typst-render/src/lib.rs index f43cd019..2c57fe2d 100644 --- a/crates/typst-render/src/lib.rs +++ b/crates/typst-render/src/lib.rs @@ -202,7 +202,7 @@ fn render_group(canvas: &mut sk::Pixmap, state: State, pos: Point, group: &Group mask.intersect_path( &path, sk::FillRule::default(), - false, + true, sk::Transform::default(), ); storage = mask; @@ -218,7 +218,7 @@ fn render_group(canvas: &mut sk::Pixmap, state: State, pos: Point, group: &Group mask.fill_path( &path, sk::FillRule::default(), - false, + true, sk::Transform::default(), ); storage = mask; diff --git a/tests/ref/block-clip-svg-glyphs.png b/tests/ref/block-clip-svg-glyphs.png index 0fc2c962..bf13b7ea 100644 Binary files a/tests/ref/block-clip-svg-glyphs.png and b/tests/ref/block-clip-svg-glyphs.png differ diff --git a/tests/ref/block-clip-text.png b/tests/ref/block-clip-text.png index 8c82bc30..2b099b48 100644 Binary files a/tests/ref/block-clip-text.png and b/tests/ref/block-clip-text.png differ diff --git a/tests/ref/block-clipping-multiple-pages.png b/tests/ref/block-clipping-multiple-pages.png index 0b6e7c85..1305ff20 100644 Binary files a/tests/ref/block-clipping-multiple-pages.png and b/tests/ref/block-clipping-multiple-pages.png differ diff --git a/tests/ref/box-clip-radius-without-stroke.png b/tests/ref/box-clip-radius-without-stroke.png index 2be772cc..c7d83de2 100644 Binary files a/tests/ref/box-clip-radius-without-stroke.png and b/tests/ref/box-clip-radius-without-stroke.png differ diff --git a/tests/ref/box-clip-radius.png b/tests/ref/box-clip-radius.png index 530d5330..fb27bb74 100644 Binary files a/tests/ref/box-clip-radius.png and b/tests/ref/box-clip-radius.png differ diff --git a/tests/ref/box-clip-rect.png b/tests/ref/box-clip-rect.png index fd62bbec..8f307f75 100644 Binary files a/tests/ref/box-clip-rect.png and b/tests/ref/box-clip-rect.png differ diff --git a/tests/ref/closure-path-resolve-in-layout-phase.png b/tests/ref/closure-path-resolve-in-layout-phase.png index a3d69998..ca22e458 100644 Binary files a/tests/ref/closure-path-resolve-in-layout-phase.png and b/tests/ref/closure-path-resolve-in-layout-phase.png differ diff --git a/tests/ref/hide-image.png b/tests/ref/hide-image.png index d671a073..75975d24 100644 Binary files a/tests/ref/hide-image.png and b/tests/ref/hide-image.png differ diff --git a/tests/ref/image-baseline-with-box.png b/tests/ref/image-baseline-with-box.png index ade90e2f..37403c80 100644 Binary files a/tests/ref/image-baseline-with-box.png and b/tests/ref/image-baseline-with-box.png differ diff --git a/tests/ref/issue-5499-text-fill-in-clip-block.png b/tests/ref/issue-5499-text-fill-in-clip-block.png index 5f7962d3..ac81fe8e 100644 Binary files a/tests/ref/issue-5499-text-fill-in-clip-block.png and b/tests/ref/issue-5499-text-fill-in-clip-block.png differ diff --git a/tests/ref/issue-6267-clip-anti-alias.png b/tests/ref/issue-6267-clip-anti-alias.png new file mode 100644 index 00000000..00a61bc2 Binary files /dev/null and b/tests/ref/issue-6267-clip-anti-alias.png differ diff --git a/tests/ref/transform-rotate-relative-sizing.png b/tests/ref/transform-rotate-relative-sizing.png index 5951ff8a..9b1d365d 100644 Binary files a/tests/ref/transform-rotate-relative-sizing.png and b/tests/ref/transform-rotate-relative-sizing.png differ diff --git a/tests/ref/transform-scale-relative-sizing.png b/tests/ref/transform-scale-relative-sizing.png index c53243c4..01f0878b 100644 Binary files a/tests/ref/transform-scale-relative-sizing.png and b/tests/ref/transform-scale-relative-sizing.png differ diff --git a/tests/ref/transform-skew-relative-sizing.png b/tests/ref/transform-skew-relative-sizing.png index af44fee9..4453a481 100644 Binary files a/tests/ref/transform-skew-relative-sizing.png and b/tests/ref/transform-skew-relative-sizing.png differ diff --git a/tests/suite/layout/container.typ b/tests/suite/layout/container.typ index f15ddfe4..489c8892 100644 --- a/tests/suite/layout/container.typ +++ b/tests/suite/layout/container.typ @@ -325,3 +325,10 @@ b a #block(height: -25pt)[b] c + +--- issue-6267-clip-anti-alias --- +#block( + clip: true, + radius: 100%, + rect(fill: gray, height: 1cm, width: 1cm), +) -- cgit v1.2.3