mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
View: Proof Setup › Customize… opens a dialog for the device to simulate
View › Proof Setup › Customize… opened the Separations Preview panel. It now opens a Proof Setup dialog: Device to Simulate (the working CMYK space or any CMYK or RGB profile), Preserve CMYK Numbers or Preserve RGB Numbers, Rendering intent (off while the numbers are preserved), Simulate Paper Color, Simulate Black Ink and Preview. OK sets the proof setup and turns Proof Colors on; Cancel puts the earlier proof back. view.proofSetup takes an "rgb:<profile>" target, preserveNumbers and simulateBlack, and its reply carries both. Simulate Black Ink shows the device's black without black-point compensation. With Preserve Numbers the renderer proofs each color from its own numbers as it paints it, placed CMYK images from their own inks, and the inks a CMYK document blends; the paper under the art takes Simulate Paper Color's tint.
This commit is contained in:
1 parent
67f6d3a50f
commit
06bf6397c7
49 files changed
+1007
-39
No files matched your search
@@ -100,7 +100,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Proof Setup",
|
||||
["View", "Proof Setup"],
|
||||
None,
|
||||
"{target?: \"workingCmyk\"|\"cmyk:<profile>\"|\"legacyMacRgb\"|\"srgb\"|\"monitorRgb\"|\"protanopia\"|\"deuteranopia\"|\"tritanopia\", intent?, simulatePaper?, proof?: bool (also turn Proof Colors on)} → proof state",
|
||||
"{target?: \"workingCmyk\"|\"cmyk:<profile>\"|\"rgb:<profile>\"|\"legacyMacRgb\"|\"srgb\"|\"monitorRgb\"|\"protanopia\"|\"deuteranopia\"|\"tritanopia\" (cmyk: and rgb: name a CMYK or RGB profile of color.loadProfile or the built-in ones: the device to simulate), intent? (used while preserveNumbers is off), simulatePaper?: bool, preserveNumbers?: bool (Preserve CMYK or RGB Numbers: the colors' numbers in the document's space go to the device unchanged), simulateBlack?: bool (Simulate Black Ink: the device's black shows as the dark gray it prints; simulatePaper does this too; CMYK devices only, as simulatePaper), proof?: bool (also turn Proof Colors on)} → proof state",
|
||||
always,
|
||||
proof_setup
|
||||
),
|
||||
@@ -235,7 +235,7 @@ fn load_profile(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
use_front_profiles(s);
|
||||
touch_all(s);
|
||||
} else if proof_targets(&info.name) {
|
||||
// A new file of the CMYK profile View → Proof Setup targets: redraw.
|
||||
// A new file of the profile View → Proof Setup targets: redraw.
|
||||
touch_all(s);
|
||||
} else {
|
||||
// Documents behind the front one draw through their own profiles: those assigned it redraw.
|
||||
@@ -266,7 +266,7 @@ fn remove_profile(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if active.rgb == name || active.cmyk == name {
|
||||
use_front_profiles(s);
|
||||
}
|
||||
// The CMYK profile View → Proof Setup targets: redraw.
|
||||
// The profile View → Proof Setup targets: redraw.
|
||||
if proof_targets(&info.name) {
|
||||
touch_all(s);
|
||||
}
|
||||
@@ -285,9 +285,9 @@ fn touch_assigned(s: &mut Session, name: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether View → Proof Setup targets the CMYK profile `name`.
|
||||
/// Whether View → Proof Setup targets the CMYK or RGB profile `name`.
|
||||
fn proof_targets(name: &str) -> bool {
|
||||
matches!(proof::view().setup.target, ProofTarget::Cmyk(t) if t == name)
|
||||
matches!(proof::view().setup.target, ProofTarget::Cmyk(t) | ProofTarget::Rgb(t) if t == name)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@@ -799,6 +799,8 @@ fn view_json(v: &proof::ProofView) -> Value {
|
||||
"target": v.setup.target.id(),
|
||||
"intent": v.setup.intent.id(),
|
||||
"simulatePaper": v.setup.simulate_paper,
|
||||
"preserveNumbers": v.setup.preserve_numbers,
|
||||
"simulateBlack": v.setup.simulate_black,
|
||||
"proofColors": v.proof_colors,
|
||||
"overprintPreview": v.overprint,
|
||||
"separations": v.separations,
|
||||
@@ -815,12 +817,19 @@ fn proof_setup(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
{
|
||||
return Err(bad(C, format!("unknown CMYK profile `{name}`")));
|
||||
}
|
||||
if let ProofTarget::Rgb(name) = &t
|
||||
&& !cms::profile(name).is_some_and(|k| k.kind == cms::ProfileKind::Rgb)
|
||||
{
|
||||
return Err(bad(C, format!("unknown RGB profile `{name}`")));
|
||||
}
|
||||
v.setup.target = t;
|
||||
}
|
||||
if let Some(i) = intent_param(p, C)? {
|
||||
v.setup.intent = i;
|
||||
}
|
||||
v.setup.simulate_paper = switch_or(p, "simulatePaper", v.setup.simulate_paper, C)?;
|
||||
v.setup.preserve_numbers = switch_or(p, "preserveNumbers", v.setup.preserve_numbers, C)?;
|
||||
v.setup.simulate_black = switch_or(p, "simulateBlack", v.setup.simulate_black, C)?;
|
||||
if let Some(on) = on_param(p, "proof", C)? {
|
||||
v.proof_colors = on;
|
||||
}
|
||||
|
||||
@@ -610,6 +610,44 @@ fn proof_setup_simulates_tritanopia() {
|
||||
s.execute("view.proofSetup", &json!({"target": "workingCmyk", "proof": false})).unwrap();
|
||||
}
|
||||
|
||||
/// View › Proof Setup › Customize's settings: an RGB profile as the device, Preserve Numbers and
|
||||
/// Simulate Black Ink, kept in the proof view, read back and drawn; bad values are refused and
|
||||
/// leave the view as it was.
|
||||
#[test]
|
||||
fn proof_setup_takes_the_custom_proof_settings() {
|
||||
let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let _v = DefaultView::new();
|
||||
let mut s = session();
|
||||
rect(&mut s, 0.0, 0.0, 100.0, 100.0, json!("#000000"));
|
||||
let r = s.execute("view.proofSetup", &json!({})).unwrap();
|
||||
assert_eq!((r["preserveNumbers"].as_bool(), r["simulateBlack"].as_bool()), (Some(false), Some(false)));
|
||||
let device = format!("cmyk:{}", cms::GENERIC_CMYK);
|
||||
let r = s.execute("view.proofSetup", &json!({"target": device, "simulateBlack": true, "proof": true})).unwrap();
|
||||
assert_eq!((r["target"].as_str(), r["simulateBlack"].as_bool(), r["proofColors"].as_bool()), (Some(device.as_str()), Some(true), Some(true)));
|
||||
let setup = vectorcraft_render::proof::active_proof().unwrap();
|
||||
assert!(setup.simulate_black && !setup.preserve_numbers);
|
||||
let doc = s.doc().unwrap().doc.clone();
|
||||
let gray = render(&doc, RenderOptions { proof: Some(setup.clone()), ..Default::default() }).pixel(50, 50);
|
||||
let black = render(&doc, RenderOptions { proof: Some(ProofSetup { simulate_black: false, ..setup }), ..Default::default() }).pixel(50, 50);
|
||||
assert!(gray[0] > black[0] + 10, "the press black shows as a gray: {gray:?} vs {black:?}");
|
||||
let rgb = format!("rgb:{}", cms::DISPLAY_P3);
|
||||
let r = s.execute("view.proofSetup", &json!({"target": rgb, "preserveNumbers": true})).unwrap();
|
||||
assert_eq!((r["target"].as_str(), r["preserveNumbers"].as_bool()), (Some(rgb.as_str()), Some(true)));
|
||||
assert_eq!(vectorcraft_render::proof::view().setup.target, ProofTarget::Rgb(cms::DISPLAY_P3.into()));
|
||||
// Unchanged settings leave the revision alone.
|
||||
let rev = s.doc().unwrap().revision;
|
||||
s.execute("view.proofSetup", &json!({"target": rgb, "preserveNumbers": true, "simulateBlack": true})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().revision, rev);
|
||||
let view = vectorcraft_render::proof::view();
|
||||
refused(&mut s, "view.proofSetup", json!({"target": "rgb:Nope"}), "unknown RGB profile `Nope`");
|
||||
refused(&mut s, "view.proofSetup", json!({"target": format!("rgb:{}", cms::GENERIC_CMYK)}), "unknown RGB profile");
|
||||
refused(&mut s, "view.proofSetup", json!({"target": "rgb:"}), "unknown RGB profile");
|
||||
refused(&mut s, "view.proofSetup", json!({"target": "workingCmyk", "preserveNumbers": "yes"}), "`preserveNumbers` must be true or false");
|
||||
refused(&mut s, "view.proofSetup", json!({"simulateBlack": 1}), "`simulateBlack` must be true or false");
|
||||
assert_eq!(vectorcraft_render::proof::view(), view, "the proof view is unchanged");
|
||||
assert_eq!(s.doc().unwrap().revision, rev, "nothing redraws");
|
||||
}
|
||||
|
||||
/// Whether the content has a DeviceCMYK fill/stroke operator (`c m y k k` / `K`).
|
||||
fn has_cmyk_op(pdf: &str) -> bool {
|
||||
let toks: Vec<&str> = pdf.split_ascii_whitespace().collect();
|
||||
|
||||
Reference in new issue
Block a user