Merge main into fix/painted-type-used-as-a-clipping-path-loses-its

This commit is contained in:
dotCooCoo committed 2026-11-15 00:55:33 -08:00
commit e13de6e675
56 files changed
+3513 -58

No files matched your search

+98 -2
View File
@@ -94,6 +94,50 @@ impl Intent {
}
}
/// A color management policy (Edit → Color Settings): what opening a document does with a profile
/// it is tagged with that is not the working space of its model.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Policy {
/// The document loses the profile; its color numbers stay as they are.
Off,
/// The document keeps the profile.
#[default]
PreserveEmbedded,
/// The colors are converted from the profile into the working space, which keeps their
/// appearance, and the document loses the profile.
Convert,
/// CMYK only: the document loses the profile; its color numbers stay as they are.
PreserveNumbers,
}
impl Policy {
/// The RGB policies, in menu order.
pub const RGB: [Policy; 3] = [Policy::Off, Policy::PreserveEmbedded, Policy::Convert];
/// The CMYK policies, in menu order.
pub const CMYK: [Policy; 4] = [Policy::Off, Policy::PreserveEmbedded, Policy::Convert, Policy::PreserveNumbers];
/// Parse an id of [`Policy::id`].
pub fn parse(s: &str) -> Option<Self> {
[Policy::Off, Policy::PreserveEmbedded, Policy::Convert, Policy::PreserveNumbers].into_iter().find(|p| p.id() == s)
}
pub fn id(&self) -> &'static str {
match self {
Policy::Off => "off",
Policy::PreserveEmbedded => "preserveEmbedded",
Policy::Convert => "convert",
Policy::PreserveNumbers => "preserveNumbers",
}
}
pub fn label(&self) -> &'static str {
match self {
Policy::Off => "Off",
Policy::PreserveEmbedded => "Preserve Embedded Profiles",
Policy::Convert => "Convert to Working Space",
Policy::PreserveNumbers => "Preserve Numbers",
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ProfileKind {
@@ -134,11 +178,25 @@ pub struct ColorSettings {
pub intent: Intent,
/// Black-point compensation.
pub bpc: bool,
/// The color management policy for RGB profiles (one of [`Policy::RGB`]). Settings saved
/// without one take the default.
#[serde(default)]
pub rgb_policy: Policy,
/// The color management policy for CMYK profiles. Settings saved without one take the default.
#[serde(default)]
pub cmyk_policy: Policy,
}
impl Default for ColorSettings {
fn default() -> Self {
Self { rgb: SRGB.into(), cmyk: GENERIC_CMYK.into(), intent: Intent::RelativeColorimetric, bpc: true }
Self {
rgb: SRGB.into(),
cmyk: GENERIC_CMYK.into(),
intent: Intent::RelativeColorimetric,
bpc: true,
rgb_policy: Policy::default(),
cmyk_policy: Policy::default(),
}
}
}
@@ -518,6 +576,41 @@ impl Cms {
Color::Rgb { r, g, b }
}
/// An RGB or CMYK colour of this context's space as the colour of the same model in `dest`'s
/// space that looks the same, converted with `intent` (Edit → Color Settings › Convert to
/// Working Space). RGB converts directly from profile to profile, and CMYK between two loaded
/// profiles through ProPhoto RGB ([`IccProfile::to_same_model_of`]), both with this context's
/// black-point compensation; CMYK goes through Lab when either space is built in. Grey and
/// Lab colours stay as they are.
pub fn convert_into(&self, dest: &Cms, c: &Color, intent: Intent) -> Color {
match *c {
Color::Rgb { r, g, b } => {
let icc = |s: &RgbSpace| match s {
RgbSpace::Icc(p) => Some(p.clone()),
RgbSpace::Srgb => builtin_rgb_cache(SRGB),
};
let [r, g, b] = icc(&self.rgb)
.zip(icc(&dest.rgb))
.and_then(|(s, d)| s.to_rgb_of(&d, &[r, g, b], intent, self.settings.bpc))
.unwrap_or_else(|| dest.srgb_to_rgb(self.rgb_to_srgb([r, g, b])));
Color::Rgb { r, g, b }
}
Color::Cmyk { c, m, y, k } => {
let inks = [c, m, y, k].map(|v| v.clamp(0.0, 1.0));
let direct = match (&self.cmyk, &dest.cmyk) {
(CmykSpace::Icc(s), CmykSpace::Icc(d)) => s.to_same_model_of(d, &inks, intent, self.settings.bpc),
_ => None,
};
let [c, m, y, k] = match direct.as_deref() {
Some(&[c, m, y, k]) => [c, m, y, k],
_ => dest.lab_to_cmyk(self.cmyk_to_lab(inks), intent),
};
Color::Cmyk { c, m, y, k }
}
Color::Gray { .. } | Color::Lab { .. } => *c,
}
}
/// How far (ΔE2000) the best CMYK reproduction of `c` is from `c` (0 for CMYK/grey colours).
pub fn gamut_error(&self, c: &Color) -> f32 {
match c {
@@ -966,8 +1059,11 @@ pub fn working_settings() -> ColorSettings {
}
/// Replace the working settings (Edit → Color Settings) and make them the active settings (fails,
/// leaving both unchanged, if a profile is unknown).
/// leaving both unchanged, if a profile is unknown or the RGB policy is Preserve Numbers).
pub fn set_active(settings: &ColorSettings) -> Result<(), CmsError> {
if !Policy::RGB.contains(&settings.rgb_policy) {
return Err(CmsError::Unsupported(format!("the RGB policy can't be {}", settings.rgb_policy.id())));
}
let cms = Arc::new(Cms::new(settings)?);
*WORKING.write().unwrap_or_else(|e| e.into_inner()) = Some(cms.clone());
install(cms);
+78
View File
@@ -34,6 +34,17 @@ type Xf = Option<Arc<TransformF32Executor>>;
/// generation only lets the cache drop what reloads left behind.
type DirectKey = (u64, u64, usize, bool);
/// The transforms of [`IccProfile::to_same_model_of`]: into ProPhoto RGB's primaries with linear
/// tone curves, where black-point compensation is a linear remap, and from there into the
/// destination.
struct SameModel {
into: Arc<TransformF32Executor>,
out_of: Arc<TransformF32Executor>,
/// The source's and the destination's black as luminance in the linear space (both 0 without
/// compensation).
black: [f32; 2],
}
/// A parsed ICC profile plus lazily-built transforms to/from sRGB.
pub struct IccProfile {
pub name: String,
@@ -49,6 +60,9 @@ pub struct IccProfile {
/// Direct transforms into other RGB profiles ([`Self::to_rgb_of`]), by destination, intent
/// and black-point compensation.
direct: Mutex<Vec<(DirectKey, Option<Arc<Direct>>)>>,
/// Transforms into other profiles of the same model ([`Self::to_same_model_of`]), keyed as
/// [`Self::direct`] is.
same_model: Mutex<Vec<(DirectKey, Option<Arc<SameModel>>)>>,
}
/// A transform from one profile into an RGB profile without passing through sRGB: into the
@@ -99,6 +113,7 @@ impl IccProfile {
to_srgb: Default::default(),
from_srgb: Default::default(),
direct: Mutex::new(Vec::new()),
same_model: Mutex::new(Vec::new()),
})
}
@@ -264,6 +279,69 @@ impl IccProfile {
Some(Direct { to_linear, to_dest: Some(to_dest), black })
}
/// Device values of this profile → device values of `dest`, a profile of the same model,
/// converted with `intent` through ProPhoto RGB rather than sRGB, so colours outside sRGB
/// keep their place. With `bpc` (and an intent other than absolute), this profile's black
/// maps onto the destination's black (black-point compensation). `None` when `dest` is of
/// another model or no transform can be built.
pub fn to_same_model_of(&self, dest: &IccProfile, v: &[f32], intent: Intent, bpc: bool) -> Option<Vec<f32>> {
if dest.kind != self.kind || v.len() != self.channels() {
return None;
}
let bpc = bpc && intent != Intent::AbsoluteColorimetric;
let generation = profiles_generation();
let key = (dest.id, generation, intent_index(intent), bpc);
let t = {
let mut cache = self.same_model.lock().unwrap_or_else(|e| e.into_inner());
cache.retain(|(k, _)| k.1 == generation);
match cache.iter().find(|(k, _)| *k == key) {
Some((_, t)) => t.clone(),
None => {
let t = self.build_same_model(dest, intent, bpc).map(Arc::new);
cache.push((key, t.clone()));
t
}
}
}?;
let mut lin = [0.0f32; 3];
t.into.transform(v, &mut lin).ok()?;
let [from, to] = t.black;
if from > 0.0 || to > 0.0 {
lin = lin.map(|x| to + (x - from) * (1.0 - to) / (1.0 - from));
}
let lin = lin.map(|x| x.clamp(0.0, 1.0));
let mut out = vec![0.0f32; dest.channels()];
t.out_of.transform(&lin, &mut out).ok()?;
Some(out.into_iter().map(|x| x.clamp(0.0, 1.0)).collect())
}
fn build_same_model(&self, dest: &IccProfile, intent: Intent, bpc: bool) -> Option<SameModel> {
let mut linear = rgb_space(super::PROPHOTO_RGB)?;
for trc in [&mut linear.red_trc, &mut linear.green_trc, &mut linear.blue_trc] {
*trc = Some(ToneReprCurve::Parametric(vec![1.0]));
}
linear.cicp = None;
let into = self.profile.create_transform_f32(self.layout(), &linear, Layout::Rgb, Self::opts(intent)).ok()?;
let out_of = linear.create_transform_f32(Layout::Rgb, &dest.profile, dest.layout(), Self::opts(intent)).ok()?;
let black = if bpc {
// Each profile's black: the darkest colour it reproduces, found as `build_direct`
// finds it, as luminance in the linear space.
let luminance = |p: &IccProfile, xf: &Arc<TransformF32Executor>| -> Option<f32> {
let inks = p.from_srgb([0.0; 3], Intent::RelativeColorimetric)?;
let mut lin = [0.0f32; 3];
xf.transform(&inks, &mut lin).ok()?;
let y = |c: &moxcms::Xyzd| c.y as f32;
let lum = lin[0] * y(&linear.red_colorant) + lin[1] * y(&linear.green_colorant) + lin[2] * y(&linear.blue_colorant);
Some(lum.clamp(0.0, 0.5))
};
let back = dest.profile.create_transform_f32(dest.layout(), &linear, Layout::Rgb, Self::opts(intent)).ok()?;
[luminance(self, &into)?, luminance(dest, &back)?]
} else {
[0.0; 2]
};
Some(SameModel { into, out_of, black })
}
/// Whether transforms can be built for this profile (checked at registration).
pub fn usable(&self) -> bool {
self.to_xf(Intent::RelativeColorimetric).is_some() && self.inverse_xf(Intent::RelativeColorimetric).is_some()
+36
View File
@@ -442,3 +442,39 @@ fn a_document_gets_the_same_context_for_the_same_profiles() {
let unknown = for_document(Some("no such profile"), Some(SRGB));
assert_eq!(unknown.settings(), &working_settings(), "an unknown profile or one of the other model leaves the working space");
}
/// The color management policies parse from their ids, Preserve Numbers is a CMYK policy only, and
/// settings saved before the policies existed read with the default policy.
#[test]
fn policies_parse_and_default_in_saved_settings() {
for p in Policy::CMYK {
assert_eq!(Policy::parse(p.id()), Some(p));
}
assert_eq!(Policy::parse("bogus"), None);
assert!(!Policy::RGB.contains(&Policy::PreserveNumbers));
let old: ColorSettings =
serde_json::from_str(r#"{"rgb": "sRGB IEC61966-2.1", "cmyk": "Device CMYK (uncalibrated)", "intent": "perceptual", "bpc": false}"#).unwrap();
assert_eq!((old.rgb_policy, old.cmyk_policy), (Policy::PreserveEmbedded, Policy::PreserveEmbedded));
let saved = serde_json::to_value(ColorSettings { cmyk_policy: Policy::PreserveNumbers, ..Default::default() }).unwrap();
assert_eq!((saved["rgbPolicy"].as_str(), saved["cmykPolicy"].as_str()), (Some("preserveEmbedded"), Some("preserveNumbers")));
}
/// Convert to Working Space keeps a color's appearance: an RGB color of a wide space converts into
/// sRGB, and a CMYK color of one CMYK space into another, with numbers that look the same. Grey and
/// Lab colors stay as they are.
#[test]
fn convert_into_keeps_the_appearance() {
let wide = Cms::new(&ColorSettings { rgb: WIDE_GAMUT_RGB.into(), cmyk: DEVICE_CMYK.into(), ..Default::default() }).unwrap();
let working = cms();
let rgb = Color::Rgb { r: 0.25, g: 0.4, b: 0.6 };
let moved = wide.convert_into(&working, &rgb, Intent::RelativeColorimetric);
assert_ne!(moved, rgb, "the numbers change");
assert!(de(wide.display_rgb(&rgb), working.display_rgb(&moved)) < 1.0, "{rgb:?} → {moved:?}");
let ink = Color::Cmyk { c: 0.2, m: 0.4, y: 0.6, k: 0.1 };
let moved = wide.convert_into(&working, &ink, Intent::RelativeColorimetric);
assert!(matches!(moved, Color::Cmyk { .. }) && moved != ink, "{ink:?} → {moved:?}");
assert!(delta_e2000(wide.lab(&ink), working.lab(&moved)) < 3.0, "{ink:?} → {moved:?}");
for c in [Color::Gray { k: 0.3 }, Color::Lab { l: 50.0, a: 10.0, b: -20.0 }] {
assert_eq!(wide.convert_into(&working, &c, Intent::RelativeColorimetric), c);
}
}
+52
View File
@@ -274,3 +274,55 @@ fn settings_built_before_a_reload_dont_leave_the_old_transform_to_the_new_ones()
assert!(in_srgb.iter().zip(want).any(|(a, b)| (a - b).abs() > 0.05), "sRGB {in_srgb:?} vs ProPhoto {want:?}");
assert!(in_prophoto.iter().zip(want).all(|(a, b)| (a - b).abs() < 1e-4), "after the reload {in_prophoto:?}, want {want:?}");
}
/// A CMYK profile converts into another CMYK profile, ink for ink, and refuses a profile
/// of another model or inks of the wrong count.
#[test]
fn cmyk_profiles_convert_into_each_other_directly() {
let generic = IccProfile::from_bytes(Some("A".into()), &icc_bytes(GENERIC_CMYK).unwrap()).unwrap();
let device = IccProfile::from_bytes(Some("B".into()), &icc_bytes(DEVICE_CMYK).unwrap()).unwrap();
let srgb = IccProfile::from_bytes(None, &icc_bytes(SRGB).unwrap()).unwrap();
let inks = [0.2, 0.4, 0.6, 0.1];
let out = generic.to_same_model_of(&device, &inks, Intent::RelativeColorimetric, false).unwrap();
assert_eq!(out.len(), 4);
assert!(out.iter().zip(inks).any(|(a, b)| (a - b).abs() > 0.01), "{out:?}");
assert!(generic.to_same_model_of(&srgb, &inks, Intent::RelativeColorimetric, false).is_none());
assert!(generic.to_same_model_of(&device, &inks[..3], Intent::RelativeColorimetric, false).is_none());
}
/// With black-point compensation, a CMYK profile's darkest ink converts into an ink as dark as a
/// darker profile's darkest ink, and a dark grey of a darker profile converts lighter into a
/// profile whose black is lighter; absolute colorimetric never compensates.
#[test]
fn cmyk_to_cmyk_compensates_the_black_point() {
let generic = IccProfile::from_bytes(Some("A".into()), &icc_bytes(GENERIC_CMYK).unwrap()).unwrap();
let device = IccProfile::from_bytes(Some("B".into()), &icc_bytes(DEVICE_CMYK).unwrap()).unwrap();
let rel = Intent::RelativeColorimetric;
let lightness = |p: &IccProfile, inks: &[f32]| lab::srgb_to_lab(p.to_srgb(inks, rel).unwrap()).l;
let black = |p: &IccProfile| p.from_srgb([0.0; 3], rel).unwrap();
// Generic CMYK's black is a dark grey, the uncalibrated profile's is black.
let (light, dark) = (lightness(&generic, &black(&generic)), lightness(&device, &black(&device)));
assert!(light > dark + 5.0, "{light} vs {dark}");
let into_device = |bpc| lightness(&device, &generic.to_same_model_of(&device, &black(&generic), rel, bpc).unwrap());
let (on, off) = (into_device(true), into_device(false));
assert!((on - dark).abs() < 1.5 && off > dark + 5.0, "with {on}, without {off}, the black {dark}");
let grey = device.from_srgb([0.2; 3], rel).unwrap();
let into_generic = |bpc| lightness(&generic, &device.to_same_model_of(&generic, &grey, rel, bpc).unwrap());
let (on, off) = (into_generic(true), into_generic(false));
assert!(on > off + 1.0, "with {on}, without {off}");
for (from, to, inks) in [(&generic, &device, black(&generic)), (&device, &generic, grey)] {
let abs = |bpc| from.to_same_model_of(to, &inks, Intent::AbsoluteColorimetric, bpc).unwrap();
assert_eq!(abs(true), abs(false));
}
// Convert to Working Space (Cms::convert_into) compensates as Color Settings say.
let device_name = register_icc(&icc_bytes(DEVICE_CMYK).unwrap(), Some("Test ICC Device CMYK".into())).unwrap().name;
let rich = Color::Cmyk { c: 0.9, m: 0.8, y: 0.8, k: 1.0 };
let convert = |bpc| {
let dest = Cms::new(&ColorSettings { cmyk: device_name.clone(), bpc, ..ColorSettings::default() }).unwrap();
icc_cmyk(bpc).convert_into(&dest, &rich, rel)
};
assert_ne!(convert(true), convert(false));
// White is untouched.
let white = generic.to_same_model_of(&device, &[0.0; 4], rel, true).unwrap();
assert!(white.iter().all(|v| *v < 0.01), "{white:?}");
}
+129 -3
View File
@@ -16,7 +16,7 @@ use std::collections::BTreeMap;
use std::sync::Arc;
use serde_json::{Value, json};
use vectorcraft_color::cms::{self, ColorSettings, Intent, Model, ProofTarget};
use vectorcraft_color::cms::{self, ColorSettings, Intent, Model, Policy, ProofTarget};
use vectorcraft_color::recolor::Neutral;
use vectorcraft_color::{Color, Paint};
use vectorcraft_doc::ColorMode;
@@ -37,7 +37,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Color Settings…",
["Edit"],
Some("Cmd+Shift+K"),
"{rgb?: profile, cmyk?: profile, intent?: \"perceptual\"|\"relative\"|\"saturation\"|\"absolute\", bpc?: bool} set the working spaces → {rgb, cmyk, intent, bpc, profiles: [{name, kind, builtin}]}. The desktop app and vectorcraft-cli keep them in `Color Settings.json` next to the preferences and use them again at the next start (not with VECTORCRAFT_NO_PREFS); saved settings naming a profile that is gone leave the defaults",
"{rgb?: profile, cmyk?: profile, intent?: \"perceptual\"|\"relative\"|\"saturation\"|\"absolute\", bpc?: bool, rgbPolicy?: \"off\"|\"preserveEmbedded\"|\"convert\", cmykPolicy?: \"off\"|\"preserveEmbedded\"|\"convert\"|\"preserveNumbers\"} set the working spaces and the color management policies → {rgb, cmyk, intent, bpc, rgbPolicy, cmykPolicy, profiles: [{name, kind, builtin}]}. A policy decides what opening a document (document.open, file.newFromTemplate, file.revert) does with an RGB or CMYK profile it is tagged with that is not the working space: preserveEmbedded (default) keeps it; off and preserveNumbers take it off and keep the color numbers; convert converts the colors of that model into the working space with the intent and bpc and takes it off. The open reply's warnings name each profile taken off or converted, and a document a policy changed opens with unsaved changes. The desktop app and vectorcraft-cli keep them in `Color Settings.json` next to the preferences and use them again at the next start (not with VECTORCRAFT_NO_PREFS); saved settings naming a profile that is gone leave the defaults",
always,
color_settings
),
@@ -163,12 +163,26 @@ fn on_param(p: &Value, key: &str, cmd: &str) -> Result<Option<bool>> {
switch_or(p, key, false, cmd).map(Some)
}
/// The policy `p` gives for `key`, one of `allowed`, or `None` when `p` leaves it out.
fn policy_param(p: &Value, key: &str, allowed: &[Policy], cmd: &str) -> Result<Option<Policy>> {
let Some(v) = text_param(p, key, cmd)? else { return Ok(None) };
match Policy::parse(v).filter(|x| allowed.contains(x)) {
Some(x) => Ok(Some(x)),
None => {
let ids: Vec<&str> = allowed.iter().map(Policy::id).collect();
Err(bad(cmd, format!("`{key}` must be one of {}", ids.join(", "))))
}
}
}
fn settings_json(st: &ColorSettings) -> Value {
json!({
"rgb": st.rgb,
"cmyk": st.cmyk,
"intent": st.intent.id(),
"bpc": st.bpc,
"rgbPolicy": st.rgb_policy.id(),
"cmykPolicy": st.cmyk_policy.id(),
"profiles": cms::profiles().iter().map(|p| json!({"name": p.name, "kind": p.kind, "builtin": p.builtin})).collect::<Vec<_>>(),
})
}
@@ -205,6 +219,12 @@ fn color_settings(s: &mut Session, p: &Value) -> Result<Value> {
st.intent = i;
}
st.bpc = switch_or(p, "bpc", st.bpc, C)?;
if let Some(v) = policy_param(p, "rgbPolicy", &Policy::RGB, C)? {
st.rgb_policy = v;
}
if let Some(v) = policy_param(p, "cmykPolicy", &Policy::CMYK, C)? {
st.cmyk_policy = v;
}
if st != before {
cms::set_active(&st).map_err(|e| bad(C, e.to_string()))?;
// Saved for the next start when the app attached a settings file (#6335).
@@ -530,7 +550,12 @@ pub(crate) fn set_color_mode(d: &mut vectorcraft_doc::Document, mode: ColorMode,
if !convert {
return 0;
}
let conv = mode_converter(mode, intent, grays);
convert_colors(d, &mode_converter(mode, intent, grays))
}
/// Every color of `d` that [`set_color_mode`] converts, converted with `conv` → how many colors of
/// the art changed, as [`set_color_mode`] counts them.
fn convert_colors(d: &mut vectorcraft_doc::Document, conv: &dyn Fn(&Color) -> Color) -> usize {
for sw in d.swatches_iter_mut() {
match &mut sw.paint {
Paint::Solid { color, .. } => *color = conv(color),
@@ -538,6 +563,11 @@ pub(crate) fn set_color_mode(d: &mut vectorcraft_doc::Document, mode: ColorMode,
for st in &mut g.gradient.stops {
st.color = conv(&st.color);
}
if let Some(freeform) = &mut g.freeform {
for point in &mut freeform.points {
point.color = conv(&point.color);
}
}
}
_ => {}
}
@@ -621,6 +651,102 @@ pub(crate) fn set_color_mode(d: &mut vectorcraft_doc::Document, mode: ColorMode,
in_art
}
/// Apply the color management policies of Edit → Color Settings to `d`, a document being opened:
/// each RGB or CMYK profile it is tagged with that is not the working space of its model is kept
/// (Preserve Embedded Profiles), taken off with the color numbers kept (Off, Preserve Numbers), or
/// taken off after the colors of that model were converted from it into the working space with the
/// working intent (Convert to Working Space). A profile that is not available here is taken off
/// by Off and Preserve Numbers and kept by Convert to Working Space, which has nothing to convert
/// from. → a note for each profile, and whether `d` changed.
pub(crate) fn apply_open_policies(d: &mut vectorcraft_doc::Document) -> (Vec<String>, bool) {
let working = cms::working_settings();
let (rgb, cmyk) = doc_profiles(d);
let mut notes = Vec::new();
// What each model's policy does with its profile: `None` keeps it; `Some` takes it off, after
// converting the colors from the profile it holds.
let mut decide = |label: &str, tag: Option<String>, working: &str, policy: Policy, kind: cms::ProfileKind| -> Option<Option<String>> {
let tag = tag.filter(|t| t != working)?;
let available = cms::profile(&tag).is_some_and(|p| p.kind == kind);
match policy {
Policy::PreserveEmbedded => None,
Policy::Off | Policy::PreserveNumbers => {
notes.push(format!(
"the {label} profile “{tag}” the file is tagged with was not used: Color Settings' {label} policy is {}",
policy.label()
));
Some(None)
}
Policy::Convert if available => {
notes.push(format!(
"the {label} colors were converted from the profile “{tag}” the file is tagged with into the working space “{working}”"
));
Some(Some(tag))
}
Policy::Convert => {
notes.push(format!("the {label} profile “{tag}” the file is tagged with is not available, so its colors were not converted"));
None
}
}
};
let rgb_do = decide("RGB", rgb, &working.rgb, working.rgb_policy, cms::ProfileKind::Rgb);
let cmyk_do = decide("CMYK", cmyk, &working.cmyk, working.cmyk_policy, cms::ProfileKind::Cmyk);
if rgb_do.is_none() && cmyk_do.is_none() {
return (notes, false);
}
let (from_rgb, from_cmyk) = (rgb_do.clone().flatten(), cmyk_do.clone().flatten());
if from_rgb.is_some() || from_cmyk.is_some() {
let source = cms::for_document(from_rgb.as_deref(), from_cmyk.as_deref());
let dest = cms::working();
let intent = working.intent;
let (rgb_on, cmyk_on) = (from_rgb.is_some(), from_cmyk.is_some());
let conv = |c: &Color| match c {
Color::Rgb { .. } if rgb_on => source.convert_into(&dest, c, intent),
Color::Cmyk { .. } if cmyk_on => source.convert_into(&dest, c, intent),
_ => *c,
};
convert_colors(d, &conv);
convert_setting_colors(d, &conv);
}
if rgb_do.is_some() {
d.color_profiles.rgb = None;
}
if cmyk_do.is_some() {
d.color_profiles.cmyk = None;
}
(notes, true)
}
/// The colors of `d` outside its art that [`convert_colors`] leaves, converted with `conv`: each
/// artboard's background, the transparency grid and simulated paper colors of Document Setup, and
/// the fill and stroke of the character and paragraph styles.
fn convert_setting_colors(d: &mut vectorcraft_doc::Document, conv: &dyn Fn(&Color) -> Color) {
for c in d.artboards.iter_mut().filter_map(|a| a.color.as_mut()) {
*c = conv(c);
}
for c in &mut d.setup.grid_colors {
*c = conv(c);
}
// A tint of a global swatch is the converted swatch's color at its tint, which
// [`convert_colors`] already gave it.
let bases = global_bases(d);
let mut f = |c: &Color, link: proof::Link| mode_color(c, link, &bases, conv);
for styles in [&mut d.char_styles, &mut d.para_styles] {
if !styles.iter().any(|s| s.attrs.contains_key("fill") || s.attrs.contains_key("stroke")) {
continue;
}
for def in styles.iter_mut() {
for key in ["fill", "stroke"] {
let Some(value) = def.attrs.get_mut(key) else { continue };
let Ok(mut paint) = serde_json::from_value::<Paint>(value.clone()) else { continue };
map_paint_colors(&mut paint, &mut f);
if let Ok(v) = serde_json::to_value(&paint) {
*value = v;
}
}
}
}
}
/// [`proof::map_node_colors`] over `n`'s subtree, then [`map_more_colors`].
fn map_art_colors(n: &mut vectorcraft_doc::Node, f: &mut dyn FnMut(&Color, proof::Link) -> Color) {
proof::map_node_colors(n, f);
+1 -1
View File
@@ -9,7 +9,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Open Document",
[],
None,
"{path | name | dataBase64 (a file's path, or its name with its bytes), pages?: \"2-3, 5\" (PDF/.ai: 1-based, default all; one artboard each) | page?: n, cropTo?: bounding|art|crop (default)|trim|bleed|media (the box each artboard gets; bounding: the art's bounds; trim: the bleed box round it becomes the document's bleed; a PDF-compatible .ai or a PDF saved with its editing data opens on its trim boxes for crop), password? (encrypted PDFs; see document.pdfInfo), textAs?: text (default: point type per line, lines wrapped in a frame as area type where they lay out the same, in the file's fonts by name; missing ones are listed in warnings) | outlines (glyph paths), layers?: true (default: optional content groups become layers with their visibility, print state and lock — art that is off comes in as a hidden layer; other art goes to a layer per page; a PSD file's layers become layers holding their pixels, with their names, visibility, opacity and blend modes, groups as layers of sublayers, layer masks as opacity masks, clipped layers and layers in blend modes VectorCraft doesn't have merged with the layers below) | false (one layer per page, without the art that is off; Save then asks for a name; a PSD file opens as its merged image), hiddenLayers?: false (a PSD file's hidden layers come in hidden instead of being left out), editingData?: true (default: an EPS, .ai or PDF that carries its editor's own copy of the art opens from it, with its layers, hidden objects, guides, artboards and the art outside them; a .ai or PDF whose type shows opens from its PDF part with textAs: outlines) | \"always\" (as true, and a .ai's editing copy is used even where it draws differently from its PDF part, which can be older; the warnings say so) | false (only what its page or PDF part prints, for print pipelines; a .ai saved without PDF compatibility then can't be opened), legacyNameEncoding?: windows-1252 (default) | macintosh | windows-949 (also euc-kr) | shift_jis | gbk | big5 (the code page names in the editing data of a .ai or an EPS are read in when they aren't UTF-8: layers, objects, artboards, colors, gradients, patterns, graphic styles, swatches, brushes, symbols, variables and data sets, and data sets' text values; warnings list the first three such names as read, and count the rest), colorMode?: rgb|cmyk (the mode the document opens in, its colours converted as file.documentColorMode does, grays? as there; default: the file's — a PDF keeps CMYK, Gray and spot inks (spot swatches at a tint) and opens in CMYK when painted mostly in CMYK), grays?: as file.documentColorMode, dxf?: {layout?: \"Model\" (default) | a paper layout's name (document.dxfInfo lists them), unit?, scale? (the ratio: 1 unit of the art = scale drawing units; default: the drawing at 1:1 in its own unit), fit?: false (scale to fit an artboard of fitTo?: [612, 792], turned to the art's orientation), scaleLineweights?: false (lineweights scale with the art), center?: true (false: the drawing's origin on the artboard's bottom-left corner; fitted art's bottom-left corner), mergeLayers?: false (all art on one layer)} (DXF), crop?: as cropTo (its older name), linkPages?: false (true: each page `pages` picks of a PDF or PDF-compatible .ai opens as a placed document linked to that page of the file, as file.place with link places one, on an artboard of its cropTo box (bounding: its art's bounds; a blank page: its crop box; a PDF-compatible .ai: its trim box for crop; on its trim box a page shows its bleed box round the artboard and gives the document its bleed), in a row 36 pt apart (on trim boxes, plus the bleed on both sides), and a layer named after the page; links.embed makes a page editable art; refused for any other file, without a path, with a password or with textAs: outlines; Save then asks for a name), importer?: \"plugin.<id>\" (an importer plug-in's format id, see document.formats: it opens the file, which must have an extension it lists, also one a built-in format reads), params?: {…} (the importer's own parameters, see plugin.info)} → {index, title, format, warnings, restored, missingLinks, modifiedLinks, updatedLinks: [{name, path, ids}]}; any readable format (see document.formats): .vectorcraft/.drawcraft, .svg/.svgz, .pdf/.ai, .ait, ASCII .dxf (each DXF layer with art a layer; blocks symbols; what can't come in is listed in warnings), PNG/JPEG/GIF/WebP/TIFF/BMP (an image opens as a document of its size at the resolution it declares, as file.place sizes it; 72 ppi, 1 px = 1 pt, when it declares none), .emf/.wmf (one artboard, the picture's frame; records VectorCraft doesn't read are skipped with one warning), PICT .pct/.pic/.pict (QuickDraw versions 1 and 2, with or without the file's 512-byte header: one artboard, the picture's frame; shapes, lines and regions as paths, text as point type, bitmaps, pixel maps and QuickTime JPEG images as images; what isn't read is listed in warnings), HP-GL plot files .plt/.hpgl/.hgl/.hpg ( Line truncated
"{path | name | dataBase64 (a file's path, or its name with its bytes), pages?: \"2-3, 5\" (PDF/.ai: 1-based, default all; one artboard each) | page?: n, cropTo?: bounding|art|crop (default)|trim|bleed|media (the box each artboard gets; bounding: the art's bounds; trim: the bleed box round it becomes the document's bleed; a PDF-compatible .ai or a PDF saved with its editing data opens on its trim boxes for crop), password? (encrypted PDFs; see document.pdfInfo), textAs?: text (default: point type per line, lines wrapped in a frame as area type where they lay out the same, in the file's fonts by name; missing ones are listed in warnings) | outlines (glyph paths), layers?: true (default: optional content groups become layers with their visibility, print state and lock — art that is off comes in as a hidden layer; other art goes to a layer per page; a PSD file's layers become layers holding their pixels, with their names, visibility, opacity and blend modes, groups as layers of sublayers, layer masks as opacity masks, clipped layers and layers in blend modes VectorCraft doesn't have merged with the layers below) | false (one layer per page, without the art that is off; Save then asks for a name; a PSD file opens as its merged image), hiddenLayers?: false (a PSD file's hidden layers come in hidden instead of being left out), editingData?: true (default: an EPS, .ai or PDF that carries its editor's own copy of the art opens from it, with its layers, hidden objects, guides, artboards and the art outside them; a .ai or PDF whose type shows opens from its PDF part with textAs: outlines) | \"always\" (as true, and a .ai's editing copy is used even where it draws differently from its PDF part, which can be older; the warnings say so) | false (only what its page or PDF part prints, for print pipelines; a .ai saved without PDF compatibility then can't be opened), legacyNameEncoding?: windows-1252 (default) | macintosh | windows-949 (also euc-kr) | shift_jis | gbk | big5 (the code page names in the editing data of a .ai or an EPS are read in when they aren't UTF-8: layers, objects, artboards, colors, gradients, patterns, graphic styles, swatches, brushes, symbols, variables and data sets, and data sets' text values; warnings list the first three such names as read, and count the rest), colorMode?: rgb|cmyk (the mode the document opens in, its colours converted as file.documentColorMode does, through the profiles the document keeps after the color management policies of edit.colorSettings, grays? as there; default: the file's — a PDF keeps CMYK, Gray and spot inks (spot swatches at a tint) and opens in CMYK when painted mostly in CMYK), grays?: as file.documentColorMode, dxf?: {layout?: \"Model\" (default) | a paper layout's name (document.dxfInfo lists them), unit?, scale? (the ratio: 1 unit of the art = scale drawing units; default: the drawing at 1:1 in its own unit), fit?: false (scale to fit an artboard of fitTo?: [612, 792], turned to the art's orientation), scaleLineweights?: false (lineweights scale with the art), center?: true (false: the drawing's origin on the artboard's bottom-left corner; fitted art's bottom-left corner), mergeLayers?: false (all art on one layer)} (DXF), crop?: as cropTo (its older name), linkPages?: false (true: each page `pages` picks of a PDF or PDF-compatible .ai opens as a placed document linked to that page of the file, as file.place with link places one, on an artboard of its cropTo box (bounding: its art's bounds; a blank page: its crop box; a PDF-compatible .ai: its trim box for crop; on its trim box a page shows its bleed box round the artboard and gives the document its bleed), in a row 36 pt apart (on trim boxes, plus the bleed on both sides), and a layer named after the page; links.embed makes a page editable art; refused for any other file, without a path, with a password or with textAs: outlines; Save then asks for a name), importer?: \"plugin.<id>\" (an importer plug-in's format id, see document.formats: it opens the file, which must have an extension it lists, also one a built-in format reads), params?: {…} (the importer's own parameters, see plugin.info)} → {index, title, format, warnings, restored, missingLinks, modifiedLinks, updatedLinks: [{name, path, ids}]}; the color management policies of edit.colorSettings keep, take off or convert from the profiles the file is tagged with, their notes go to warnings, and a document they changed opens with unsaved changes; any readable format (see document.formats): .vectorcraft/.drawcraft, .svg/.svgz, .pdf/.ai, .ait, ASCII .dxf (each DXF layer with art a layer; blocks symbols; what can't come in is listed in warnings), PNG/JPEG/GIF/WebP/TIFF/BMP (an image opens as a document of its size at the resolution it declares, as file.place sizes it; 72 ppi, 1 px = 1 pt, when it declares none), .emf/.wmf (one artboard, the picture's frame; records VectorCraft doesn't read are skipped with one warning), PICT .pct/.pic/.p Line truncated
always,
load::open
),
+52 -10
View File
@@ -660,6 +660,17 @@ pub struct ReadFile {
path: Option<String>,
/// What became of its linked files.
links: Resolved,
/// Whether the color management policies changed the document ([`apply_policies`]).
policy_changed: bool,
}
/// Edit › Color Settings: the color management policies keep, take off or convert from the
/// profiles the document `loaded` holds is tagged with, and their notes go to its warnings →
/// whether they changed the document.
fn apply_policies(loaded: &mut Loaded) -> bool {
let (notes, changed) = crate::cmd::colormgmt::apply_open_policies(&mut loaded.doc);
loaded.warnings.extend(notes);
changed
}
#[cfg(test)]
@@ -680,17 +691,35 @@ impl ReadFile {
/// ([`super::importer`]).
pub fn read_for_open(name: &str, bytes: &[u8], path: Option<String>, p: &Value, update_links: bool, low_res_proxy_eps: bool) -> Result<ReadFile> {
let opts = LoadOptions::from_params("document.open", p)?;
let mut loaded = if opts.link_pages {
linked_pages(name, bytes, path.as_deref(), &opts)?
let (mut loaded, policy_changed) = if opts.link_pages {
let mut loaded = linked_pages(name, bytes, path.as_deref(), &opts)?;
let changed = apply_policies(&mut loaded);
(loaded, changed)
} else {
match super::importer::pick(name, bytes, p)? {
Some(plugin) => super::importer::load(name, bytes, &plugin, p)?,
None => load_with(name, bytes, &opts)?,
Some(plugin) => {
let mut loaded = super::importer::load(name, bytes, &plugin, p)?;
let changed = apply_policies(&mut loaded);
(loaded, changed)
}
None => {
// The color mode `p` asks for converts the colors after the policies did, through
// the profiles the document keeps.
let mut loaded = load_with(name, bytes, &LoadOptions { color_mode: None, ..opts.clone() })?;
let changed = apply_policies(&mut loaded);
if let Some(mode) = opts.color_mode.filter(|m| *m != loaded.doc.color_mode) {
let doc = &mut loaded.doc;
vectorcraft_color::cms::with_active(super::super::colormgmt::doc_cms(doc), || {
super::super::colormgmt::set_color_mode(doc, mode, true, None, opts.grays);
});
}
(loaded, changed)
}
}
};
let links = crate::cmd::links::resolve(&mut loaded.doc, crate::cmd::links::LinkBase::file(path.as_deref()), update_links, low_res_proxy_eps);
Session::refresh_text_bounds(&mut loaded.doc);
Ok(ReadFile { loaded, opts, path, links })
Ok(ReadFile { loaded, opts, path, links, policy_changed })
}
/// The PDF `name` (`bytes`, read from `path`) opened with `linkPages`: its pages as placed documents
@@ -705,7 +734,7 @@ fn linked_pages(name: &str, bytes: &[u8], path: Option<&str>, opts: &LoadOptions
/// The second half of [`open_bytes_with`]: open a file [`read_for_open`] read as the new active
/// document → `document.open`'s result.
pub fn open_read(s: &mut Session, file: ReadFile) -> Result<Value> {
open_loaded(s, file.loaded, file.links, file.path, &file.opts, false)
open_loaded(s, file.loaded, file.links, file.path, &file.opts, false, file.policy_changed)
}
/// File → New from Template: any readable file (at `path`, if it is one: its links are looked for
@@ -717,14 +746,24 @@ pub fn open_template(s: &mut Session, name: &str, bytes: &[u8], path: Option<&st
"only this Affinity file's embedded preview could be read: use File › Open to see it with its warning, or export SVG or PDF from Affinity first",
));
}
let policy_changed = apply_policies(&mut loaded);
let base = crate::cmd::links::LinkBase::file(path);
let links = crate::cmd::links::resolve(&mut loaded.doc, base, s.prefs.update_links == "automatically", s.prefs.low_res_proxy_eps);
open_loaded(s, loaded, links, path.map(str::to_string), &LoadOptions::default(), true)
open_loaded(s, loaded, links, path.map(str::to_string), &LoadOptions::default(), true, policy_changed)
}
/// Make a loaded file the new active document; `links` is what became of its linked files, and
/// `opts` are the options it was read with.
fn open_loaded(s: &mut Session, loaded: Loaded, links: Resolved, path: Option<String>, opts: &LoadOptions, as_template: bool) -> Result<Value> {
/// Make a loaded file the new active document; `links` is what became of its linked files, `opts`
/// are the options it was read with, and `policy_changed` says whether the color management
/// policies changed it (it then opens with unsaved changes).
fn open_loaded(
s: &mut Session,
loaded: Loaded,
links: Resolved,
path: Option<String>,
opts: &LoadOptions,
as_template: bool,
policy_changed: bool,
) -> Result<Value> {
let Loaded { mut doc, format, warnings, restored, converted, native_pdf_compatible, .. } =
loaded.with_grid_prefs(&s.prefs).with_unit_prefs(&s.prefs);
// EPS now has an ordinary Save path. Its preview, partial-program and damaged-editing
@@ -765,6 +804,9 @@ fn open_loaded(s: &mut Session, loaded: Loaded, links: Resolved, path: Option<St
let converted = saves_back && converted && s.prefs.append_converted;
let index = s.add_document(doc, path);
let st = s.doc_mut()?;
if policy_changed {
st.mark_unsaved();
}
if let Some(pdf) = native_pdf_compatible {
st.save_options.insert("pdfCompatible".into(), json!(pdf));
}
+12 -3
View File
@@ -1239,14 +1239,23 @@ fn revert(s: &mut Session, _: &Value) -> Result<Value> {
let bytes = read_file(&path).map_err(|e| super::access::naming_in_error(e, &path))?;
let Loaded { mut doc, native_pdf_compatible, .. } = load(&path, &bytes)?.with_grid_prefs(&s.prefs).with_unit_prefs(&s.prefs);
doc.template = false;
// The color management policies apply as when the file is opened.
let (notes, policy_changed) = crate::cmd::colormgmt::apply_open_policies(&mut doc);
// Back to the saved file: its recovery copy has nothing left to recover.
let uid = s.doc()?.uid;
crate::cmd::recovery::forget(s, uid);
s.replace_document(index, doc);
if policy_changed {
s.doc_mut()?.mark_unsaved();
}
if let Some(pdf) = native_pdf_compatible {
s.doc_mut()?.save_options.insert("pdfCompatible".into(), json!(pdf));
}
Ok(json!({ "path": path }))
let mut reply = json!({ "path": path });
if !notes.is_empty() {
reply["warnings"] = json!(notes);
}
Ok(reply)
}
/// `file.formatOptions`: a writable format's options with the values Save would use.
@@ -1345,7 +1354,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
"New from Template…",
["File"],
Some("Cmd+Shift+N"),
"{path} or {name, dataBase64}: open a template (or any readable file) as a new untitled document → {index, title, format, warnings}",
"{path} or {name, dataBase64}: open a template (or any readable file) as a new untitled document; the color management policies of edit.colorSettings apply as at document.open → {index, title, format, warnings (with the policies' notes)}",
always,
super::load::new_from_template
),
@@ -1354,7 +1363,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
"Revert",
["File"],
Some("F12"),
"{confirmed?: bool (the app's own: it asks first, then runs the command with it)} discard the changes: reload the saved file into the same tab (history cleared; the tab keeps its place and view). Saved, modified documents only; if the file can't be read the document is left as it is → {path}. The app asks first (a confirm dialog) unless confirmed: true",
"{confirmed?: bool (the app's own: it asks first, then runs the command with it)} discard the changes: reload the saved file into the same tab (history cleared; the tab keeps its place and view). Saved, modified documents only; if the file can't be read the document is left as it is → {path, warnings?: the notes of the color management policies of edit.colorSettings, which apply as at document.open}. The app asks first (a confirm dialog) unless confirmed: true",
can_revert,
revert
),
+167 -1
View File
@@ -823,7 +823,13 @@ fn color_settings_come_back_in_the_next_session() {
a.execute("edit.colorSettings", &json!({})).unwrap();
assert!(!file.exists(), "nothing to keep before the settings change");
a.execute("edit.colorSettings", &json!({"rgb": loaded, "cmyk": cms::DEVICE_CMYK, "intent": "perceptual", "bpc": false})).unwrap();
let chosen = cms::ColorSettings { rgb: loaded.into(), cmyk: cms::DEVICE_CMYK.into(), intent: cms::Intent::Perceptual, bpc: false };
let chosen = cms::ColorSettings {
rgb: loaded.into(),
cmyk: cms::DEVICE_CMYK.into(),
intent: cms::Intent::Perceptual,
bpc: false,
..cms::ColorSettings::default()
};
assert_eq!(cms::active_settings(), chosen);
// The next start begins with the defaults and without the loaded profile, which the profile
@@ -865,3 +871,163 @@ fn saved_color_settings_that_cannot_be_used_leave_the_defaults() {
assert!(!saved.bpc && saved.cmyk == cms::GENERIC_CMYK, "written over by the next change: {saved:?}");
}
}
/// Edit › Color Settings' color management policies decide what opening a document tagged with
/// profiles other than the working spaces does with them: Preserve Embedded Profiles keeps them,
/// Off and Preserve Numbers take them off and keep the color numbers, and Convert to Working Space
/// converts the colors into the working spaces, keeping how they look, and takes them off. A
/// document a policy changed opens with unsaved changes, and the open reply names each profile.
/// A profile that is the working space stays, and File › Revert and File › New from Template apply
/// the policies too.
#[test]
fn color_management_policies_keep_take_off_or_convert_a_tagged_profile() {
let _g = settings();
let dir = fresh_dir("policies");
let _reset = ColorSettingsReset { profile: None, paths: vec![dir.clone()] };
std::fs::create_dir_all(&dir).unwrap();
let tagged = dir.join("tagged.vectorcraft");
let mut s = session();
let (blue, ink) = (rect(&mut s, 0.0, 0.0, 10.0, 10.0), rect(&mut s, 20.0, 0.0, 10.0, 10.0));
exec(&mut s, "paint.setFill", json!({"ids": [blue.0], "color": "#3366cc"}));
exec(&mut s, "paint.setFill", json!({"ids": [ink.0], "color": {"c": 20, "m": 40, "y": 60, "k": 10}}));
exec(&mut s, "edit.assignProfile", json!({"rgb": cms::WIDE_GAMUT_RGB, "cmyk": cms::DEVICE_CMYK}));
// An artboard background, a character style's fill and a freeform gradient swatch, colors
// outside the art.
let paper = vectorcraft_color::Color::Rgb { r: 0.9, g: 0.8, b: 0.6 };
let free = rect(&mut s, 40.0, 0.0, 10.0, 10.0);
select(&mut s, &[free]);
exec(&mut s, "paint.setFill", json!({"gradient": {"kind": "freeform"}}));
exec(&mut s, "paint.freeform.setPoint", json!({"index": 0, "color": "#e6cc99", "stroke": false}));
{
let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc);
d.artboards[0].color = Some(paper);
let mut style = vectorcraft_doc::TextStyleDef { name: "Inked".into(), attrs: Default::default() };
style.attrs.insert("fill".into(), serde_json::to_value(vectorcraft_color::Paint::solid(paper)).unwrap());
d.char_styles.push(style);
let paint = d.node(free).unwrap().appearance.fill().unwrap().paint.clone();
d.swatches.push(vectorcraft_color::Swatch { name: "Free".into(), paint, global: false, spot: false });
}
exec(&mut s, "file.saveAs", json!({"path": tagged.to_str().unwrap()}));
let settings_colors = |s: &Session| {
let d = &s.doc().unwrap().doc;
let style = serde_json::from_value::<vectorcraft_color::Paint>(d.char_styles[0].attrs["fill"].clone()).unwrap();
(d.artboards[0].color.unwrap(), style.color().unwrap())
};
// The first point of the freeform swatch and of the freeform fill.
let free_points = |s: &Session| {
let d = &s.doc().unwrap().doc;
let first = |p: &vectorcraft_color::Paint| match p {
vectorcraft_color::Paint::Gradient(g) => g.freeform.as_ref().map(|f| f.points[0].color),
_ => None,
};
let swatch = d.swatches.iter().find(|w| w.name == "Free").and_then(|w| first(&w.paint)).unwrap();
(swatch, first(&d.node(free).unwrap().appearance.fill().unwrap().paint).unwrap())
};
let (free0, _) = free_points(&s);
let fill = |s: &Session, id| s.doc().unwrap().doc.node(id).and_then(|n| n.appearance.fill()).and_then(|f| f.paint.color()).unwrap();
let (blue0, ink0) = (fill(&s, blue), fill(&s, ink));
let source = cms::for_document(Some(cms::WIDE_GAMUT_RGB), Some(cms::DEVICE_CMYK));
let notes = |r: &serde_json::Value| r["warnings"].as_array().unwrap().iter().filter(|w| w.as_str().unwrap().contains("profile")).count();
// A session that opened the file under the policies, and the open reply.
let open = |rgb: &str, cmyk: &str| {
let mut s = session();
exec(&mut s, "edit.colorSettings", json!({"rgbPolicy": rgb, "cmykPolicy": cmyk}));
let r = exec(&mut s, "document.open", json!({"path": tagged.to_str().unwrap()}));
(r, s)
};
let (r, kept) = open("preserveEmbedded", "preserveEmbedded");
assert_eq!(doc_profiles(&kept.doc().unwrap().doc), (Some(cms::WIDE_GAMUT_RGB.into()), Some(cms::DEVICE_CMYK.into())));
assert_eq!((fill(&kept, blue), fill(&kept, ink), notes(&r)), (blue0, ink0, 0));
assert!(!kept.doc().unwrap().is_dirty());
for (rgb, cmyk) in [("off", "off"), ("off", "preserveNumbers")] {
let (r, off) = open(rgb, cmyk);
assert_eq!(doc_profiles(&off.doc().unwrap().doc), (None, None), "{cmyk}");
assert_eq!((fill(&off, blue), fill(&off, ink), notes(&r)), (blue0, ink0, 2), "{cmyk}: the numbers stay");
assert!(off.doc().unwrap().is_dirty(), "{cmyk}: the document changed");
}
let (r, converted) = open("convert", "convert");
assert_eq!(doc_profiles(&converted.doc().unwrap().doc), (None, None));
assert_eq!(notes(&r), 2);
let working = cms::working();
let (blue1, ink1) = (fill(&converted, blue), fill(&converted, ink));
assert!(blue1 != blue0 && ink1 != ink0, "the numbers change: {blue1:?} {ink1:?}");
assert!(cms::delta_e2000(source.lab(&blue0), working.lab(&blue1)) < 1.0, "{blue0:?} → {blue1:?}");
assert!(cms::delta_e2000(source.lab(&ink0), working.lab(&ink1)) < 3.0, "{ink0:?} → {ink1:?}");
assert!(converted.doc().unwrap().is_dirty());
let (board, styled) = settings_colors(&converted);
assert_eq!(board, styled, "the artboard and the style convert alike");
assert!(board != paper && cms::delta_e2000(source.lab(&paper), working.lab(&board)) < 1.0, "{paper:?} → {board:?}");
assert_eq!(settings_colors(&kept), (paper, paper), "kept with the profile");
let (swatch_point, fill_point) = free_points(&converted);
assert_eq!(swatch_point, fill_point, "the freeform swatch and fill convert alike");
assert!(swatch_point != free0 && cms::delta_e2000(source.lab(&free0), working.lab(&swatch_point)) < 1.0, "{free0:?} → {swatch_point:?}");
// A color mode asked for on open converts the colors the policy converted, through the working
// spaces, also when the document in front draws through another profile.
let mut s2 = session();
exec(&mut s2, "edit.assignProfile", json!({"rgb": cms::DISPLAY_P3}));
exec(&mut s2, "edit.colorSettings", json!({"rgbPolicy": "convert", "cmykPolicy": "convert"}));
exec(&mut s2, "document.open", json!({"path": tagged.to_str().unwrap(), "colorMode": "cmyk"}));
let intent = working.settings().intent;
let want = working.convert(&blue1, cms::Model::Cmyk, intent);
let got = fill(&s2, blue);
assert!(cms::delta_e2000(working.lab(&want), working.lab(&got)) < 0.01, "{want:?} vs {got:?}");
// A profile that is the working space is kept whatever the policy.
exec(&mut s, "edit.colorSettings", json!({"rgb": cms::WIDE_GAMUT_RGB}));
let (r, same) = open("off", "off");
assert_eq!(doc_profiles(&same.doc().unwrap().doc), (Some(cms::WIDE_GAMUT_RGB.into()), None));
assert_eq!(notes(&r), 1);
exec(&mut s, "edit.colorSettings", json!({"rgb": cms::SRGB}));
// File › Revert reads the file again under the policies.
let (_, mut reverted) = open("preserveEmbedded", "preserveEmbedded");
exec(&mut reverted, "paint.setFill", json!({"ids": [blue.0], "color": "#ff0000"}));
exec(&mut reverted, "edit.colorSettings", json!({"cmykPolicy": "preserveNumbers"}));
let r = exec(&mut reverted, "file.revert", json!({"confirmed": true}));
assert_eq!(doc_profiles(&reverted.doc().unwrap().doc), (Some(cms::WIDE_GAMUT_RGB.into()), None));
assert_eq!((fill(&reverted, blue), notes(&r)), (blue0, 1));
// File › New from Template applies the policies as opening does.
let mut from_template = session();
exec(&mut from_template, "edit.colorSettings", json!({"rgbPolicy": "convert", "cmykPolicy": "off"}));
let r = exec(&mut from_template, "file.newFromTemplate", json!({"path": tagged.to_str().unwrap()}));
assert_eq!(doc_profiles(&from_template.doc().unwrap().doc), (None, None));
assert_eq!(notes(&r), 2);
assert_eq!(fill(&from_template, ink), ink0, "Off keeps the CMYK numbers");
let blue2 = fill(&from_template, blue);
assert!(blue2 != blue0 && cms::delta_e2000(source.lab(&blue0), working.lab(&blue2)) < 1.0, "{blue0:?} → {blue2:?}");
assert!(from_template.doc().unwrap().is_dirty());
}
/// The policies are checked, come back in the reply and in `Color Settings.json`, and a saved file
/// that gives the RGB policy Preserve Numbers, a CMYK policy only, leaves the defaults.
#[test]
fn color_management_policies_are_checked_and_kept() {
let _g = settings();
let dir = fresh_dir("policies-kept");
let _reset = ColorSettingsReset { profile: None, paths: vec![dir.clone()] };
let file = dir.join("Color Settings.json");
let mut s = session();
s.attach_color_settings(file.clone());
for bad in [json!({"rgbPolicy": "preserveNumbers"}), json!({"cmykPolicy": "keep"}), json!({"rgbPolicy": 1})] {
assert!(s.execute("edit.colorSettings", &bad).is_err(), "{bad}");
}
assert!(!file.exists(), "a refused change keeps nothing");
let r = exec(&mut s, "edit.colorSettings", json!({"rgbPolicy": "convert", "cmykPolicy": "preserveNumbers"}));
assert_eq!((r["rgbPolicy"].as_str(), r["cmykPolicy"].as_str()), (Some("convert"), Some("preserveNumbers")));
let saved: cms::ColorSettings = serde_json::from_slice(&std::fs::read(&file).unwrap()).unwrap();
assert_eq!((saved.rgb_policy, saved.cmyk_policy), (cms::Policy::Convert, cms::Policy::PreserveNumbers));
cms::set_active(&cms::ColorSettings::default()).unwrap();
std::fs::write(
&file,
json!({"rgb": cms::SRGB, "cmyk": cms::GENERIC_CMYK, "intent": "relative", "bpc": true, "rgbPolicy": "preserveNumbers"}).to_string(),
)
.unwrap();
let mut next = Session::new();
next.attach_color_settings(file);
assert_eq!(cms::active_settings(), cms::ColorSettings::default());
}
+7 -4
View File
@@ -274,6 +274,7 @@ fn export_within(doc: &Document, o: &AiEditingOptions, max_objects: usize) -> Re
// The objects that may keep their effects in an art style, as they are before baking (not on
// a large canvas, whose scale the styles' strokes and effects would need).
let styled = writer::styled_objects(doc);
let (symbol_styled, pattern_styled) = writer::styled_definitions(doc);
let own_styles = doc.graphic_styles != Document::new(1.0, 1.0).graphic_styles;
let links = writer::style_links(doc);
// Live geometry effects as their result, as the PDF part draws them.
@@ -311,16 +312,14 @@ fn export_within(doc: &Document, o: &AiEditingOptions, max_objects: usize) -> Re
w.reserve_swatch_gradients();
if scale == 1.0 {
w.styled = styled;
(w.symbol_styled, w.pattern_styled) = (symbol_styled, pattern_styled);
w.panel_styles();
} else if !styled.is_empty() || own_styles || links > 0 {
} else if !styled.is_empty() || !symbol_styled.is_empty() || !pattern_styled.is_empty() || own_styles || links > 0 {
w.warnings.push(writer::LARGE_CANVAS_STYLES.to_string());
}
for layer in &doc.layers {
w.layer(layer);
}
if scale == 1.0 {
w.lost_links(links);
}
// The symbols no instance uses too; their art adds definitions.
w.symbols();
// The brushes, once the layers have said whether an object is written with one.
@@ -328,6 +327,10 @@ fn export_within(doc: &Document, o: &AiEditingOptions, max_objects: usize) -> Re
// The palette first: its gradient and pattern swatches add definitions.
let mut palette = String::new();
w.palette(&mut palette);
// Once every definition is written: their opacity masks' art keeps links too.
if scale == 1.0 {
w.lost_links(links);
}
let library = w.variable_library();
let first = to_art.transform_rect_bbox(board);
let art = doc
+289
View File
@@ -6761,6 +6761,159 @@ fn hidden_and_nested_mask_art_keep_live_offset_path() {
}
}
/// An image 60 × 40 points at (10, 10) whose opacity mask, of `art`, doesn't clip.
fn masked_image_node(doc: &mut Document, art: Node) -> Node {
let im = image_node(doc, ImageBlob::png(rgb_png()), (3, 2), Affine::new([60.0, 0.0, 0.0, 40.0, 10.0, 10.0]), None);
with_mask(im, art)
}
/// A red square from (10, 10) to (70, 50) whose opacity mask, of `art`, doesn't clip.
fn masked_square(doc: &mut Document, art: Node) -> Node {
let sq = square(doc, Rect::new(10.0, 10.0, 70.0, 50.0), Color::rgb(1.0, 0.0, 0.0));
with_mask(sq, art)
}
/// `n` with an opacity mask of `art` that doesn't clip.
fn with_mask(mut n: Node, art: Node) -> Node {
n.extras_mut().mask = Some(OpacityMask { art: Arc::new(art), clip: false, invert: false, disabled: false, linked: true }.into());
n
}
/// The opacity mask art of the first object with one in `n`, its masks' art included.
fn mask_art_in(n: &Node) -> Option<Arc<Node>> {
let mut art = None;
vectorcraft_doc::swatches::walk_with_masks(n, &mut |m| {
if art.is_none()
&& let Some(mask) = m.extras().mask.as_ref()
{
art = Some(mask.art.clone());
}
});
art
}
/// The Offset Path distance of `n`'s one live effect, when that is all it has.
fn offset_path_of(n: &Node) -> Option<f64> {
match n.appearance.effects.as_slice() {
[e] if e.id == "path.offsetPath" => e.params.get("offset").and_then(serde_json::Value::as_f64),
_ => None,
}
}
/// The opacity mask art of an image in a symbol's art keeps its live effects as an art style: a
/// black path with Offset Path reads back with the effect live on the definition's mask art, when
/// the mask's art root is hidden and when the symbol is used inside another symbol's art too, and
/// both instances draw as they did.
#[test]
fn a_symbols_mask_art_keeps_live_offset_path() {
let offset = fx("path.offsetPath", serde_json::json!({"offset": 6.0}));
let made = |effects: Vec<vectorcraft_doc::Effect>, case: &str| {
let mut doc = Document::new(200.0, 100.0);
let layer = doc.layers[0].id;
let mut grown = styled_rect(&mut doc, "Grown", Rect::new(25.0, 20.0, 45.0, 40.0), solid(Color::BLACK), Paint::None, effects);
grown.visible = case != "hidden";
let im = masked_image_node(&mut doc, grown);
doc.symbols.push(Symbol { dynamic: false, name: "Picture".into(), art: Arc::new(im) });
let mut used = "Picture";
if case == "nested" {
let inner = Node::new(doc.alloc_id(), NodeKind::SymbolInstance { symbol: "Picture".into(), xf: Affine::translate((5.0, 0.0)) });
let dot = square(&mut doc, Rect::new(0.0, 0.0, 4.0, 4.0), Color::rgb(1.0, 0.0, 0.0));
let frame = group(&mut doc, vec![inner, dot], false);
doc.symbols.push(Symbol { dynamic: false, name: "Frame".into(), art: Arc::new(frame) });
used = "Frame";
}
for x in [0.0, 100.0] {
let instance = Node::new(doc.alloc_id(), NodeKind::SymbolInstance { symbol: used.into(), xf: Affine::translate((x, 20.0)) });
doc.insert(Some(layer), usize::MAX, instance).unwrap();
}
doc
};
for case in ["shown", "hidden", "nested"] {
let doc = made(vec![offset.clone()], case);
assert!(pixels_apart(&doc, &made(vec![], case)) > 0, "{case}: the effect draws nothing");
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::EFFECTS), "{case}: {:?}", out.warnings);
let back = read_back(&doc);
let picture = back.symbols.iter().find(|s| s.name == "Picture").unwrap_or_else(|| panic!("{case}: {:?}", back.symbols));
let art = mask_art_in(&picture.art).unwrap_or_else(|| panic!("{case}: no masked image in {:?}", picture.art.kind));
assert_eq!(offset_path_of(&art), Some(6.0), "{case}: {:?}", art.appearance.effects);
assert_eq!(pixels_apart(&doc, &back), 0, "{case}");
}
}
/// The opacity mask art of a square in a pattern's tile keeps its live effects as an art style: the
/// tile's black path with Offset Path reads back with the effect live, and the pattern fill draws as
/// it did.
#[test]
fn a_pattern_tiles_mask_art_keeps_live_offset_path() {
let offset = fx("path.offsetPath", serde_json::json!({"offset": 6.0}));
let made = |effects: Vec<vectorcraft_doc::Effect>| {
let mut doc = Document::new(200.0, 100.0);
let layer = doc.layers[0].id;
let grown = styled_rect(&mut doc, "Grown", Rect::new(25.0, 20.0, 45.0, 40.0), solid(Color::BLACK), Paint::None, effects);
let sq = masked_square(&mut doc, grown);
let tile = Rect::new(0.0, 0.0, 80.0, 60.0);
doc.patterns.push(vectorcraft_doc::PatternDef { tile, ..vectorcraft_doc::PatternDef::new("Masked", vec![Arc::new(sq)]) });
let fill = Paint::Pattern { pattern: "Masked".into(), xf: Affine::IDENTITY };
let filled = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(0.0, 0.0, 160.0, 60.0)), Appearance::basic(fill, Paint::None, 0.0));
doc.insert(Some(layer), usize::MAX, filled).unwrap();
doc
};
let doc = made(vec![offset]);
assert!(pixels_apart(&doc, &made(vec![])) > 0, "the effect draws nothing");
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::EFFECTS), "{:?}", out.warnings);
let back = read_back(&doc);
let def = back.pattern("Masked").unwrap_or_else(|| panic!("{:?}", back.patterns.iter().map(|p| &p.name).collect::<Vec<_>>()));
let art = def.art.iter().find_map(|a| mask_art_in(a)).expect("a masked image in the tile");
assert_eq!(offset_path_of(&art), Some(6.0), "{:?}", art.appearance.effects);
assert_eq!(pixels_apart(&doc, &back), 0);
}
/// Each opacity mask's art keeps its own art style: masks on the layers, in a symbol's art and in a
/// pattern's tile with different Offset Path distances read back with their own distances, and a
/// symbol's mask art with an effect no art style holds (Roughen) reads back without a live effect.
#[test]
fn mask_art_styles_stay_with_their_own_art() {
let mut doc = Document::new(200.0, 100.0);
let layer = doc.layers[0].id;
let masked = |doc: &mut Document, effect: vectorcraft_doc::Effect| {
let grown = styled_rect(doc, "Grown", Rect::new(25.0, 20.0, 45.0, 40.0), solid(Color::BLACK), Paint::None, vec![effect]);
masked_image_node(doc, grown)
};
let by = |d: f64| fx("path.offsetPath", serde_json::json!({"offset": d}));
let on_layer = masked(&mut doc, by(3.0));
doc.insert(Some(layer), usize::MAX, on_layer).unwrap();
let picture = masked(&mut doc, by(6.0));
doc.symbols.push(Symbol { dynamic: false, name: "Picture".into(), art: Arc::new(picture) });
let rough = masked(&mut doc, fx("distort.roughen", serde_json::json!({"size": 6.0, "relative": false, "points": "corner"})));
doc.symbols.push(Symbol { dynamic: false, name: "Rough".into(), art: Arc::new(rough) });
for (symbol, x) in [("Picture", 100.0), ("Rough", 120.0)] {
let instance = Node::new(doc.alloc_id(), NodeKind::SymbolInstance { symbol: symbol.into(), xf: Affine::translate((x, 40.0)) });
doc.insert(Some(layer), usize::MAX, instance).unwrap();
}
let grown = styled_rect(&mut doc, "Grown", Rect::new(25.0, 20.0, 45.0, 40.0), solid(Color::BLACK), Paint::None, vec![by(9.0)]);
let tile = masked_square(&mut doc, grown);
doc.patterns.push(vectorcraft_doc::PatternDef {
tile: Rect::new(0.0, 0.0, 80.0, 60.0),
..vectorcraft_doc::PatternDef::new("Masked", vec![Arc::new(tile)])
});
let fill = Paint::Pattern { pattern: "Masked".into(), xf: Affine::IDENTITY };
let filled = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(0.0, 60.0, 80.0, 100.0)), Appearance::basic(fill, Paint::None, 0.0));
doc.insert(Some(layer), usize::MAX, filled).unwrap();
let back = read_back(&doc);
let symbol_art = |name: &str| {
let s = back.symbols.iter().find(|s| s.name == name).unwrap_or_else(|| panic!("{name}: {:?}", back.symbols));
mask_art_in(&s.art).unwrap_or_else(|| panic!("{name}: no masked image"))
};
assert_eq!(offset_path_of(&image_mask_art(&back)), Some(3.0));
assert_eq!(offset_path_of(&symbol_art("Picture")), Some(6.0));
let tile = back.pattern("Masked").and_then(|p| p.art.iter().find_map(|a| mask_art_in(a))).expect("a masked image in the tile");
assert_eq!(offset_path_of(&tile), Some(9.0));
let rough = symbol_art("Rough");
assert!(rough.appearance.effects.is_empty(), "{:?}", rough.appearance.effects);
}
/// A geometry effect on an opacity mask's art that no art style holds (Roughen) is applied to the
/// art written, so the mask reads back drawing what it drew, but for pixels on its edge that the
/// written points' rounding moves.
@@ -6900,6 +7053,142 @@ fn a_filled_even_odd_object_is_written_as_its_drawn_look() {
assert_eq!(n.extras().graphic_style, None);
}
/// Links to graphic styles in pattern tiles count toward the warning about lost links: a tile's
/// object linked to a style, which is written without its link, warns; and so does an object on the
/// layers that loses its link while a tile's opacity mask art keeps its own.
#[test]
fn pattern_tile_style_links_count_toward_lost_links() {
let made = |linked_tile: bool| {
let mut doc = Document::new(200.0, 100.0);
let ap = Appearance::basic(black_fill(), Paint::None, 0.0);
let mut g = vectorcraft_doc::GraphicStyle::new("Solid", ap.clone());
g.id = 7;
doc.graphic_styles.push(g);
let mut linked = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(25.0, 20.0, 45.0, 40.0)), ap.clone());
linked.extras_mut().graphic_style = Some(7);
let art = if linked_tile {
linked
} else {
// An even-odd path is written without its link (see the test above).
let mut lost = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(100.0, 10.0, 140.0, 40.0)), ap);
lost.extras_mut().graphic_style = Some(7);
if let NodeKind::Path { rule, .. } = &mut lost.kind {
*rule = FillRule::EvenOdd;
}
put(&mut doc, lost);
masked_square(&mut doc, linked)
};
doc.patterns.push(vectorcraft_doc::PatternDef {
tile: Rect::new(0.0, 0.0, 80.0, 60.0),
..vectorcraft_doc::PatternDef::new("Linked", vec![Arc::new(art)])
});
let fill = Paint::Pattern { pattern: "Linked".into(), xf: Affine::IDENTITY };
let filled = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(0.0, 50.0, 80.0, 100.0)), Appearance::basic(fill, Paint::None, 0.0));
put(&mut doc, filled);
doc
};
for linked_tile in [true, false] {
let doc = made(linked_tile);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.iter().any(|w| w == writer::STYLE_LINKS), "{linked_tile}: {:?}", out.warnings);
}
let back = read_back(&made(false));
let tile = back.pattern("Linked").and_then(|p| p.art.iter().find_map(|a| mask_art_in(a))).expect("a masked square in the tile");
assert!(tile.extras().graphic_style.is_some(), "the tile's mask art keeps its link");
}
/// An opacity mask's art linked to a graphic style reads back linked to it.
#[test]
fn opacity_mask_art_keeps_its_graphic_style_link() {
let mut doc = Document::new(200.0, 100.0);
let ap = Appearance::basic(black_fill(), Paint::None, 0.0);
let mut g = vectorcraft_doc::GraphicStyle::new("Solid", ap.clone());
g.id = 7;
doc.graphic_styles.push(g);
let mut linked = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(25.0, 20.0, 45.0, 40.0)), ap);
linked.extras_mut().graphic_style = Some(7);
let sq = masked_square(&mut doc, linked);
put(&mut doc, sq);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::STYLE_LINKS), "{:?}", out.warnings);
let back = read_back(&doc);
let art = mask_art_in(&back.layers[0]).expect("a masked square");
let id = art.extras().graphic_style.expect("the mask's art keeps its link");
assert_eq!(back.graphic_style_by_id(id).map(|g| g.name.as_str()), Some("Solid"));
}
/// A link written in a pattern tile's opacity mask art that the object limit then leaves out with
/// the rest of the tile is not counted as kept: at every limit where the style isn't written, the
/// export warns that the link is lost.
#[test]
fn mask_art_links_left_out_at_the_object_limit_are_reported_lost() {
let mut doc = Document::new(200.0, 100.0);
let layer = doc.layers[0].id;
let ap = Appearance::basic(black_fill(), Paint::None, 0.0);
let mut g = vectorcraft_doc::GraphicStyle::new("Solid", ap.clone());
g.id = 7;
doc.graphic_styles.push(g);
let mut linked = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(25.0, 20.0, 45.0, 40.0)), ap);
linked.extras_mut().graphic_style = Some(7);
let mut art = vec![Arc::new(masked_square(&mut doc, linked))];
for i in 0..6 {
let x = 2.0 + 12.0 * f64::from(i);
art.push(Arc::new(square(&mut doc, Rect::new(x, 52.0, x + 8.0, 58.0), Color::rgb(0.0, 0.0, 1.0))));
}
doc.patterns.push(vectorcraft_doc::PatternDef { tile: Rect::new(0.0, 0.0, 80.0, 60.0), ..vectorcraft_doc::PatternDef::new("Linked", art) });
let fill = Paint::Pattern { pattern: "Linked".into(), xf: Affine::IDENTITY };
let filled = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(0.0, 0.0, 80.0, 60.0)), Appearance::basic(fill, Paint::None, 0.0));
doc.insert(Some(layer), usize::MAX, filled).unwrap();
let mut left_out = 0;
for max in 1..40 {
let out = export_within(&doc, &opts(), max).unwrap();
let text = String::from_utf8_lossy(&out.program).into_owned();
if !text.contains("(Solid) XW") {
left_out += 1;
assert!(out.warnings.iter().any(|w| w == writer::STYLE_LINKS), "{max}: {:?}", out.warnings);
}
}
assert!(left_out > 0 && left_out < 39, "{left_out}");
}
/// The links of opacity masks' art in a symbol no instance uses and in a pattern only the Swatches
/// panel holds are written with those definitions, after the layers, and count as kept: no warning
/// about lost links.
#[test]
fn mask_art_links_in_unused_definitions_are_not_reported_lost() {
let mut doc = Document::new(200.0, 100.0);
let ap = Appearance::basic(black_fill(), Paint::None, 0.0);
let mut g = vectorcraft_doc::GraphicStyle::new("Solid", ap.clone());
g.id = 7;
doc.graphic_styles.push(g);
let linked = |doc: &mut Document| {
let mut n = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(25.0, 20.0, 45.0, 40.0)), ap.clone());
n.extras_mut().graphic_style = Some(7);
masked_square(doc, n)
};
let unused = linked(&mut doc);
doc.symbols.push(Symbol { dynamic: false, name: "Unused".into(), art: Arc::new(unused) });
let tile = linked(&mut doc);
doc.patterns.push(vectorcraft_doc::PatternDef {
tile: Rect::new(0.0, 0.0, 80.0, 60.0),
..vectorcraft_doc::PatternDef::new("Swatch only", vec![Arc::new(tile)])
});
let swatch = Swatch {
name: "Swatch only".into(),
paint: Paint::Pattern { pattern: "Swatch only".into(), xf: Affine::IDENTITY },
global: false,
spot: false,
};
swatches_plus(&mut doc, vec![swatch]);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::STYLE_LINKS), "{:?}", out.warnings);
let back = read_back(&doc);
let symbol = back.symbols.iter().find(|s| s.name == "Unused").and_then(|s| mask_art_in(&s.art)).expect("the unused symbol's mask art");
assert!(symbol.extras().graphic_style.is_some(), "the symbol's mask art keeps its link");
let tile = back.pattern("Swatch only").and_then(|p| p.art.iter().find_map(|a| mask_art_in(a))).expect("the swatch's mask art");
assert!(tile.extras().graphic_style.is_some(), "the pattern's mask art keeps its link");
}
/// A compound path filled by the non-zero rule keeps its effects, its gradient fill and its link to
/// a graphic style.
#[test]
+26 -7
View File
@@ -28,7 +28,7 @@ mod variables;
pub(super) use brushes::BRUSHES;
#[cfg(test)]
pub(super) use envelopes::ENVELOPES;
pub(super) use styles::{LARGE_CANVAS_STYLES, style_links, styled_objects};
pub(super) use styles::{LARGE_CANVAS_STYLES, style_links, styled_definitions, styled_objects};
#[cfg(test)]
pub(super) use styles::{PANEL_EMPTY, PANEL_STYLES, STYLE_LINKS, WARPED_IMAGES, same_appearance};
@@ -133,6 +133,10 @@ struct Charges {
kept_objects: usize,
kept_symbol_nodes: u64,
left_out: usize,
/// The objects written with the graphic style they are linked to, and those of them in the
/// definitions written.
links: usize,
kept_links: usize,
}
pub(super) struct Writer<'a> {
@@ -171,6 +175,8 @@ pub(super) struct Writer<'a> {
definition_objects: usize,
/// The objects of symbol art in those definitions ([`Self::symbol_nodes`]).
definition_symbol_nodes: u64,
/// The objects in those definitions written with the graphic style they are linked to.
definition_links: usize,
/// The most objects written ([`Self::take_objects`]): the most the reader reads,
/// [`crate::import::MAX_EDITING_OBJECTS`].
pub(super) max_objects: usize,
@@ -268,6 +274,12 @@ pub(super) struct Writer<'a> {
/// The objects that may be written with an art style, as they were before baking, by id
/// ([`styles::styled_objects`]).
pub(super) styled: HashMap<NodeId, Arc<Node>>,
/// The objects of the opacity masks' art in each symbol's art and each pattern's tile art that
/// may be written with an art style, by the symbol's or pattern's name
/// ([`styles::styled_definitions`]). [`Self::define_symbol`] and [`Self::define_pattern`] write
/// a definition's art with its own as [`Self::styled`].
pub(super) symbol_styled: HashMap<String, styles::StyledMap>,
pub(super) pattern_styled: HashMap<String, styles::StyledMap>,
/// The art styles written ([`styles`]).
styles: styles::Styles,
/// An object's drawn look is being written: no object in it is written with a style, and its
@@ -365,6 +377,8 @@ impl<'a> Writer<'a> {
symbol_scales: HashMap::new(),
root_entries: None,
styled: HashMap::new(),
symbol_styled: HashMap::new(),
pattern_styled: HashMap::new(),
styles: styles::Styles::default(),
in_look: false,
drawn: 0,
@@ -376,6 +390,7 @@ impl<'a> Writer<'a> {
objects: 0,
left_out: 0,
definition_objects: 0,
definition_links: 0,
definition_symbol_nodes: 0,
max_objects: crate::import::MAX_EDITING_OBJECTS,
last_samples: None,
@@ -434,6 +449,8 @@ impl<'a> Writer<'a> {
kept_objects: self.definition_objects,
kept_symbol_nodes: self.definition_symbol_nodes,
left_out: self.left_out,
links: self.styles.links_written,
kept_links: self.definition_links,
}
}
@@ -447,15 +464,18 @@ impl<'a> Writer<'a> {
fn keep_since(&mut self, c: Charges) {
self.definition_objects = c.kept_objects + (self.objects - c.objects);
self.definition_symbol_nodes = c.kept_symbol_nodes + (self.symbol_nodes - c.symbol_nodes);
self.definition_links = c.kept_links + (self.styles.links_written - c.links);
}
/// Art written since `c` as `lines` is not used: the objects and symbol art charged since are
/// given back, except those of the definitions written since, and the images `lines` marks
/// Art written since `c` as `lines` is not used: the objects and symbol art charged since, and
/// the objects counted as written with their graphic style, are given back, except those of the
/// definitions written since, and the images `lines` marks
/// are emptied (the others keep their indices). An image whose whole copy is among them is no
/// longer written whole ([`Self::whole_images`]).
fn give_back(&mut self, c: Charges, lines: &str) {
self.objects = c.objects + (self.definition_objects - c.kept_objects);
self.symbol_nodes = c.symbol_nodes + (self.definition_symbol_nodes - c.kept_symbol_nodes);
self.styles.links_written = c.links + (self.definition_links - c.kept_links);
let mut emptied = HashSet::new();
for index in lines.split(PAYLOAD).skip(1).step_by(2) {
if let Some((i, p)) = index.parse::<usize>().ok().and_then(|i| Some((i, self.payloads.get_mut(i)?))) {
@@ -675,12 +695,11 @@ impl<'a> Writer<'a> {
if n.extras().graph.is_some() && !self.in_look && graph.is_none() {
self.warn(GRAPHS);
}
// On the layers or in an opacity mask's art, outside art cut to a clipping object: with its
// art style, when it has one.
// On the layers or in an opacity mask's art (a symbol's and a pattern tile's included),
// outside art cut to a clipping object: with its art style, when it has one.
if !self.in_look
&& ((self.hidden == 0 && self.nest == 0) || self.mask_level == Some((self.hidden, self.nest)))
&& ((self.hidden == 0 && self.nest == 0 && !self.in_symbol) || self.mask_level == Some((self.hidden, self.nest)))
&& self.clip.is_none()
&& !self.in_symbol
&& let Some(orig) = self.styled.get(&n.id).cloned()
&& self.check_left(&orig)
&& let Some(name) = self.object_style(n, &orig)
+11 -1
View File
@@ -483,6 +483,8 @@ impl Writer<'_> {
self.gs.replace(Xy::OPAQUE),
(self.clip.take(), std::mem::take(&mut self.shown)),
self.block_end,
// The tile's masks' objects are written with their art styles, those of no other art.
(std::mem::replace(&mut self.styled, self.pattern_styled.get(name).cloned().unwrap_or_default()), self.mask_level.take()),
);
// `Bg` places a gradient in a pattern's tile as on the canvas, mirrored top to bottom: its
// placement is worked out in the tile's space turned y up.
@@ -505,7 +507,15 @@ impl Writer<'_> {
self.hidden -= 1;
self.nest -= 1;
let art;
(art, (self.to_art, self.grad_space, self.canvas), self.state, self.gs, (self.clip, self.shown), self.block_end) = saved;
(
art,
(self.to_art, self.grad_space, self.canvas),
self.state,
self.gs,
(self.clip, self.shown),
self.block_end,
(self.styled, self.mask_level),
) = saved;
let art = std::mem::replace(&mut self.body, art);
self.defining.pop();
if self.left_out_since(before) {
+33 -9
View File
@@ -26,7 +26,8 @@ pub(in crate::ai_editing) const PANEL_EMPTY: &str =
pub(in crate::ai_editing) const WARPED_IMAGES: &str = "images with a Warp after the first 256 envelopes and images with a Warp are written as their drawn look, without their Warp, in the editing data for other apps";
pub(in crate::ai_editing) const STYLE_LINKS: &str = "links to graphic styles are left out of the editing data for other apps on type, images, symbol instances, knockout shapes and other objects that aren't written with their graphic style";
/// How many objects of `doc`'s layers, opacity masks and symbols are linked to a graphic style.
/// How many objects of `doc`'s layers, opacity masks, symbols and pattern tiles are linked to a
/// graphic style.
pub(in crate::ai_editing) fn style_links(doc: &Document) -> usize {
fn count(n: &Node) -> usize {
// Ruler guides are not written as objects.
@@ -37,7 +38,9 @@ pub(in crate::ai_editing) fn style_links(doc: &Document) -> usize {
let mask = n.extras().mask.as_ref().map_or(0, |m| count(&m.art));
own + mask + n.children().map_or(0, |c| c.iter().map(|m| count(m)).sum())
}
doc.layers.iter().map(|l| count(l)).sum::<usize>() + doc.symbols.iter().map(|s| count(&s.art)).sum::<usize>()
doc.layers.iter().map(|l| count(l)).sum::<usize>()
+ doc.symbols.iter().map(|s| count(&s.art)).sum::<usize>()
+ doc.patterns.iter().flat_map(|p| p.art.iter()).map(|a| count(a)).sum::<usize>()
}
/// The objects of `doc`'s layers and of their opacity masks' art that may be written with an art
@@ -48,10 +51,30 @@ pub(in crate::ai_editing) fn style_links(doc: &Document) -> usize {
/// Knockout Shape (the reader takes an object's transparency
/// from its look, which doesn't carry it). A group's members are paths, compound paths or such
/// groups, none with effects or anything baking changes.
pub(in crate::ai_editing) fn styled_objects(doc: &Document) -> HashMap<NodeId, Arc<Node>> {
fn walk(nodes: &[Arc<Node>], out: &mut HashMap<NodeId, Arc<Node>>) {
pub(in crate::ai_editing) fn styled_objects(doc: &Document) -> StyledMap {
styled_in(&doc.layers, true)
}
/// The objects that may be written with an art style, by id, as they are before baking.
pub(in crate::ai_editing) type StyledMap = HashMap<NodeId, Arc<Node>>;
/// The objects of the opacity masks' art in each of `doc`'s symbols' art, by symbol name, and in
/// each of its patterns' tile art, by pattern name, that may be written with an art style, as
/// [`styled_objects`] finds them on the layers. A definition's own objects outside its masks' art
/// are not among them, and definitions without such objects are left out.
pub(in crate::ai_editing) fn styled_definitions(doc: &Document) -> (HashMap<String, StyledMap>, HashMap<String, StyledMap>) {
let symbols = doc.symbols.iter().map(|s| (s.name.clone(), styled_in(std::slice::from_ref(&s.art), false)));
let patterns = doc.patterns.iter().map(|p| (p.name.clone(), styled_in(&p.art, false)));
let kept = |(_, m): &(String, StyledMap)| !m.is_empty();
(symbols.filter(kept).collect(), patterns.filter(kept).collect())
}
/// The objects of `nodes` that may be written with an art style ([`styled_objects`]): with `own`,
/// `nodes` and their members as well as their opacity masks' art, else their masks' art only.
fn styled_in(nodes: &[Arc<Node>], own: bool) -> StyledMap {
fn walk(nodes: &[Arc<Node>], own: bool, out: &mut StyledMap) {
for n in nodes {
if candidate(n) {
if own && candidate(n) {
out.insert(n.id, n.clone());
}
if let Some(m) = n.extras().mask.as_ref() {
@@ -59,7 +82,7 @@ pub(in crate::ai_editing) fn styled_objects(doc: &Document) -> HashMap<NodeId, A
if !art.visible {
Arc::make_mut(&mut art).visible = true;
}
walk(std::slice::from_ref(&art), out);
walk(std::slice::from_ref(&art), true, out);
}
// A group's members are written with a style of their own only when the group is written
// without one. Baking a container with effects of its own changes its members, which
@@ -67,12 +90,12 @@ pub(in crate::ai_editing) fn styled_objects(doc: &Document) -> HashMap<NodeId, A
if let NodeKind::Layer { children, .. } | NodeKind::Group { children, .. } = &n.kind
&& !bakes_members(n)
{
walk(children, out);
walk(children, own, out);
}
}
}
let mut out = HashMap::new();
walk(&doc.layers, &mut out);
walk(nodes, own, &mut out);
out
}
@@ -613,7 +636,8 @@ impl Writer<'_> {
let doc = self.doc;
// A new document's styles are what the reader gives a file without a style list; they are
// still written when an object is linked to one of them, so that it keeps its link.
let linked = self.styled.values().any(|n| n.extras().graphic_style.is_some());
let definitions = self.symbol_styled.values().chain(self.pattern_styled.values()).flat_map(HashMap::values);
let linked = self.styled.values().chain(definitions).any(|n| n.extras().graphic_style.is_some());
if !linked && doc.graphic_styles == Document::new(1.0, 1.0).graphic_styles {
return;
}
@@ -252,6 +252,8 @@ impl Writer<'_> {
self.root_entries.take(),
std::mem::take(&mut self.wrote_pattern),
(std::mem::take(&mut self.wrote_fixed), std::mem::replace(&mut self.inner_scale, 1.0)),
// The art's masks' objects are written with their art styles, those of no other art.
(std::mem::replace(&mut self.styled, self.symbol_styled.get(name).cloned().unwrap_or_default()), self.mask_level.take()),
);
// Gradients' matrices and instances' matrices are written about the canvas point of art
// space's origin, y up; `Bg` places a gradient on the art as it lies in the symbol's space.
@@ -309,6 +311,7 @@ impl Writer<'_> {
self.root_entries,
self.wrote_pattern,
(self.wrote_fixed, self.inner_scale),
(self.styled, self.mask_level),
) = saved;
self.doc = page_doc;
(self.in_look, self.drawn) = (in_look, drawn);
+8 -2
View File
@@ -1399,8 +1399,9 @@ impl<'a> Reader<'a> {
}
/// Link the objects of `links` among `nodes` to their graphic style's id, each only when it has its
/// style's appearance and transparency (`styles`, whose ids are 1, 2, … in order). A path, which
/// has no contents, takes the style's contents slot.
/// style's appearance and transparency (`styles`, whose ids are 1, 2, … in order), their members
/// and their opacity masks' art included. A path, which has no contents, takes the style's contents
/// slot.
fn link_styles(nodes: &mut [Arc<Node>], links: &HashMap<NodeId, u32>, styles: &[GraphicStyle], depth: usize) {
if depth > MAX_DEPTH {
return;
@@ -1419,6 +1420,11 @@ fn link_styles(nodes: &mut [Arc<Node>], links: &HashMap<NodeId, u32>, styles: &[
n.extras_mut().graphic_style = Some(*id);
}
}
if n.extras().mask.is_some()
&& let Some(m) = Arc::make_mut(n).extras_mut().mask.as_mut()
{
link_styles(std::slice::from_mut(&mut m.art), links, styles, depth + 1);
}
if n.children().is_some_and(|c| !c.is_empty())
&& let Some(c) = Arc::make_mut(n).children_mut()
{
+6
View File
@@ -612,6 +612,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"Shift+Tab",
"{} show/hide the dock and the floating panels (hiding them closes a panel popped out of the icon column), leaving the toolbar and the Control bar as they are; returns whether the panels show",
),
(
"window.panels.peek",
"Show Hidden Panels at Edge",
"",
"{side: left|right|null} while Tab or Shift+Tab hides the panels, show the docked panels on that side of the canvas over its edge, as resting the pointer on that edge of the window for 0.3 s does; they hide again 0.3 s after the pointer moves away from them, and null hides them now. Floating panels, the toolbar and the Control bar stay hidden, and Tab or Shift+Tab shows the panels for good. Fails and changes nothing while the panels show, in Presentation Mode, for any other side, or when no panel is docked on that side; returns the side shown or null",
),
(
"window.panel",
"Show Panel",
+5
View File
@@ -5053,6 +5053,11 @@ axis Both И двете
@msg Imported library {name} Импортирана библиотека {name}
RGB: RGB:
CMYK: CMYK:
RGB Policy: Правило за RGB:
CMYK Policy: Правило за CMYK:
Preserve Embedded Profiles Запазване на вградените профили
Convert to Working Space Преобразуване в работното пространство
Preserve Numbers Запазване на числата
Texture Текстура
Craquelure… Кракелюр…
Grain… Зърнистост…
Can't render this file because it is too large.
+5
View File
@@ -986,6 +986,11 @@
NTSC Colors NTSC boje
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB pravilo:
CMYK Policy: CMYK pravilo:
Preserve Embedded Profiles Zadrži ugrađene profile
Convert to Working Space Pretvori u radni prostor
Preserve Numbers Zadrži brojeve
CMYK CMYK
Texture Tekstura
Craquelure… Krakelura…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -765,6 +765,11 @@ antiAlias Sharp Nítid
CMYK Equivalents Equivalents CMYK
CMYK profile in effect Perfil CMYK en vigor
CMYK: CMYK:
RGB Policy: Política RGB:
CMYK Policy: Política CMYK:
Preserve Embedded Profiles Conserva els perfils incrustats
Convert to Working Space Converteix a l'espai de treball
Preserve Numbers Conserva els números
Coarse Dots Punts gruixuts
Collapse Panel Group Replega el grup de panells
Collapse Panels to Icons Replega els panells a icones
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -1005,6 +1005,11 @@
NTSC Colors Barvy NTSC
RGB: RGB:
CMYK: CMYK:
RGB Policy: Zásada RGB:
CMYK Policy: Zásada CMYK:
Preserve Embedded Profiles Zachovat vložené profily
Convert to Working Space Převést do pracovního prostoru
Preserve Numbers Zachovat čísla
CMYK CMYK
Texture Textura
Craquelure… Krakelování…
Can't render this file because it is too large.
+5
View File
@@ -1538,6 +1538,11 @@
NTSC Colors NTSC-farver
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB-politik:
CMYK Policy: CMYK-politik:
Preserve Embedded Profiles Bevar indlejrede profiler
Convert to Working Space Konverter til arbejdsfarverum
Preserve Numbers Bevar tal
CMYK CMYK
Texture Tekstur
Craquelure… Krakelering…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -5381,6 +5381,11 @@ theme Appearance Erscheinungsbild
The key color becomes the stroke color. The other colors shift their hue by the same amount and keep their saturation and brightness. Die Hauptfarbe wird zur Konturfarbe. Die anderen Farben wandern ebenso weit um den Farbkreis wie die Hauptfarbe und behalten ihre Sättigung und Helligkeit.
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB-Richtlinie:
CMYK Policy: CMYK-Richtlinie:
Preserve Embedded Profiles Eingebettete Profile beibehalten
Convert to Working Space In Arbeitsfarbraum konvertieren
Preserve Numbers Werte beibehalten
# PSD files.
@msg not a PSD file keine PSD-Datei
@msg Multichannel PSD files can't be read: save it in RGB, CMYK or Grayscale mode PSD-Dateien im Mehrkanalmodus können nicht gelesen werden: Speichern Sie die Datei im RGB-, CMYK- oder Graustufenmodus
Can't render this file because it is too large.
+5
View File
@@ -5353,6 +5353,11 @@ digits Malayalam Μαλαγιάλαμ
@msg Imported library {name} Εισήχθη η βιβλιοθήκη {name}
RGB: RGB:
CMYK: CMYK:
RGB Policy: Πολιτική RGB:
CMYK Policy: Πολιτική CMYK:
Preserve Embedded Profiles Διατήρηση ενσωματωμένων προφίλ
Convert to Working Space Μετατροπή στον χώρο εργασίας
Preserve Numbers Διατήρηση αριθμών
System Title Bar Γραμμή τίτλου συστήματος
VectorCraft Title Bar on Every Desktop Γραμμή τίτλου του VectorCraft σε κάθε επιφάνεια εργασίας
The VECTORCRAFT_TITLEBAR environment variable chooses the title bar while it is set. Όσο είναι ορισμένη, η μεταβλητή περιβάλλοντος VECTORCRAFT_TITLEBAR επιλέγει τη γραμμή τίτλου.
Can't render this file because it is too large.
+5
View File
@@ -5399,6 +5399,11 @@ axis Both Ambos
@msg Imported library {name} Biblioteca {name} importada
RGB: RGB:
CMYK: CMYK:
RGB Policy: Norma RGB:
CMYK Policy: Norma CMYK:
Preserve Embedded Profiles Conservar perfiles incrustados
Convert to Working Space Convertir en espacio de trabajo
Preserve Numbers Conservar números
Texture Textura
Craquelure… Craquelado…
Grain… Granulado…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -989,6 +989,11 @@
NTSC Colors NTSC-värit
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB-käytäntö:
CMYK Policy: CMYK-käytäntö:
Preserve Embedded Profiles Säilytä upotetut profiilit
Convert to Working Space Muunna työväriavaruuteen
Preserve Numbers Säilytä lukuarvot
CMYK CMYK
Texture Tekstuuri
Craquelure… Krakelyyri…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -5404,6 +5404,11 @@ axis Both Les deux
@msg Imported library {name} Bibliothèque {name} importée
RGB: RVB :
CMYK: CMJN :
RGB Policy: Règle RVB :
CMYK Policy: Règle CMJN :
Preserve Embedded Profiles Conserver les profils incorporés
Convert to Working Space Convertir en espace de travail
Preserve Numbers Conserver les valeurs numériques
Texture Texture
Craquelure… Craquelure…
Grain… Grain…
Can't render this file because it is too large.
+5
View File
@@ -472,6 +472,11 @@
CMYK Images CMYK ઇમેજ
CMYK colours print with their own values; off, they go through the colour settings too. CMYK રંગો પોતાની કિંમતો સાથે છાપે છે; બંધ હોય ત્યારે તે રંગ સેટિંગમાંથી પણ પસાર થાય છે.
CMYK: CMYK:
RGB Policy: RGB નીતિ:
CMYK Policy: CMYK નીતિ:
Preserve Embedded Profiles એમ્બેડ કરેલી પ્રોફાઇલ જાળવો
Convert to Working Space કાર્યકારી સ્પેસમાં રૂપાંતરિત કરો
Preserve Numbers સંખ્યાઓ જાળવો
CSS Properties CSS ગુણધર્મો
Calligraphic Brush કેલિગ્રાફિક બ્રશ
Calligraphic Brush Options કેલિગ્રાફિક બ્રશ વિકલ્પો
Can't render this file because it contains an unexpected character in line 72 and column 5.
+5
View File
@@ -892,6 +892,11 @@ antiAlias Sharp शार्प
CMYK Images CMYK इमेज
CMYK profile in effect इफ़ेक्ट में CMYK प्रोफ़ाइल
CMYK: CMYK:
RGB Policy: RGB नीति:
CMYK Policy: CMYK नीति:
Preserve Embedded Profiles एम्बेड की गई प्रोफ़ाइल बनाए रखें
Convert to Working Space वर्किंग स्पेस में बदलें
Preserve Numbers संख्याएँ बनाए रखें
Coarse Dots मोटे बिंदु
Coincidence: संयोग:
Collapse Panel Group पैनल समूह संक्षिप्त करें
Can't render this file because it is too large.
+5
View File
@@ -696,6 +696,11 @@ font-technology Variable Változó
CMYK Equivalents CMYK-megfelelők
CMYK profile in effect Érvényes CMYK-profil
CMYK: CMYK:
RGB Policy: RGB-házirend:
CMYK Policy: CMYK-házirend:
Preserve Embedded Profiles Beágyazott profilok megtartása
Convert to Working Space Konvertálás a munkaszíntérbe
Preserve Numbers Számértékek megtartása
Coarse Dots Durva pontok
Collapse Panels to Icons Panelek ikonná csukása
Collapse to Icons Ikonná csukás
Can't render this file because it is too large.
+5
View File
@@ -928,6 +928,11 @@
NTSC Colors Warna NTSC
RGB: RGB:
CMYK: CMYK:
RGB Policy: Kebijakan RGB:
CMYK Policy: Kebijakan CMYK:
Preserve Embedded Profiles Pertahankan Profil Tersemat
Convert to Working Space Konversi ke Ruang Kerja
Preserve Numbers Pertahankan Angka
CMYK CMYK
Texture Tekstur
Craquelure… Craquelure…
1 # Indonesian (id) catalog. Same format as zh-hant.tsv: context <TAB> source <TAB> translation
928
929
930
931
932
933
934
935
936
937
938
+5
View File
@@ -5449,6 +5449,11 @@ axis Both Entrambi
@msg Imported library {name} Libreria {name} importata
RGB: RGB:
CMYK: CMYK:
RGB Policy: Criterio RGB:
CMYK Policy: Criterio CMYK:
Preserve Embedded Profiles Mantieni profili incorporati
Convert to Working Space Converti nello spazio di lavoro
Preserve Numbers Mantieni valori numerici
Texture Texture
Craquelure… Craquelé…
Grain… Granulosità…
Can't render this file because it is too large.
+5
View File
@@ -5490,6 +5490,11 @@ swatch Bright Violet ビビッドバイオレット
@msg Imported library {name} ライブラリ {name} を読み込みました
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB ポリシー:
CMYK Policy: CMYK ポリシー:
Preserve Embedded Profiles 埋め込まれたプロファイルを保持
Convert to Working Space 作業用スペースに変換
Preserve Numbers カラー値を保持
Texture テクスチャ
Craquelure… クラッキング…
Grain… 粒状…
Can't render this file because it is too large.
+5
View File
@@ -894,6 +894,11 @@
NTSC Colors NTSC ფერები
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB წესი:
CMYK Policy: CMYK წესი:
Preserve Embedded Profiles ჩაშენებული პროფილების შენარჩუნება
Convert to Working Space სამუშაო სივრცეში გადაყვანა
Preserve Numbers რიცხვების შენარჩუნება
CMYK CMYK
Texture ტექსტურა
Craquelure… კრაკელიური…
Can't render this file because it is too large.
+5
View File
@@ -5417,6 +5417,11 @@ theme Appearance 외관
@msg Imported library {name} 라이브러리 {name}을(를) 가져왔습니다
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB 정책:
CMYK Policy: CMYK 정책:
Preserve Embedded Profiles 포함된 프로필 유지
Convert to Working Space 작업 공간으로 변환
Preserve Numbers 숫자 유지
Texture 텍스처
Craquelure… 크랙…
Grain… 그레인…
Can't render this file because it is too large.
+5
View File
@@ -1446,6 +1446,11 @@
NTSC Colors NTSC-kleuren
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB-beleid:
CMYK Policy: CMYK-beleid:
Preserve Embedded Profiles Ingesloten profielen behouden
Convert to Working Space Omzetten naar werkruimte
Preserve Numbers Waarden behouden
CMYK CMYK
Texture Textuur
Craquelure… Craquelure…
Can't render this file because it is too large.
+5
View File
@@ -946,6 +946,11 @@
NTSC Colors Kolory NTSC
RGB: RGB:
CMYK: CMYK:
RGB Policy: Zasada RGB:
CMYK Policy: Zasada CMYK:
Preserve Embedded Profiles Zachowaj osadzone profile
Convert to Working Space Konwertuj do przestrzeni roboczej
Preserve Numbers Zachowaj wartości liczbowe
CMYK CMYK
Texture Tekstura
Craquelure… Spękania…
Can't render this file because it is too large.
+5
View File
@@ -3506,6 +3506,11 @@ imageTrace Outline Contorno
NTSC Colors Cores NTSC
RGB: RGB:
CMYK: CMYK:
RGB Policy: Política RGB:
CMYK Policy: Política CMYK:
Preserve Embedded Profiles Preservar perfis incorporados
Convert to Working Space Converter para espaço de trabalho
Preserve Numbers Preservar números
Texture Textura
Craquelure… Craquelê…
Grain… Granulação…
Can't render this file because it is too large.
File diff suppressed because it is too large. Load diff
+5
View File
@@ -5306,6 +5306,11 @@ axis Both Båda
@msg Imported library {name} Importerade biblioteket {name}
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB-princip:
CMYK Policy: CMYK-princip:
Preserve Embedded Profiles Behåll inbäddade profiler
Convert to Working Space Konvertera till arbetsfärgrymd
Preserve Numbers Behåll värden
Texture Textur
Craquelure… Krakelering…
Grain… Korn…
Can't render this file because it is too large.
+21
View File
@@ -4041,6 +4041,27 @@ fn dataset_import_cell_errors_are_translated() {
}
}
/// Russian shows command, script and file messages in Russian: a whole message, a message that
/// begins with a feature name, messages with a name, a number or a command id filled in, and the
/// two messages whose catalog rows escape a backslash.
#[test]
fn russian_translates_command_script_and_file_messages() {
let ru = Lang::from_code("ru").expect("registered");
for (english, russian) in [
("CSV is empty", "CSV пуст"),
("Offset Path: the path is too complex to offset", "Смещение контура: контур слишком сложен для смещения"),
("no swatch named `Gold`", "нет образца с именем `Gold`"),
("object 12 is not an Intertwine group", "объект 12 не является группой переплетения"),
("no slice 4 in the image (see slice.list)", "в изображении нет фрагмента 4 (см. slice.list)"),
("give origin: [x, y], or reset: true", "укажите origin: [x, y] или reset: true"),
("`kinsoku` must be \"none\", \"hard\" or \"soft\"", "`kinsoku` должно быть \"none\", \"hard\" или \"soft\""),
("\\ at end of pattern", "\\ в конце шаблона"),
("a \\u escape needs four hexadecimal digits", "после \\u нужны четыре шестнадцатеричные цифры"),
] {
assert_eq!(message(ru, english), russian, "{english}");
}
}
/// The errors of the parameter checks that many commands share (a number given as text, a missing
/// number or index, a fraction for a whole number, `ids` that aren't a list of object ids, an
/// `ids` entry or an `id` that is negative, an object id that names no object, a date that isn't
+5
View File
@@ -5204,6 +5204,11 @@ axis Both Her İkisi
@msg Imported library {name} İçe aktarılan kitaplık {name}
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB İlkesi:
CMYK Policy: CMYK İlkesi:
Preserve Embedded Profiles Gömülü Profilleri Koru
Convert to Working Space Çalışma Alanına Dönüştür
Preserve Numbers Sayıları Koru
Texture Doku
Craquelure… Küçük çatlak…
Grain… Tahıl…
Can't render this file because it is too large.
+5
View File
@@ -5433,6 +5433,11 @@ axis Both Обидві
@msg Imported library {name} Імпортовано бібліотеку {name}
RGB: RGB:
CMYK: CMYK:
RGB Policy: Правило RGB:
CMYK Policy: Правило CMYK:
Preserve Embedded Profiles Зберігати вбудовані профілі
Convert to Working Space Перетворювати в робочий простір
Preserve Numbers Зберігати числа
Texture Текстура
Craquelure… Кракелюри…
Grain… Зерно…
Can't render this file because it is too large.
+5
View File
@@ -608,6 +608,11 @@ font-technology Variable Biến thiên
CMYK Equivalents Tương đương CMYK
CMYK profile in effect Hồ sơ CMYK đang có hiệu lực
CMYK: CMYK:
RGB Policy: Chính sách RGB:
CMYK Policy: Chính sách CMYK:
Preserve Embedded Profiles Giữ cấu hình nhúng
Convert to Working Space Chuyển sang không gian làm việc
Preserve Numbers Giữ giá trị số
Coarse Dots Chấm thô
Collapse Panels to Icons Thu gọn bảng thành biểu tượng
Collapse to Icons Thu gọn thành biểu tượng
Can't render this file because it contains an unexpected character in line 205 and column 5.
+5
View File
@@ -5335,6 +5335,11 @@ imageTrace Outline 轮廓
None (Color Preview) 无 (颜色预览)
Preserve 保留
CMYK: CMYK:
RGB Policy: RGB 策略:
CMYK Policy: CMYK 策略:
Preserve Embedded Profiles 保留嵌入的配置文件
Convert to Working Space 转换为工作空间
Preserve Numbers 保留数值
Art & Illustration 艺术和插画
Branding 品牌
Film & Video 影片和视频
Can't render this file because it is too large.
+5
View File
@@ -5567,6 +5567,11 @@ axis Both 兩者
Interpolation 內插
RGB: RGB:
CMYK: CMYK:
RGB Policy: RGB 原則:
CMYK Policy: CMYK 原則:
Preserve Embedded Profiles 保留內嵌描述檔
Convert to Working Space 轉換為工作空間
Preserve Numbers 保留數值
Texture 紋理
Craquelure… 龜裂紋…
Grain… 顆粒…
Can't render this file because it is too large.
+6
View File
@@ -613,6 +613,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"Shift+Tab",
"{} show/hide the dock and the floating panels (hiding them closes a panel popped out of the icon column), leaving the toolbar and the Control bar as they are; returns whether the panels show",
),
(
"window.panels.peek",
"Show Hidden Panels at Edge",
"",
"{side: left|right|null} while Tab or Shift+Tab hides the panels, show the docked panels on that side of the canvas over its edge, as resting the pointer on that edge of the window for 0.3 s does; they hide again 0.3 s after the pointer moves away from them, and null hides them now. Floating panels, the toolbar and the Control bar stay hidden, and Tab or Shift+Tab shows the panels for good. Fails and changes nothing while the panels show, in Presentation Mode, for any other side, or when no panel is docked on that side; returns the side shown or null",
),
(
"window.panel",
"Show Panel",
+15 -4
View File
@@ -51,6 +51,8 @@ pub(crate) struct Runtime {
raise: Option<String>,
/// The panel the user last clicked or pressed in (a tab, a panel body, a drop).
focused: Option<String>,
/// Hidden panels shown from the window's edges ([`peek`]).
peek: peek::State,
}
/// Every docking control the main window drew last frame with its rect. Controls in floating
@@ -72,6 +74,7 @@ pub(crate) fn inspect(app: &VectorcraftApp, ctx: &egui::Context) -> Value {
"hidden": app.ui.docking_hidden.keys().collect::<Vec<_>>(),
"autoCollapse": app.session.prefs.auto_collapse_icon_panels,
"panelsShown": app.ui.dock && app.ui.screen_mode < 3,
"peek": peek::shown(app),
"hitRects": hits,
})
}
@@ -322,6 +325,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, id: &str, params: &Value) -> Opt
match id {
"window.panel" => return Some(show_panel(app, params)),
"window.collapseDock" => return Some(crate::menus::opt_bool(params, "collapsed").and_then(|c| collapse_dock(app, c))),
"window.panels.peek" => return Some(peek::command(app, params)),
"window.panel.collapse" => {
let minimized = match crate::menus::opt_bool(params, "collapsed") {
Ok(c) => c,
@@ -1167,6 +1171,9 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
if modal || egui::Popup::is_any_open(&ctx) {
blocked.push(ctx.content_rect());
}
// Panels hidden by Tab or Shift+Tab show on the side of the window edge the pointer rests on.
let peeking = peek::update(app, &ctx, ui.available_rect_before_wrap(), &layout, !blocked.is_empty()).map(|edge| peek::edge_panels(&layout, edge));
let shown_from_edge = |panel: &String| peeking.as_ref().is_some_and(|panels| panels.contains(panel));
let style = dock_style(ui);
let mut dock = craft_ui::docking::DockArea::new(area)
.blocked_rects(&blocked)
@@ -1187,7 +1194,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
// Tab and Shift+Tab (`window.dock`, `window.panels`) and the full screen modes hide the panels;
// the canvas stays.
if !app.ui.dock || app.ui.screen_mode >= 3 {
dock = dock.hide_panels(HidePanels::All);
dock = dock.hide_panels(if peeking.is_some() { HidePanels::Except(&shown_from_edge) } else { HidePanels::All });
}
if let Some(panel) = app.dock_rt.raise.take() {
dock = dock.raise_panel(panel);
@@ -1220,7 +1227,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
app.open_dropped_files(window.dropped, None, shift);
}
forward_keys(app, &ctx, output.forwarded_events, output.forwarded_modifiers);
if !thumbnail_panel_showing(&app.ui, &ctx) {
if peeking.is_none() && !thumbnail_panel_showing(&app.ui, &ctx) {
// No panel can ask for these rows again this pass. Keep the cache of open documents, but
// discard worker jobs queued behind the one already rendering.
crate::panels::layers::show_thumbs_of(None);
@@ -1383,8 +1390,10 @@ impl craft_ui::docking::DockContent<String> for PanelContent<'_> {
/// Draw a registered panel body, fitting untouched flyouts and pinning sized panels' footers.
fn body(&mut self, ui: &mut egui::Ui, id: &String) {
if id == CANVAS {
crate::toolbar::show_beside_canvas(self.app, ui);
self.app.canvas_area(ui);
peek::canvas(self.app, ui, |app, ui| {
crate::toolbar::show_beside_canvas(app, ui);
app.canvas_area(ui);
});
return;
}
let floating = ui.ctx().viewport_id() != egui::ViewportId::ROOT;
@@ -1513,6 +1522,8 @@ impl craft_ui::docking::DockContent<String> for PanelContent<'_> {
}
}
mod peek;
#[cfg(test)]
mod tests;
+248
View File
@@ -0,0 +1,248 @@
//! Panels hidden by Tab or Shift+Tab, shown for a while: resting the pointer on the left or right
//! edge of the dock area shows the docked panels on that side of the canvas
//! (`window.panels.peek`). They hide again once the pointer has been away from them for
//! [`GRACE`] seconds; Tab or Shift+Tab shows them for good. The canvas keeps the size it has with
//! every panel hidden, so the panels cover its edge and the artwork stays where it is. Floating
//! panels, the Tools panel and the Control bar stay hidden.
use craft_ui::docking::{Layout, Node};
use craft_ui::layout::SplitAxis;
use serde_json::{Value, json};
use super::CANVAS;
use crate::VectorcraftApp;
/// Width of the band along each edge of the dock area that shows the panels on that side.
pub(crate) const EDGE: f32 = 6.0;
/// How long the pointer rests on an edge band before the panels show, in seconds.
pub(crate) const DELAY: f64 = 0.3;
/// How long the pointer stays away from the panels shown before they hide, in seconds.
pub(crate) const GRACE: f64 = 0.3;
/// A side of the canvas.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum Edge {
Left,
Right,
}
impl Edge {
fn id(self) -> &'static str {
match self {
Edge::Left => "left",
Edge::Right => "right",
}
}
}
/// The panels shown on one side.
#[derive(Clone, Copy, Debug)]
struct Shown {
edge: Edge,
/// When the pointer left them; `None` while it is over them or has not moved since they showed.
left_at: Option<f64>,
}
/// The session's state of the panels shown from the edges.
pub(crate) struct State {
/// Whether Tab or Shift+Tab hides the panels this frame.
hidden: bool,
/// The dock area this frame.
area: egui::Rect,
/// The edge band the pointer rests on, and since when.
resting: Option<(Edge, f64)>,
shown: Option<Shown>,
/// How far the canvas's corners lay from the dock area's with every panel hidden.
canvas: Option<(egui::Vec2, egui::Vec2)>,
/// The part of the canvas left uncovered while panels show.
uncovered: Option<egui::Rect>,
}
impl Default for State {
fn default() -> Self {
Self { hidden: false, area: egui::Rect::NOTHING, resting: None, shown: None, canvas: None, uncovered: None }
}
}
/// The docked panels on `edge`'s side of the canvas, at any depth of horizontal splits.
pub(crate) fn edge_panels(layout: &Layout<String>, edge: Edge) -> Vec<String> {
let canvas = CANVAS.to_string();
let tree = |node: &Node<String>| Layout { root: Some(node.clone()), floating: Vec::new() };
let mut out = Vec::new();
let mut node = layout.root.as_ref();
let mut depth = 0usize;
while let Some(Node::Split { axis, first, second, .. }) = node {
depth = depth.saturating_add(1);
if depth > 2 * craft_ui::docking::MAX_PANELS {
break;
}
let (inner, outer, side) = if tree(first).contains(&canvas) { (first, second, Edge::Right) } else { (second, first, Edge::Left) };
if matches!(axis, SplitAxis::Horizontal) && side == edge {
out.extend(tree(outer).panels().into_iter().filter(|p| **p != canvas).cloned());
}
node = Some(inner);
}
out
}
/// The side whose panels show this frame. `area` is the dock area and `blocked` whether a modal
/// dialog or a popup takes the input.
pub(super) fn update(app: &mut VectorcraftApp, ctx: &egui::Context, area: egui::Rect, layout: &Layout<String>, blocked: bool) -> Option<Edge> {
let hidden = !app.ui.dock && app.ui.screen_mode < 3;
let flyout = app.ui.open_panel.is_some();
// The docked Tools panel's rect, read only while Tools shows (Tab turns `toolbar` off).
let tools = app.ui.toolbar.then(|| ctx.data(|d| d.get_temp::<egui::Rect>(crate::toolbar::docked_rect_id()))).flatten();
let st = &mut app.dock_rt.peek;
st.hidden = hidden;
st.area = area;
if !hidden {
st.resting = None;
st.shown = None;
st.uncovered = None;
return None;
}
let (now, pointer, down, moved) = ctx.input(|i| {
// A release counts as moving away: a press may have held the panels while it left them.
let moved =
i.pointer.delta() != egui::Vec2::ZERO || i.pointer.any_released() || i.events.iter().any(|e| matches!(e, egui::Event::PointerGone));
(i.time, i.pointer.hover_pos(), i.pointer.any_down(), moved)
});
// A workspace switched to while panels show may dock none on that side.
if st.shown.is_some_and(|shown| edge_panels(layout, shown.edge).is_empty()) {
st.shown = None;
st.uncovered = None;
}
if let Some(shown) = st.shown.as_mut() {
// The panels shown sit beside the canvas, level with it.
let over = pointer.is_some_and(|p| {
let uncovered = st.uncovered.unwrap_or_else(|| area.shrink2(egui::vec2(EDGE, 0.0)));
area.contains(p)
&& (uncovered.top()..=uncovered.bottom()).contains(&p.y)
&& match shown.edge {
Edge::Left => p.x < uncovered.left(),
Edge::Right => p.x > uncovered.right(),
}
});
if over || down || blocked || flyout {
shown.left_at = None;
} else if moved || pointer.is_none() {
shown.left_at.get_or_insert(now);
}
match shown.left_at {
Some(left) if now - left >= GRACE => {
st.shown = None;
st.uncovered = None;
// A flyout opened from the panels shown closes with them.
app.ui.open_panel = None;
return None;
}
Some(left) => ctx.request_repaint_after_secs((GRACE - (now - left)) as f32),
None => {}
}
return Some(shown.edge);
}
let edge = pointer.filter(|p| area.contains(*p) && !tools.is_some_and(|r| r.contains(*p))).and_then(|p| {
if p.x <= area.left() + EDGE {
Some(Edge::Left)
} else if p.x >= area.right() - EDGE {
Some(Edge::Right)
} else {
None
}
});
let Some(edge) = edge.filter(|e| !down && !blocked && !edge_panels(layout, *e).is_empty()) else {
st.resting = None;
return None;
};
let since = match st.resting {
Some((rested, since)) if rested == edge => since,
_ => now,
};
if now - since >= DELAY {
st.resting = None;
st.shown = Some(Shown { edge, left_at: None });
return Some(edge);
}
st.resting = Some((edge, since));
ctx.request_repaint_after_secs((DELAY - (now - since)) as f32);
// The strip the pointer rests on.
let band = match edge {
Edge::Left => egui::Rect::from_min_max(area.left_top(), egui::pos2(area.left() + EDGE, area.bottom())),
Edge::Right => egui::Rect::from_min_max(egui::pos2(area.right() - EDGE, area.top()), area.right_bottom()),
};
let t = crate::theme::Tokens::get(ctx);
let layer = egui::LayerId::new(egui::Order::Foreground, super::area_id().with("peek-strip"));
ctx.layer_painter(layer).rect_filled(band, 0.0, t.accent.gamma_multiply(0.6));
None
}
/// The side shown, for `ui.docking`.
pub(super) fn shown(app: &VectorcraftApp) -> Option<&'static str> {
app.dock_rt.peek.shown.map(|s| s.edge.id())
}
/// Draw the canvas panel's body with `draw`. While panels show from an edge, the canvas keeps the
/// rect it has with every panel hidden, drawn under the panels and taking input only where they
/// leave it uncovered.
pub(super) fn canvas(app: &mut VectorcraftApp, ui: &mut egui::Ui, draw: impl FnOnce(&mut VectorcraftApp, &mut egui::Ui)) {
let uncovered = ui.max_rect();
let st = &mut app.dock_rt.peek;
let wide = if !st.hidden {
st.canvas = None;
None
} else if st.shown.is_none() {
st.canvas = Some((uncovered.min - st.area.min, uncovered.max - st.area.max));
None
} else {
st.uncovered = Some(uncovered);
// The canvas's insets in the dock area with every panel hidden, kept as the window resizes;
// none before such a frame was drawn, as it fills the area then.
let (min, max) = st.canvas.unwrap_or((egui::Vec2::ZERO, egui::Vec2::ZERO));
Some(egui::Rect::from_min_max(st.area.min + min, st.area.max + max))
};
match wide {
Some(full) if full != uncovered && full.is_positive() => {
let clip = uncovered.intersect(ui.clip_rect());
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(full));
child.set_clip_rect(clip);
draw(app, &mut child);
}
_ => draw(app, ui),
}
}
/// `window.panels.peek {side: left|right|null}`: show the docked panels on that side while Tab or
/// Shift+Tab hides the panels, as resting the pointer on that edge does, or (null) hide them.
pub(super) fn command(app: &mut VectorcraftApp, params: &Value) -> Result<Value, String> {
let edge = match params.get("side") {
None | Some(Value::Null) => None,
Some(Value::String(s)) if s == "left" => Some(Edge::Left),
Some(Value::String(s)) if s == "right" => Some(Edge::Right),
Some(_) => return Err("`side` must be left, right or null".into()),
};
if app.ui.screen_mode >= 3 {
return Err("panels can't be shown in Presentation Mode".into());
}
if app.ui.dock {
return Err("the panels are not hidden".into());
}
match edge {
Some(edge) => {
if edge_panels(&super::layout_of(&app.ui), edge).is_empty() {
return Err(format!("no panels are docked on the {} side", edge.id()));
}
let st = &mut app.dock_rt.peek;
st.resting = None;
st.shown = Some(Shown { edge, left_at: None });
Ok(json!(edge.id()))
}
None => {
let st = &mut app.dock_rt.peek;
if st.shown.take().is_some() {
st.uncovered = None;
app.ui.open_panel = None;
}
Ok(Value::Null)
}
}
}
+194
View File
@@ -468,6 +468,200 @@ fn tab_hides_the_panels_and_the_canvas_keeps_drawing() {
assert!(h.tab("properties").is_some());
}
/// Hide the panels with Tab and settle; returns the canvas rect with every panel hidden.
fn hide_with_tab(h: &mut Harness) -> Rect {
h.app.run("window.dock", json!({})).unwrap();
h.frame(vec![]);
h.frame(vec![]);
assert!(h.tab("properties").is_none());
h.app.canvas_rect.expect("the canvas draws")
}
/// Frames with the pointer still, for `secs` of the harness clock.
fn wait(h: &mut Harness, secs: f64) {
let until = h.time + secs;
while h.time < until {
h.frame(vec![]);
}
}
#[test]
fn resting_on_the_right_edge_shows_the_hidden_panels_over_the_canvas_until_the_pointer_leaves() {
let mut h = Harness::new();
let wide = hide_with_tab(&mut h);
let edge = pos2(SCREEN.right() - 2.0, 500.0);
h.frame(vec![Event::PointerMoved(edge)]);
wait(&mut h, peek::DELAY / 2.0);
assert!(h.tab("properties").is_none(), "the panels wait for the pointer to rest");
wait(&mut h, peek::DELAY);
let tab = h.tab("properties").expect("resting on the edge shows the right-hand panels");
assert!(h.hit(&Hit::Icon("swatches".into())).is_some(), "the icon column shows with them");
assert!(!h.app.ui.dock, "the panels stay hidden for good");
assert_eq!(h.app.canvas_rect, Some(wide), "the canvas keeps its size, so the art stays where it is");
assert_eq!(inspect(&h.app, &h.ctx)["peek"], json!("right"));
h.frame(vec![Event::PointerMoved(tab.center())]);
wait(&mut h, peek::GRACE * 2.0);
assert!(h.tab("properties").is_some(), "they stay while the pointer is over them");
h.frame(vec![Event::PointerMoved(wide.center())]);
wait(&mut h, peek::GRACE / 2.0);
assert!(h.tab("properties").is_some(), "a short trip away keeps them");
wait(&mut h, peek::GRACE);
assert!(h.tab("properties").is_none(), "away from them, they hide again");
assert_eq!(inspect(&h.app, &h.ctx)["peek"], Value::Null);
}
#[test]
fn a_press_on_the_canvas_while_the_panels_show_from_the_edge_does_not_reach_the_art_under_them() {
let mut h = Harness::new();
let wide = hide_with_tab(&mut h);
h.app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 100, "height": 100})).unwrap();
h.frame(vec![]);
fn selected(app: &VectorcraftApp) -> bool {
!app.session.active().unwrap().selection.is_empty()
}
assert!(selected(&h.app));
assert_eq!(h.app.run("window.panels.peek", json!({"side": "right"})).unwrap(), json!("right"));
h.frame(vec![]);
h.frame(vec![]);
let tab = h.tab("properties").expect("the right-hand panels show");
assert!(tab.left() < wide.right(), "they cover the canvas's right edge");
assert_eq!(h.app.canvas_rect, Some(wide));
// A click in the panels, where the canvas lies under them, leaves the selection.
h.click(pos2(tab.center().x, wide.bottom() - 40.0));
assert!(selected(&h.app), "the canvas under the panels takes no click");
// A click on the uncovered canvas away from the art deselects it, as it always does.
h.click(pos2(wide.left() + 40.0, wide.bottom() - 40.0));
assert!(!selected(&h.app));
}
#[test]
fn the_canvas_keeps_the_hidden_panels_size_when_the_window_resizes_or_the_panels_show_at_once() {
let mut h = Harness::new();
// Shown before any frame has drawn the panels hidden.
h.app.run("window.dock", json!({})).unwrap();
assert_eq!(h.app.run("window.panels.peek", json!({"side": "right"})).unwrap(), json!("right"));
h.frame(vec![]);
h.frame(vec![]);
assert!(h.tab("properties").is_some());
let wide = h.app.canvas_rect.unwrap();
h.app.run("window.panels.peek", json!({"side": null})).unwrap();
h.frame(vec![]);
h.frame(vec![]);
assert_eq!(h.app.canvas_rect, Some(wide), "the canvas had the size it has with every panel hidden");
// A narrower window while they show.
h.app.run("window.panels.peek", json!({"side": "right"})).unwrap();
let narrow = Rect::from_min_max(SCREEN.min, pos2(SCREEN.right() - 200.0, SCREEN.bottom()));
for _ in 0..3 {
h.time += 0.05;
h.run(egui::RawInput { time: Some(h.time), screen_rect: Some(narrow), ..Default::default() });
}
assert!(h.tab("properties").is_some());
let canvas = h.app.canvas_rect.unwrap();
assert!((canvas.width() - (wide.width() - 200.0)).abs() < 1.0, "{canvas:?} follows the window, under the panels");
}
#[test]
fn panels_held_by_a_press_hide_after_its_release_away_from_them() {
let mut h = Harness::new();
let wide = hide_with_tab(&mut h);
h.frame(vec![Event::PointerMoved(pos2(SCREEN.right() - 2.0, 500.0))]);
wait(&mut h, peek::DELAY * 2.0);
let tab = h.tab("properties").expect("the panels show");
let body = pos2(tab.center().x, wide.bottom() - 40.0);
h.frame(vec![Event::PointerMoved(body), button(body, true)]);
h.frame(vec![Event::PointerMoved(wide.center())]);
wait(&mut h, peek::GRACE * 2.0);
assert!(h.tab("properties").is_some(), "a held button keeps them");
h.frame(vec![button(wide.center(), false)]);
wait(&mut h, peek::GRACE * 2.0);
assert!(h.tab("properties").is_none(), "released away from them, they hide");
}
#[test]
fn a_drag_to_the_edge_or_a_pointer_on_the_left_edge_shows_nothing() {
let mut h = Harness::new();
let wide = hide_with_tab(&mut h);
// The default layout docks no panel on the left.
h.frame(vec![Event::PointerMoved(pos2(SCREEN.left() + 2.0, 500.0))]);
wait(&mut h, peek::DELAY * 2.0);
assert!(h.tab("properties").is_none());
// A drag that reaches the right edge holds a button down.
h.frame(vec![Event::PointerMoved(wide.center()), button(wide.center(), true)]);
h.frame(vec![Event::PointerMoved(pos2(SCREEN.right() - 2.0, 500.0))]);
wait(&mut h, peek::DELAY * 2.0);
assert!(h.tab("properties").is_none(), "a drag never shows them");
h.frame(vec![button(pos2(SCREEN.right() - 2.0, 500.0), false)]);
}
#[test]
fn tab_while_the_panels_show_from_the_edge_shows_them_for_good() {
let mut h = Harness::new();
let wide = hide_with_tab(&mut h);
h.frame(vec![Event::PointerMoved(pos2(SCREEN.right() - 2.0, 500.0))]);
wait(&mut h, peek::DELAY * 2.0);
assert!(h.tab("properties").is_some());
h.app.run("window.dock", json!({})).unwrap();
h.frame(vec![Event::PointerMoved(wide.center())]);
wait(&mut h, peek::GRACE * 2.0);
assert!(h.app.ui.dock && h.tab("properties").is_some());
assert_eq!(inspect(&h.app, &h.ctx)["peek"], Value::Null);
}
#[test]
fn shift_tab_hidden_panels_show_from_the_edge_too() {
let mut h = Harness::new();
h.app.run("window.panels", json!({})).unwrap();
h.frame(vec![]);
h.frame(vec![]);
assert!(h.tab("properties").is_none());
h.frame(vec![Event::PointerMoved(pos2(SCREEN.right() - 2.0, 500.0))]);
wait(&mut h, peek::DELAY * 2.0);
assert!(h.tab("properties").is_some());
}
#[test]
fn window_panels_peek_rejects_what_it_cannot_show_and_changes_nothing() {
let mut h = Harness::new();
assert_eq!(h.app.run("window.panels.peek", json!({"side": "right"})).unwrap_err(), "the panels are not hidden");
hide_with_tab(&mut h);
for side in [json!("up"), json!(1), json!(true), json!("Right")] {
assert_eq!(h.app.run("window.panels.peek", json!({"side": side})).unwrap_err(), "`side` must be left, right or null", "{side}");
}
assert_eq!(h.app.run("window.panels.peek", json!({"side": "left"})).unwrap_err(), "no panels are docked on the left side");
assert_eq!(h.app.run("window.panels.peek", json!({})).unwrap(), Value::Null, "nothing to hide");
h.frame(vec![]);
assert!(h.tab("properties").is_none() && !h.app.ui.dock);
assert_eq!(h.app.run("window.panels.peek", json!({"side": "right"})).unwrap(), json!("right"));
h.frame(vec![]);
assert!(h.tab("properties").is_some(), "the panels stay while the pointer has not moved");
assert_eq!(h.app.run("window.panels.peek", json!({"side": null})).unwrap(), Value::Null);
h.frame(vec![]);
assert!(h.tab("properties").is_none());
h.app.ui.screen_mode = 3;
assert_eq!(h.app.run("window.panels.peek", json!({"side": "right"})).unwrap_err(), "panels can't be shown in Presentation Mode");
h.app.ui.screen_mode = 0;
}
#[test]
fn edge_panels_are_the_docked_panels_on_each_side_of_the_canvas() {
let layout = default_from(DockTab::ALL[0], &[], false, None, None);
let right = peek::edge_panels(&layout, peek::Edge::Right);
assert!(right.contains(&"properties".to_string()) && right.contains(&"swatches".to_string()));
assert!(!right.contains(&CANVAS.to_string()));
assert!(peek::edge_panels(&layout, peek::Edge::Left).is_empty());
let mirrored = Layout {
root: Some(Node::Split {
axis: craft_ui::layout::SplitAxis::Horizontal,
size: craft_ui::layout::SplitSize::FixedFirst(310.0),
first: Box::new(Node::Tabs { panels: vec!["layers".to_string()], active: 0 }),
second: Box::new(Node::Tabs { panels: vec![CANVAS.to_string()], active: 0 }),
}),
floating: Vec::new(),
};
assert_eq!(peek::edge_panels(&mirrored, peek::Edge::Left), ["layers"]);
assert!(peek::edge_panels(&mirrored, peek::Edge::Right).is_empty());
}
#[test]
fn switching_workspace_during_a_tab_drag_keeps_the_new_workspace_layout() {
let mut h = Harness::new();
+31 -4
View File
@@ -1,11 +1,12 @@
//! Separations Preview panel: process plates C/M/Y/K plus spot plates with eye toggles (one visible
//! plate renders as greyscale ink coverage; Alt-click an eye to show only that plate), and the
//! colour-management controls behind Edit → Color Settings… / Assign Profile… and View → Proof
//! Setup (working spaces, intent, black-point compensation, proof target, gamut check).
//! Setup (working spaces, color management policies, intent, black-point compensation, proof
//! target, gamut check).
use egui::{Sense, Ui, vec2};
use serde_json::{Value, json};
use vectorcraft_color::cms::{self, Intent, ProfileKind};
use vectorcraft_color::cms::{self, Intent, Policy, ProfileKind};
use vectorcraft_render::proof;
use crate::VectorcraftApp;
@@ -100,8 +101,9 @@ fn settings_section(app: &mut VectorcraftApp, ui: &mut Ui) {
}
}
/// The section's rows: the RGB and CMYK working spaces, intent, black point compensation, Load
/// Profile… and Gamut Check, and the profile the active document is assigned.
/// The section's rows: the RGB and CMYK working spaces, intent, black point compensation, the RGB
/// and CMYK color management policies, Load Profile… and Gamut Check, and the profile the active
/// document is assigned.
fn settings_rows(app: &mut VectorcraftApp, ui: &mut Ui) {
let st = cms::working_settings();
widgets::section_header(ui, tl!("Color Settings"));
@@ -127,6 +129,21 @@ fn settings_rows(app: &mut VectorcraftApp, ui: &mut Ui) {
if widgets::check(ui, tl!("Use Black Point Compensation"), st.bpc, true) {
run(app, "edit.colorSettings", json!({"bpc": !st.bpc}));
}
// Color management policies: what opening a document does with a profile it is tagged with
// that is not the working space.
let policies: [(&str, &str, Policy, &[Policy]); 2] =
[("rgbPolicy", tl!("RGB Policy:"), st.rgb_policy, &Policy::RGB), ("cmykPolicy", tl!("CMYK Policy:"), st.cmyk_policy, &Policy::CMYK)];
for (key, label, current, choices) in policies {
ui.horizontal(|ui| {
ui.label(label);
let labels: Vec<&str> = choices.iter().map(|p| policy_label(*p)).collect();
if let Some(i) = widgets::dropdown_names(ui, key, policy_label(current), &labels, 210.0)
&& let Some(p) = choices.get(i)
{
run(app, "edit.colorSettings", json!({ key: p.id() }));
}
});
}
ui.horizontal(|ui| {
if widgets::flat_button(ui, tl!("Load Profile…"), 110.0).clicked() {
// Its file dialog, shown off the UI thread, loads the profile when it answers.
@@ -243,6 +260,16 @@ fn assign_rows(app: &mut VectorcraftApp, ui: &mut Ui, row: &AssignRow) {
}
}
/// The name of color management policy `p` in the UI language.
fn policy_label(p: Policy) -> &'static str {
match p {
Policy::Off => tl!("Off"),
Policy::PreserveEmbedded => tl!("Preserve Embedded Profiles"),
Policy::Convert => tl!("Convert to Working Space"),
Policy::PreserveNumbers => tl!("Preserve Numbers"),
}
}
/// The status bar's line after Gamut Check finds `n` colors outside the CMYK gamut.
pub(crate) fn gamut_check_status(n: usize) -> String {
if n == 0 {
+4 -2
View File
@@ -106,7 +106,9 @@ private editing data. VectorCraft:
Round Corners, Scribble, Convert to Shape, Offset Path, Outline Object or Outline Stroke, and groups with Pathfinder ›
Add. Groups keep them when their members are paths, compound paths or such groups, without effects of their own; when the
group's effects change its members' outlines, a member's strokes are plain lines, and its fills are not pattern
fills written as tiles or gradients that fit their object. The look holds the object's vector art, without the shadow, glow or feather. Other objects with
fills written as tiles or gradients that fit their object. The look holds the object's vector art, without the shadow, glow or feather.
This holds for objects on the layers and in opacity masks' art, the masks' art in a symbol's art and in a pattern's tile
included; a symbol's or a pattern's other objects are written as described next. Other objects with
live effects are written as their vector art with their geometry effects applied, and their other effects, such as
Drop Shadow, the glows and Feather, are left out with a warning. A path, compound path or group linked to a graphic style names it when it has the style's
appearance and the style is written; other links to graphic styles, those on a styled group's members included, are
@@ -272,7 +274,7 @@ The app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri
A run of type in the editing data whose baseline direction is 1 opens with Standard Vertical Roman Alignment (https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html) on, which is VectorCraft's own mapping: its half-width characters stand upright in vertical type, and horizontal type keeps the mark with no change to its layout. A run whose baseline direction is 2 or 3 (Tate-chu-yoko), or that names none in the run, its character style or the document's defaults, opens with it off. The scripting reference lists 1, 2 and 3 as the Standard, vertical rotated and Tate-chu-yoko baseline directions (https://web.archive.org/web/20170621180804/https://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015_3/Illustrator%20VBScript%20Reference.pdf, page 256).
A Scatter brush in the editing data whose last 15 numbers start with 1 comes into the Brushes panel in Tints. Each brush art section is read without its frame: an unnamed, unpainted rectangle with no settings of its own at the art's bounds (within 1/1000 pt), closed, or open with its first corner again at the end. A wider frame stays in the art, and an art group with a state or look of its own (hidden, locked, isolated, knockout, an opacity, a blend mode, a name, a mask, a note or an appearance) stays a group.
An object in a pattern's art or in a brush's art takes the file's art styles in the same way as an object on a layer: with a style VectorCraft reads, it comes in as itself with its effects live, not as the look it draws. An object in a pattern's art with a style in the file's style list keeps that graphic style's id. An art styles section inside a symbol's, a pattern's or a brush's art is skipped.
An object in a pattern's art or in a brush's art takes the file's art styles in the same way as an object on a layer: with a style VectorCraft reads, it comes in as itself with its effects live, not as the look it draws. An object in a pattern's art with a style in the file's style list keeps that graphic style's id, as does an object in an opacity mask's art. An art styles section inside a symbol's, a pattern's or a brush's art is skipped.
Names in the editing data that aren't UTF-8 (layers, objects, artboards, colors, gradients, patterns, graphic styles, swatches, brushes, symbols, variables and data sets) are read as Windows-1252 unless `legacyNameEncoding` (`convert --legacy-name-encoding`) picks `macintosh`, `windows-949`, `shift_jis`, `gbk` or `big5`; the open result's warnings list the first three such names as read and count the rest. The text values of data sets are read in the same encoding.
+1 -1
View File
@@ -56,7 +56,7 @@ plus review. Native-speaker review is human work and isn't in the hours.
| Italian | `it` | 8,924 rows, 3,560 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 54 missing messages for it, which open #7116, #7211, #7378 and #7405 translate | full |
| Dutch | `nl` | 3,447 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): in `COMPLETE_MESSAGES`, and the untranslated report lists 41 missing messages for it; one/other plurals | full |
| Danish | `da` | 7,422 rows, 1,636 of them `@msg` and 48 `@msgplural` (counted 2026-11-14 on `main` at `edb228ac3`): in `COMPLETE_MESSAGES`, and the untranslated report lists the same missing messages for it as for Greek, Spanish and Finnish; one/other plurals | full |
| Russian | `ru` | 4,009 / 4,020 | full |
| Russian | `ru` | 9,259 rows, 3,444 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): in `COMPLETE_MESSAGES`; the untranslated report lists 46 menu strings, 21 `tl!` literals and 11 undo labels as missing | full |
| Ukrainian | `uk` | 8,802 rows, 3,439 of them `@msg` and 48 `@msgplural` (counted 2026-11-13); one/few/many plurals | full |
| Hungarian | `hu` | 9,166 rows, 3,444 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 40 missing messages for it, and lists 47 menu strings, 25 `tl!` strings, 11 undo labels and 45 swatch names without a row; one plural form | full |
| Polish | `pl` | 9,044 rows, 3,439 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 46 missing messages for it, and 47 menu strings, 26 `tl!` literals, 11 undo labels and 45 swatch names; one/few/many plurals | full; native review pending |
+21 -4
View File
@@ -1666,10 +1666,18 @@ preferences (the folder the desktop app uses, so both see the same ones; `VECTOR
command, so `edit.colorSettings {"cmyk": "…"}` or a preset's output intent can name it in a later run. The
copy is what counts: the original may move or be deleted. `color.removeProfile {name}` forgets a profile and its
copy (not while it is a working space).
- **Color Settings** (`edit.colorSettings`): the RGB and CMYK working spaces, intent and black point
compensation go into `Color Settings.json` when they change, and are the active settings again at the next
start, after the profiles above are registered (#6335). Saved settings that name a profile that is no longer
there, or a damaged file, leave the defaults (logged), and the next change writes over the file.
- **Color Settings** (`edit.colorSettings`): the RGB and CMYK working spaces, intent, black point
compensation and color management policies go into `Color Settings.json` when they change, and are the active
settings again at the next start, after the profiles above are registered (#6335). Saved settings that name a
profile that is no longer there, or a damaged file, leave the defaults (logged), and the next change writes over
the file; settings saved without policies take the default, `preserveEmbedded`. `rgbPolicy` (`off`,
`preserveEmbedded`, `convert`) and `cmykPolicy` (the same and `preserveNumbers`) decide what `document.open`,
`file.newFromTemplate` and `file.revert` do with an RGB or CMYK profile the file is tagged with that is not the
working space: keep it, take it off and keep the color numbers (`off`, `preserveNumbers`), or convert the colors
of that model into the working space with the intent and black point compensation and take it off (`convert`; a
profile that is not available stays). The reply's `warnings` name each profile, and a document a policy changed
opens with unsaved changes. A profile that is the working space stays whatever the policy. `document.open`'s
`colorMode` converts the colors after the policies, through the profiles the document keeps.
`edit.assignProfile` tags the document only: colors show and convert through the profiles it assigns, and the
working spaces and the file stay as they are. The profiles in use are those of the document in front, after
`file.new`, `document.open`, `document.activate`, `file.close`, `file.revert`, `edit.undo`, `edit.redo` and a
@@ -1824,6 +1832,15 @@ and the action still plays. `Session::replay` plays a journal the same way. The
hides the dock, no panel is checked, and the panel shows again with the dock in its earlier place; the toolbar and the
Control bar stay as they are.
While Tab or Shift+Tab hides the panels, resting the pointer for 0.3 s on a 6 pt band along the left or right edge of
the area below the bars shows the panels docked on that side of the canvas, over the canvas's edge; the canvas keeps its
size, so the art does not move. They hide again once the pointer has been away from them for 0.3 s, and stay while a
flyout opened from them, a menu or a pressed button is open. Floating panels, the toolbar and the Control bar stay
hidden, and Tab or Shift+Tab shows the panels for good. `window.panels.peek {side: "left" | "right"}` shows them as the
pointer does, `{side: null}` hides them, and `ui.docking`'s `peek` names the side shown (null for none). The command
refuses another side, a side with no docked panel, panels that are not hidden and Presentation Mode, and changes
nothing.
The export commands limit those keys. `document.export`, `document.exportSelection`, `document.serialize`, `app.export`
and `file.export` refuse a key that no format takes. They accept a key that only another format takes and do not use
it: `{"format": "pdf", "quality": 80}` writes the PDF, and the reply's `warnings` name the key
+3
View File
@@ -758,6 +758,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Translucent art blended before the display profile:** with Use Monitor Profile for Canvas converting, translucent art and the anti-aliased edges of art over an artboard's paper, a colored artboard or the transparency grid are blended with it in sRGB and the blend is converted, so the monitor's profile translates the document's colors as they are composited ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=151)). The frame rendered whole, the part an edit renders again, the render worker's frame, the pan fill and the other windows' panes do the same; over the pasteboard and in Outline the art is converted on its own, and with no profile to convert into nothing changes. Tests `display_profile::tests::translucent_pixels_over_the_paper_are_blended_before_they_are_converted`, `the_transparency_grid_is_blended_cell_by_cell`, `the_backdrop_is_found_through_the_view` and `canvas::tests::translucent_art_over_the_paper_is_blended_before_the_display_profile`.
- **Out-of-gamut warning after a profile change:** the out-of-gamut warning and its closest-color correction in the Color panel and Color Picker ([the help page](https://helpx.adobe.com/illustrator/using/adjusting-colors.html)) check the color against the document's assigned CMYK profile, else the working CMYK space, and update when Edit › Assign Profile… or Edit › Color Settings… changes that space or a loaded profile changes, without a change of color. Which CMYK space the warning uses is VectorCraft's own rule. Tests: `gamut_warning_follows_a_profile_change` and `gamut_warning_follows_a_profile_loaded_again` in `dialogs/color_picker/tests.rs`.
- **Assign Profile and the working spaces:** Edit › Assign Profile… tags the document and leaves the working spaces of Edit › Color Settings… as they are, in Color Settings, the Separations panel and the settings saved for the next start. Colors show and convert through the profiles assigned; a change in Color Settings keeps the profiles the document in front is assigned in use, and removing an assigned profile in use puts the working space back in its place. The profiles in use follow the document in front: a new, opened or reverted document, a switch to another tab, a close, Undo and Redo of Assign Profile, a failed batch, each step of a batch, Export All Open and the update of placed documents put that document's profiles in use, and the working spaces where it is assigned none or no document is open. With Window › Arrange › Tile or floating document windows, each document behind the front one draws its art, paper and transparency grid through its own assigned profiles, and loading or removing a profile redraws the documents assigned it; placed documents inside it still draw through the front document's profiles. How documents behind the front one draw is VectorCraft's own rule. View › Proof Setup › Working CMYK simulates the working CMYK space of Color Settings in Proof Colors and Separations Preview, also in a document assigned another CMYK profile. Public references: [Changing the color profile for a document and About color working spaces](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=150) and [Soft-proof presets](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=134). Tests in `engine/tests/color_settings.rs`.
- **Color management policies:** Edit › Color Settings… (the Separations panel's Color Settings section and `edit.colorSettings`) has an RGB and a CMYK policy: Off, Preserve Embedded Profiles and Convert to Working Space, and Preserve Numbers for CMYK. When a document tagged with a profile other than the working space is opened, reverted or opened as a template, the policy keeps the profile, takes it off with the color numbers kept, or converts that model's colors into the working space, with black point compensation as Color Settings set it, and takes it off. The policies are kept in `Color Settings.json`. Preserve Embedded Profiles as the default for both, and the per-model policy for a document tagged with both an RGB and a CMYK profile, are VectorCraft's own rules; placed images and the Profile Mismatches and Missing Profiles prompts are not covered. Public reference: [Color management policy options](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=157). Tests in `engine/tests/color_settings.rs`, `color/src/cms/tests.rs` and `color/src/cms/tests_icc.rs`.
- **New Document's More Settings and Save Preset:** More Settings opens a pop-up over New Document with only Number of Artboards, the artboard layout, Change to Right-to-Left Layout, Spacing and Columns; Done, Escape or a click outside closes it and keeps the values. Save Preset turns the top of Preset Details into a Save Document Preset heading with the preset's name, Cancel and Save, and hides the document's name, Close and Create until the preset is saved or canceled; nothing in that mode creates a document. Save Preset's default name is the first "Preset N" no saved preset has. VectorCraft's own layout. Harness tests in `dialogs/new_document.rs` cover both.
- **New Document profiles:** each built-in category's presets start documents from that category's profile, a native document holding the starting swatches, graphic styles, brushes, symbols and other assets, the ruler and Document Setup options and the print settings ([Create a custom new document profile](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/start-a-new-file/create-a-custom-new-document-profile.html)). New Document's Manage Profiles pop-up opens a profile to edit and resets one to the shipped profile (`file.newProfiles`, `file.newProfiles.edit`, `file.newProfiles.reset`; `file.new {profile}`). The profiles live in VectorCraft's own `New Document Profiles` folder next to the preferences; a profile that cannot be read or is larger than 64 MiB leaves the defaults and is reported. Tests: `tests::newdoc::an_edited_profile_starts_the_documents_of_its_category`, `the_profile_follows_the_preset_access_and_reset`, `profile_errors_name_the_file_by_its_name_outside_the_read_roots`, `a_damaged_or_oversized_profile_leaves_the_defaults_and_is_reported`, `profile_names_are_checked_and_editing_needs_the_folder`, `dialogs::new_document::tests::manage_profiles_edits_and_resets_the_profiles`.
- **Control bar with the Artboard tool:** while the Artboard tool is in use, the Control bar shows the active artboard's controls in place of the object controls: Preset, Portrait and Landscape, New Artboard, Delete Artboard, the Name field, Artboard Options, Rearrange All Artboards, the Transform link, Move and Scale Artwork with Artboard and, while the bar has room, the reference point with X and Y, and W and H with the Constrain Width and Height Proportions link. Each runs the command its Properties or Transform panel counterpart runs (`artboard.setProps`, `artboard.new`, `artboard.delete`, `tool.options {tool: "artboard"}`), and the reference point is the one the Transform panel uses. In an 800-point window the controls up to the Transform link fit, Move and Scale Artwork with Artboard show as their boxes alone with their names in tooltips, and the link opens the Transform panel with the artboard's position and size. Pointer and key tests in `panels/artboards.rs` cover the controls, W about the reference point, the orientation and the name. Public reference: [Using multiple artboards](https://web.archive.org/web/20210925094818/https://helpx.adobe.com/illustrator/using/using-multiple-artboards.html) (archived copy).
@@ -1471,6 +1472,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
With the Selection tool, the Tabs panel shows the ruler and stops of the first paragraph of the first selected text object, also when the text is inside a selected group or a shape is selected before it; a selection without text shows "No text selected". A stop set on that ruler is set on every selected text object and the text in selected groups, and other objects are left as they were. This is VectorCraft's own rule. Tests `panels::tabs::tests::the_ruler_shows_text_selected_after_an_object_that_is_not_text`, `the_ruler_shows_text_inside_a_selected_group`, `a_stop_added_on_a_mixed_selection_sets_every_selected_text` and `a_selection_without_text_shows_no_ruler`.
The Tabs panel menu's Clear All Tabs (`text.tabs.clear`), Delete Tab and Repeat Tab (`text.tabs.set`) can be chosen while the panel's ruler shows tab stops. Delete Tab removes the stop selected on the ruler. Repeat Tab replaces the stops after the selected stop with up to 20 copies of it. The copies are spaced by the selected stop's distance from the stop before it, or from the paragraph's left indent (18 pt further in for each list level past the first) when it is the first stop, and no copy is placed at 2,000 pt or beyond. Clear All Tabs removes every stop, so the default stops every ½ inch apply again.
- **Interface languages, vertical type:** Preferences ▸ User Interface (or VectorCraft ▸ Language on macOS) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, German (every `de-*` locale), Spanish (neutral international Spanish, for every `es-*` locale), French (every `fr-*` locale), Italian (every `it-*` locale), Russian (every `ru-*` locale) and Ukrainian (every `uk-*` locale), Catalan (every `ca-*` locale) and Polish (every `pl-*` locale; AI-drafted, native review pending) cover the whole interface, Czech every menu label; Czech, German, Greek, Spanish, French, Georgian, Hindi, Hungarian, Italian, Japanese, Korean, Vietnamese, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Traditional Chinese, Swedish, Ukrainian, Finnish, Turkish, Catalan, Dutch and Danish also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, German, Spanish, French, Italian, Russian and Ukrainian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line; on a vertical path, upright glyphs and tate-chu-yoko blocks face the path's start, and letters on their side are a quarter turn clockwise from them (with Skew, 3D Ribbon and Stair Step only on a path that runs to the right), in one column that Align to Path Baseline or Center centers on the path and that the caret and selection span); kinsoku applies to horizontal and vertical Japanese (Paragraph panel › Kinsoku Set, `text.setFormat {kinsoku}`: Hard, the default, keeps closing marks, iteration marks, the prolonged sound mark and small kana off the line start and opening brackets off its end; Soft lets 々, ー and small kana start a line as JLREQ's level 3 rules do; None turns it off), and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a line flush with its start (a paragraph's first line at its first-line indent, JIS X 4051's principle in JLREQ 3.1.5), and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline (new type in a Japanese interface starts top to top, with em box centre character alignment, #432); Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline, the em box top/right, centre or bottom/left, or the ICF (ideographic character face) top/right or bottom/left, from the font's BASE table or, without one, the average ink box of some ideographs and kana; Proportional Metrics (the same menu; `{proportionalMetrics}`) sets full-width glyphs on the font's proportional widths (OpenType `palt`) in horizontal type and upright glyphs on its proportional heights (`vpal`, shaped top to bottom; fonts without vertical metrics keep their cells) in vertical type, and Line-end Punctuation Half Width takes nothing more off the punctuation they re-spaced; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. The interface is available in Polish (`pl`): menus, panels, dialogs and messages, with one/few/many Line truncated
The Russian catalog (`crates/ui-egui/src/i18n/ru.tsv`) has 1,811 more `@msg` rows, for status and error messages of commands, scripts and file import and export, 3,444 `@msg` rows in all counted on 2026-11-13 (`russian_translates_command_script_and_file_messages` in `crates/ui-egui/src/i18n/tests.rs`). Scores and estimates are unchanged.
With Line-end Punctuation Half Width, both composers measure a line with its last character set as narrow as Mojikumi sets it ([the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/use-mojikumi-for-japanese-text-composition.html)): a closing bracket, comma or full stop that fits at half width ends the line, and the character before it no longer goes to the next line with it. A mark that already lost its half to the punctuation after it and a line that ends in a hyphen take nothing more off, and the quarter em between Japanese and Latin text counts only where the line ends there. Kinsoku Shori Type and Burasagari Regular measure lines the same way; right-to-left lines and Mojikumi None break as before. In a frame that is not a rectangle, or with text wrap, a line's first word is measured as it is set (an opening bracket at its start flush, its last character narrowed) when layout looks for a line wide enough for it, and it ends only where the line may break, so kinsoku keeps an opening bracket with the character after it and a No Break run counts whole (`crates/text/src/layout/wrapping_tests.rs`, `crates/text/src/tests/vertical.rs`). Scores and estimates are unchanged.
The Paragraph panel's Mojikumi Set lists the five predefined sets the help page names (None, YakumonoHankaku, GyomatsuYakumonoHankaku, GyomatsuYakumonoZenkaku and YakumonoZenkaku), then Line-end Punctuation Half Width, and `text.setFormat {mojikumi}` takes each of them. YakumonoHankaku sets every bracket, comma and full stop half width and takes a quarter em off each side of a middle dot; GyomatsuYakumonoHankaku keeps punctuation full width inside a line, sets an opening bracket flush at a line's start and a closing mark half width at its end, and takes the quarter em after a middle dot off at a line's end; GyomatsuYakumonoZenkaku keeps punctuation full width and adds a quarter em between Japanese and Latin text; YakumonoZenkaku sets characters as None does. These widths are VectorCraft's own rules, from the help page's one-line description of each set. Both composers and vertical type measure each line as it is set, the sets save with the document and paragraph styles, and a `.ai` save reports the new sets as left out (`crates/text/src/tests/vertical.rs`, `crates/ui-egui/src/panels/paragraph/tests.rs`). Scores and estimates are unchanged.
Interface text in characters the interface's fonts lack, drawn in a bundled Japanese, Georgian or Devanagari face or in an installed font that covers them, sits on the baseline of the Latin text beside it, monospace text included (#5816; `crates/ui-egui/src/ui_fonts.rs`, `crates/ui-egui/src/theme.rs`).
@@ -1775,6 +1777,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
A top object whose top and bottom sides, or left and right sides, have different numbers of segments is also saved live: the side with fewer segments is split into as many as the side across from it has (each segment into equal spans of its curve, a straight one at even steps), up to the 50 a side the grid holds, so the file opens with the same corners and the same mapping of the contents, its outline holding the added anchors. Where the split side would share out the contents another way, as a side of two curves that aren't one curve can, or a side has more than 50 segments, the envelope is written as its distorted art, with the warning (`a_top_object_with_uneven_sides_is_read_back_live`, `a_top_object_split_to_the_grids_limit_is_read_back_live` and `a_top_object_whose_split_side_would_map_another_way_is_written_as_its_art` in `crates/eps/src/ai_editing/tests.rs`).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes eligible paths, compound paths and groups with live effects with an art style when the writer supports their appearance and effects (not a filled path that uses the even-odd rule, and none on a large canvas), which VectorCraft's `.ai` reader opens as the same appearance with its effects live (`objects_with_live_effects_are_read_back` and `every_effect_setting_written_on_an_object_is_read_back` in `crates/eps/src/ai_editing/tests.rs`; [file-format-parity.md](file-format-parity.md) lists the objects written without one and the effects they lose).
The same holds for the objects of an opacity mask's art, a mask inside another mask's art and a hidden art root included, so a mask whose art has Offset Path opens drawing the image it masks as it did, with the effect live; geometry effects that no art style holds on a mask's art, such as Roughen, are written applied to the art, which opens drawing what it drew (`a_masked_image_with_live_offset_path_round_trips`, `hidden_and_nested_mask_art_keep_live_offset_path` and `a_masks_art_with_an_effect_no_style_holds_is_written_as_it_draws` in `crates/eps/src/ai_editing/tests.rs`).
Opacity masks in a symbol's art and in a pattern's tile are written the same way, so a symbol or pattern whose mask art has Offset Path opens with the effect live in its definition, and its instances and pattern fills draw as they did; each definition's mask art keeps its own style, and mask art linked to a graphic style opens still linked to it (`a_symbols_mask_art_keeps_live_offset_path`, `a_pattern_tiles_mask_art_keeps_live_offset_path`, `mask_art_styles_stay_with_their_own_art` and `opacity_mask_art_keeps_its_graphic_style_link` in `crates/eps/src/ai_editing/tests.rs`).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes point type, area type and type on a path as type in its editing copy, and objects next to it keep their own transparency (`crates/eps/src/ai_editing/tests.rs`, `cmd::fileio::tests_pdfedit::type_comes_back_from_the_editing_copy`; [file-format-parity.md](file-format-parity.md) lists what is written as outlines).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps the document's variables, data sets and the bindings of objects to variables in its editing copy, in the form the variable library reader above reads, so they come back when the file is opened. Bindings to layers, to type written as outlines, to graphs and to linked images written as other objects, data set values of graphs, and variables, data sets, bindings and values past the writer's limits are left out with a warning (#6024; `crates/eps/src/ai_editing/tests.rs` `variables_data_sets_and_bindings_are_read_back`; `crates/eps/src/ai_editing/writer/variables.rs` lists what is left out).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps each wrap object's Text Wrap Options in its editing copy: the Offset, positive or negative, and Invert Wrap ([the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/wrap-or-unwrap-text-around-objects.html)), in the form the `.ai` reader reads them (`text_wrap` in `crates/eps/src/import/ai/read/document.rs`), so they come back when the file is opened. An offset past the -1000 to 1000 pt the reader keeps is written as the nearer end of that range. On a large canvas the offset is written at the art's scale and comes back at its size. Art the writer draws for an object, such as a blend's steps or a symbol instance written as its art, has only that object's options, and a clipping path written as its fills and its strokes has its options once (`crates/eps/src/ai_editing/tests.rs` `text_wrap_options_are_written_and_read_back`, `drawn_art_keeps_only_its_objects_text_wrap`, `text_wrap_offsets_on_a_large_canvas_come_back_at_their_size`, `text_wrap_options_of_type_and_envelopes_are_read_back`, `a_clipping_path_written_as_its_paint_keeps_one_text_wrap`).
+1
View File
@@ -384,6 +384,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
| Selection artwork drag hovers a visible document tab to activate it, then drops editable artwork on its canvas | done | `tests_document_drag`, `edit.dropSelection`, lossless resource and one-step Undo regressions; overflow and cross-window drag remain separate |
| A document tab dragged along the tab strip moves its document; a line marks where it goes, the current document and every document's view stay as they were, and a drag off the strip still floats it | done | #5663, [public source](https://helpx.adobe.com/illustrator/using/customizing-workspace.html); `document.move`; `tests::tab_reorder`, `chrome::tests` (drop index with floating and view tabs), `engine` `tests::document_move` |
| A middle-click on a document tab or its × closes it as the × does; closing a modified document's last view asks to save first (VectorCraft addition, as in PhotoCraft) | done | #6506; `chrome::tests::a_middle_click_on_a_tab_closes_it_as_the_close_box_does`; not scored |
| Panels hidden by Tab or Shift+Tab show for a while when the pointer rests on the left or right edge of the window, over the canvas, and hide again when it moves away; Tab shows them for good | done | Part of #5661; `window.panels.peek` ([Workspace basics](https://web.archive.org/web/2014/https://helpx.adobe.com/illustrator/using/workspace-basics.html), "Hide or show all panels"); VectorCraft's own choices: the 6 pt band and the 0.3 s delays, only the docked panels on that side show (floating panels, Tools and the Control bar stay hidden), and nothing shows in Presentation Mode; `panel_docking::tests::resting_on_the_right_edge_shows_the_hidden_panels_over_the_canvas_until_the_pointer_leaves` and the tests after it |
| Behaviour | Status | Notes |
|---|---|---|