VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Part of #1286: constant alpha masks are drawn white, so the page shows where soft masks are read by luminosity
bflatastic934d83405cd5
diff --git a/crates/pdf/src/export.rs b/crates/pdf/src/export.rsindex 15a1e213c..990fc3cb9 100644--- a/crates/pdf/src/export.rs+++ b/crates/pdf/src/export.rs@@ -605,10 +605,11 @@ fn cover(s: &mut Surface, page: Rect, level: u8, opacity: f32) {/// An alpha mask of constant `alpha` over the page. A group drawn through it is a transparency/// group of that opacity that, unlike the writer's opacity groups, is not isolated.+/// The cover is white, so a reader that takes every soft mask as a luminosity mask shows the same.fn constant_mask(s: &mut Surface, page: Rect, alpha: f32) -> krilla::mask::Mask {let mut sb = s.stream_builder();let mut ms = sb.surface();- cover(&mut ms, page, 0, alpha);+ cover(&mut ms, page, 255, alpha);ms.finish();krilla::mask::Mask::new(sb.finish(), krilla::mask::MaskType::Alpha)}diff --git a/crates/pdf/src/tests_cmykblend.rs b/crates/pdf/src/tests_cmykblend.rsindex f76d90815..03fcad84f 100644--- a/crates/pdf/src/tests_cmykblend.rs+++ b/crates/pdf/src/tests_cmykblend.rs@@ -76,3 +76,12 @@ fn soft_mask_groups_keep_screen_luminance() {// The page's group blends in CMYK; the mask's group measures luminance in RGB.assert!(t.contains("/CS/DeviceCMYK") && t.contains("/S/Luminosity") && t.contains("/CS/DeviceRGB"), "{t}");}++#[test]+fn constant_alpha_masks_are_white() {+ // #1286: a black cover hides the whole page in readers that take the mask's luminosity.+ for grouped in [true, false] {+ let t = text(&doc(ColorMode::Cmyk, grouped));+ assert!(t.contains("/S/Alpha") && t.contains("111rg") && !t.contains("000rg"), "grouped {grouped}: {t}");+ }+}