diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 4b46e8acf6..ecef505a7c 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -1410,6 +1410,8 @@ fn prefs_set(s: &mut Session, p: &Value) -> Result { return Err(bad(cmd, e)); } } + // `colorSettings.blendTextGamma` lives in the compositor too, as `edit.colorSettings` sets it. + photocraft_compose::psblend::set_text_gamma(s.color.settings.blend_text_gamma); s.apply_prefs(); let view = s.prefs_view(); let out: Map = changes.iter().map(|(k, _)| (k.clone(), get_path(&view, k).cloned().unwrap_or(Value::Null))).collect(); @@ -1439,6 +1441,7 @@ fn prefs_reset(s: &mut Session, p: &Value) -> Result { } } s.prefs.edit(|_| ()); + photocraft_compose::psblend::set_text_gamma(s.color.settings.blend_text_gamma); s.apply_prefs(); if path.is_some_and(|path| keyed(path).is_some()) { // The removed override is absent, so reading its old path would report an error. diff --git a/crates/engine/tests/text_gamma.rs b/crates/engine/tests/text_gamma.rs index 4089dcb21b..603dbae558 100644 --- a/crates/engine/tests/text_gamma.rs +++ b/crates/engine/tests/text_gamma.rs @@ -27,4 +27,21 @@ fn blend_text_gamma_setting() { s.execute("edit.colorSettings", json!({"blendTextGamma": true})).unwrap(); assert!((s.color.settings.blend_text_gamma - 1.45).abs() < 1e-6); assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6); + + // `prefs.set` and `prefs.reset` on `colorSettings` move the compositor's gamma too (#987). + // Same function, not a second test: tests in one binary run concurrently. + let in_sync = |s: &Session| (photocraft_compose::psblend::text_gamma() - s.color.settings.blend_text_gamma).abs() < 1e-6; + s.execute("edit.colorSettings", json!({"blendTextGamma": 1.8})).unwrap(); + s.execute("prefs.set", json!({"path": "colorSettings.blendTextGamma", "value": 1.0})).unwrap(); + assert_eq!(photocraft_compose::psblend::text_gamma(), 1.0); + assert!(in_sync(&s)); + s.execute("prefs.reset", json!({"path": "colorSettings.blendTextGamma"})).unwrap(); + assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6); + assert!(in_sync(&s)); + for reset in [json!({"path": "colorSettings"}), json!({})] { + s.execute("edit.colorSettings", json!({"blendTextGamma": 1.8})).unwrap(); + s.execute("prefs.reset", reset).unwrap(); + assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6); + assert!(in_sync(&s)); + } }