From 3903d948d47c1b9d41b52ce9f1c44c2f11c985cc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 06:53:27 -0800 Subject: [PATCH] Proof Setup: a CMYK device that is not loaded leaves colors as they are With Preserve CMYK Numbers on and a CMYK device whose profile is not loaded, proof_color separated an RGB color into the working CMYK space and showed the inks back through it, so a saturated blue changed while the same color as a pixel stayed as it is. It now returns the color's display color, as the RGB devices do. --- crates/color/src/cms.rs | 2 ++ crates/color/src/cms/tests.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/color/src/cms.rs b/crates/color/src/cms.rs index 1bc134afb0..b3f312879b 100644 --- a/crates/color/src/cms.rs +++ b/crates/color/src/cms.rs @@ -699,6 +699,8 @@ impl Cms { return self.proof_srgb(self.display_rgb(c), proof); } match &proof.target { + // A device whose profile is not loaded leaves the color as it is, as for a pixel. + ProofTarget::Cmyk(name) if cmyk_space(name).is_err() => self.display_rgb(c), ProofTarget::WorkingCmyk | ProofTarget::Cmyk(_) => self.proof_cmyk_to_srgb(self.to_cmyk(c, Intent::RelativeColorimetric), proof), ProofTarget::Rgb(name) => { // A CMYK color converts straight into the RGB space, so a wide space keeps it. diff --git a/crates/color/src/cms/tests.rs b/crates/color/src/cms/tests.rs index f0ab0e8e8e..9e3a588d53 100644 --- a/crates/color/src/cms/tests.rs +++ b/crates/color/src/cms/tests.rs @@ -271,6 +271,23 @@ fn rgb_device_proofs_show_the_device_numbers() { assert_eq!(c.proof_srgb(red, &gone), red); } +/// A CMYK device whose profile is not loaded leaves a color as the screen shows it, with Preserve +/// CMYK Numbers on as well as off, the same as for a pixel of that color. +#[test] +fn missing_cmyk_device_leaves_colors_as_they_are() { + let c = cms(); + let gone = ProofSetup { target: ProofTarget::Cmyk("Nope".into()), preserve_numbers: true, ..Default::default() }; + let blue = Color::rgb(0.0, 0.0, 1.0); + let shown = c.display_rgb(&blue); + assert_eq!(c.proof_color(&blue, &gone), shown); + assert_eq!(c.proof_srgb(shown, &gone), shown); + let off = ProofSetup { preserve_numbers: false, ..gone.clone() }; + assert_eq!(c.proof_color(&blue, &off), shown); + // A CMYK color keeps its inks' display color. + let ink = Color::Cmyk { c: 0.2, m: 0.7, y: 0.1, k: 0.05 }; + assert!(de(c.proof_color(&ink, &gone), c.display_rgb(&ink)) < 0.01); +} + /// The expected colors were computed separately with NumPy from the same published inputs (linear /// sRGB to XYZ from IEC 61966-2-1, Smith & Pokorny's XYZ to LMS, Judd-Vos XYZ at 485 nm and 660 nm), /// following Brettel, ViƩnot & Mollon (1997) with the display's white as the neutral axis.