summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-07-09 14:02:13 +0200
committerGitHub <noreply@github.com>2025-07-09 12:02:13 +0000
commit9ad1879e9d0978d828790fdf7978ba4aff240a71 (patch)
tree17f456a8733b7fb166776c33964d63228cf40397
parente5e813219edd3553535c4c6cf885138dbc9f3f9a (diff)
Anti-alias clip paths (#6570)
-rw-r--r--crates/typst-render/src/lib.rs4
-rw-r--r--tests/ref/block-clip-svg-glyphs.pngbin1862 -> 1938 bytes
-rw-r--r--tests/ref/block-clip-text.pngbin908 -> 965 bytes
-rw-r--r--tests/ref/block-clipping-multiple-pages.pngbin2029 -> 2085 bytes
-rw-r--r--tests/ref/box-clip-radius-without-stroke.pngbin1255 -> 1256 bytes
-rw-r--r--tests/ref/box-clip-radius.pngbin1250 -> 1255 bytes
-rw-r--r--tests/ref/box-clip-rect.pngbin1680 -> 1691 bytes
-rw-r--r--tests/ref/closure-path-resolve-in-layout-phase.pngbin2256 -> 2263 bytes
-rw-r--r--tests/ref/hide-image.pngbin8877 -> 9123 bytes
-rw-r--r--tests/ref/image-baseline-with-box.pngbin6375 -> 6613 bytes
-rw-r--r--tests/ref/issue-5499-text-fill-in-clip-block.pngbin1502 -> 1518 bytes
-rw-r--r--tests/ref/issue-6267-clip-anti-alias.pngbin0 -> 251 bytes
-rw-r--r--tests/ref/transform-rotate-relative-sizing.pngbin2414 -> 2491 bytes
-rw-r--r--tests/ref/transform-scale-relative-sizing.pngbin2023 -> 2034 bytes
-rw-r--r--tests/ref/transform-skew-relative-sizing.pngbin828 -> 834 bytes
-rw-r--r--tests/suite/layout/container.typ7
16 files changed, 9 insertions, 2 deletions
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
--- a/tests/ref/block-clip-svg-glyphs.png
+++ b/tests/ref/block-clip-svg-glyphs.png
Binary files differ
diff --git a/tests/ref/block-clip-text.png b/tests/ref/block-clip-text.png
index 8c82bc30..2b099b48 100644
--- a/tests/ref/block-clip-text.png
+++ b/tests/ref/block-clip-text.png
Binary files differ
diff --git a/tests/ref/block-clipping-multiple-pages.png b/tests/ref/block-clipping-multiple-pages.png
index 0b6e7c85..1305ff20 100644
--- a/tests/ref/block-clipping-multiple-pages.png
+++ b/tests/ref/block-clipping-multiple-pages.png
Binary files 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
--- a/tests/ref/box-clip-radius-without-stroke.png
+++ b/tests/ref/box-clip-radius-without-stroke.png
Binary files differ
diff --git a/tests/ref/box-clip-radius.png b/tests/ref/box-clip-radius.png
index 530d5330..fb27bb74 100644
--- a/tests/ref/box-clip-radius.png
+++ b/tests/ref/box-clip-radius.png
Binary files differ
diff --git a/tests/ref/box-clip-rect.png b/tests/ref/box-clip-rect.png
index fd62bbec..8f307f75 100644
--- a/tests/ref/box-clip-rect.png
+++ b/tests/ref/box-clip-rect.png
Binary files 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
--- a/tests/ref/closure-path-resolve-in-layout-phase.png
+++ b/tests/ref/closure-path-resolve-in-layout-phase.png
Binary files differ
diff --git a/tests/ref/hide-image.png b/tests/ref/hide-image.png
index d671a073..75975d24 100644
--- a/tests/ref/hide-image.png
+++ b/tests/ref/hide-image.png
Binary files differ
diff --git a/tests/ref/image-baseline-with-box.png b/tests/ref/image-baseline-with-box.png
index ade90e2f..37403c80 100644
--- a/tests/ref/image-baseline-with-box.png
+++ b/tests/ref/image-baseline-with-box.png
Binary files 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
--- a/tests/ref/issue-5499-text-fill-in-clip-block.png
+++ b/tests/ref/issue-5499-text-fill-in-clip-block.png
Binary files 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
--- /dev/null
+++ b/tests/ref/issue-6267-clip-anti-alias.png
Binary files differ
diff --git a/tests/ref/transform-rotate-relative-sizing.png b/tests/ref/transform-rotate-relative-sizing.png
index 5951ff8a..9b1d365d 100644
--- a/tests/ref/transform-rotate-relative-sizing.png
+++ b/tests/ref/transform-rotate-relative-sizing.png
Binary files differ
diff --git a/tests/ref/transform-scale-relative-sizing.png b/tests/ref/transform-scale-relative-sizing.png
index c53243c4..01f0878b 100644
--- a/tests/ref/transform-scale-relative-sizing.png
+++ b/tests/ref/transform-scale-relative-sizing.png
Binary files differ
diff --git a/tests/ref/transform-skew-relative-sizing.png b/tests/ref/transform-skew-relative-sizing.png
index af44fee9..4453a481 100644
--- a/tests/ref/transform-skew-relative-sizing.png
+++ b/tests/ref/transform-skew-relative-sizing.png
Binary files 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),
+)