Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Installed ICC profiles in the profile menus, and Mirror in Print (#3011)

Moiztermindb1900ace289e
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs
index 3d4b73f4d..a3599ecd6 100644
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@ -1187,6 +1187,7 @@ fn build() -> Vec<CommandSpec> {
v.extend(crate::web_cmds::specs());
v.extend(crate::automate_cmds::specs());
v.extend(crate::print_cmds::specs());
+ v.extend(crate::installed_profiles::specs());
v.extend(crate::pick_cmds::specs());
v.extend(crate::layer_nav_cmds::specs());
v.extend(crate::frame_cmds::specs());
diff --git a/crates/engine/src/installed_profiles.rs b/crates/engine/src/installed_profiles.rs
new file mode 100644
index 000000000..33fb3d351
--- /dev/null
+++ b/crates/engine/src/installed_profiles.rs
@@ -0,0 +1,240 @@
+//! ICC profiles installed in the operating system, as Photoshop lists them in Print › Printer
+//! Profile, View › Proof Setup › Custom and Edit › Convert to Profile: printer and paper profiles
+//! a user installs (Windows › Install Profile, macOS ColorSync, Linux `~/.local/share/icc`) appear
+//! by their description, and the commands take the file's path.
+//!
+//! `edit.installedProfiles` lists them for agents; the dialogs call [`installed`].
+
+use std::path::{Path, PathBuf};
+use std::sync::Mutex;
+
+use photocraft_cms::{ColorSpace, Profile, ProfileClass};
+use serde_json::{Value, json};
+
+use crate::commands::CommandSpec;
+use crate::{EngineError, Result, Session};
+
+/// One installed profile.
+#[derive(Clone, Debug, PartialEq)]
+pub struct InstalledProfile {
+ /// The file, as the profile commands take it.
+ pub path: String,
+ pub description: String,
+ pub class: ProfileClass,
+ pub color_space: ColorSpace,
+}
+
+impl InstalledProfile {
+ /// Whether a document can be assigned, converted or proofed to it (device and colour space
+ /// profiles in RGB, CMYK or Gray; device links, abstract and named colour profiles are not).
+ pub fn is_destination(&self) -> bool {
+ matches!(self.class, ProfileClass::Input | ProfileClass::Display | ProfileClass::Output | ProfileClass::ColorSpace)
+ && matches!(self.color_space, ColorSpace::Rgb | ColorSpace::Cmyk | ColorSpace::Gray)
+ }
+}
+
+/// Folders scanned at most this deep (macOS keeps profiles in vendor subfolders).
+const MAX_DEPTH: usize = 3;
+/// At most this many files are parsed per scan.
+const MAX_FILES: usize = 1000;
+/// Larger files are not profiles anyone prints with.
+const MAX_BYTES: u64 = 32 << 20;
+
+/// The operating system's colour profile folders.
+pub fn profile_dirs() -> Vec<PathBuf> {
+ let mut v = Vec::new();
+ let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")).map(PathBuf::from);
+ if cfg!(windows) {
+ let root = std::env::var_os("SystemRoot").map_or_else(|| PathBuf::from(r"C:\Windows"), PathBuf::from);
+ v.push(root.join(r"System32\spool\drivers\color"));
+ } else if cfg!(target_os = "macos") {
+ v.push(PathBuf::from("/System/Library/ColorSync/Profiles"));
+ v.push(PathBuf::from("/Library/ColorSync/Profiles"));
+ if let Some(h) = &home {
+ v.push(h.join("Library/ColorSync/Profiles"));
+ }
+ } else {
+ v.push(PathBuf::from("/usr/share/color/icc"));
+ v.push(PathBuf::from("/usr/local/share/color/icc"));
+ if let Some(h) = &home {
+ v.push(h.join(".local/share/icc"));
+ v.push(h.join(".color/icc"));
+ }
+ }
+ v
+}
+
+/// Every profile under `dirs` that parses, sorted by description; unreadable or malformed files
+/// are skipped.
+pub fn scan(dirs: &[PathBuf]) -> Vec<InstalledProfile> {
+ let mut files = Vec::new();
+ for d in dirs {
+ collect(d, 0, &mut files);
+ }
+ let mut out: Vec<InstalledProfile> = files.iter().filter_map(|f| read_one(f)).collect();
+ out.sort_by(|a, b| a.description.to_lowercase().cmp(&b.description.to_lowercase()).then_with(|| a.path.cmp(&b.path)));
+ out.dedup_by(|a, b| a.path == b.path);
+ out
+}
+
+fn collect(dir: &Path, depth: usize, files: &mut Vec<PathBuf>) {
+ if depth > MAX_DEPTH || files.len() >= MAX_FILES {
+ return;
+ }
+ let Ok(entries) = std::fs::read_dir(dir) else { return };
+ for e in entries.flatten() {
+ if files.len() >= MAX_FILES {
+ return;
+ }
+ let path = e.path();
+ let Ok(ft) = e.file_type() else { continue };
+ if ft.is_dir() {
+ collect(&path, depth + 1, files);
+ } else if path.extension().and_then(|x| x.to_str()).is_some_and(|x| x.eq_ignore_ascii_case("icc") || x.eq_ignore_ascii_case("icm")) {
+ files.push(path);
+ }
+ }
+}
+
+fn read_one(path: &Path) -> Option<InstalledProfile> {
+ if std::fs::metadata(path).ok()?.len() > MAX_BYTES {
+ return None;
+ }
+ let bytes = std::fs::read(path).ok()?;
+ let p = Profile::parse(&bytes).ok()?;
+ let path = path.to_string_lossy().into_owned();
+ let description = if p.description.trim().is_empty() {
+ Path::new(&path).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_else(|| path.clone())
+ } else {
+ p.description.trim().to_string()
+ };
+ Some(InstalledProfile { path, description, class: p.class, color_space: p.color_space })
+}
+
+/// How long a scan is reused: dialogs ask every frame, and a newly installed profile shows up
+/// within this long.
+const FRESH: std::time::Duration = std::time::Duration::from_secs(10);
+
+/// The installed profiles (cached; see [`FRESH`]). Empty on the web.
+pub fn installed() -> Vec<InstalledProfile> {
+ if cfg!(target_arch = "wasm32") {
+ return Vec::new();
+ }
+ type Cache = Mutex<Option<(std::time::Instant, Vec<InstalledProfile>)>>;
+ static CACHE: std::sync::OnceLock<Cache> = std::sync::OnceLock::new();
+ let cache = CACHE.get_or_init(Default::default);
+ if let Some((at, list)) = cache.lock().unwrap_or_else(|e| e.into_inner()).as_ref()
+ && at.elapsed() < FRESH
+ {
+ return list.clone();
+ }
+ let list = scan(&profile_dirs());
+ *cache.lock().unwrap_or_else(|e| e.into_inner()) = Some((std::time::Instant::now(), list.clone()));
+ list
+}
+
+fn class_id(c: ProfileClass) -> &'static str {
+ match c {
+ ProfileClass::Input => "input",
+ ProfileClass::Display => "display",
+ ProfileClass::Output => "output",
+ ProfileClass::DeviceLink => "deviceLink",
+ ProfileClass::ColorSpace => "colorSpace",
+ ProfileClass::Abstract => "abstract",
+ ProfileClass::NamedColor => "namedColor",
+ ProfileClass::Unknown(_) => "unknown",
+ }
+}
+
+fn space_id(c: ColorSpace) -> String {
+ format!("{c:?}").to_lowercase()
+}
+
+fn list(_: &mut Session, p: &Value) -> Result<Value> {
+ let bad = |msg: String| EngineError::BadParams { cmd: "edit.installedProfiles".into(), msg };
+ let class = match p.get("class") {
+ None | Some(Value::Null) => "any",
+ Some(Value::String(s)) if ["any", "input", "display", "output", "deviceLink", "colorSpace", "abstract", "namedColor"].contains(&s.as_str()) => s,
+ Some(v) => return Err(bad(format!("class is any|input|display|output|deviceLink|colorSpace|abstract|namedColor, not {v}"))),
+ };
+ let space = match p.get("colorSpace") {
+ None | Some(Value::Null) => "any",
+ Some(Value::String(s)) if ["any", "rgb", "cmyk", "gray"].contains(&s.as_str()) => s,
+ Some(v) => return Err(bad(format!("colorSpace is any|rgb|cmyk|gray, not {v}"))),
+ };
+ let profiles: Vec<Value> = installed()
+ .into_iter()
+ .filter(|i| class == "any" || class_id(i.class) == class)
+ .filter(|i| space == "any" || space_id(i.color_space) == space)
+ .map(|i| json!({"path": i.path, "description": i.description, "class": class_id(i.class), "colorSpace": space_id(i.color_space)}))
+ .collect();
+ let dirs: Vec<String> = profile_dirs().iter().map(|d| d.to_string_lossy().into_owned()).collect();
+ Ok(json!({"profiles": profiles, "dirs": dirs}))
+}
+
+/// `edit.installedProfiles`.
+pub fn specs() -> Vec<CommandSpec> {
+ vec![CommandSpec {
+ id: "edit.installedProfiles",
+ label: "Installed Profiles",
+ menu: &[],
+ shortcut: None,
+ params: r##"{"class":"any|input|display|output|deviceLink|colorSpace|abstract|namedColor"="any","colorSpace":"any|rgb|cmyk|gray"="any"} → {profiles: [{path, description, class, colorSpace}], dirs} (the OS profile folders; pass a path as any command's "profile")"##,
+ enabled: |_| Ok(()),
+ run: list,
+ journal: false,
+ }]
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use photocraft_cms::Builtin;
+
+ fn temp_dir(tag: &str) -> PathBuf {
+ let d = std::env::temp_dir().join(format!("pc-installed-{tag}-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&d);
+ std::fs::create_dir_all(d.join("vendor")).unwrap();
+ d
+ }
+
+ #[test]
+ fn scan_lists_parsable_profiles_by_description_and_skips_junk() {
+ let d = temp_dir("scan");
+ std::fs::write(d.join("b.icc"), Builtin::Srgb.profile().to_bytes().as_slice()).unwrap();
+ std::fs::write(d.join("vendor").join("a.ICM"), Builtin::CoatedCmyk.profile().to_bytes().as_slice()).unwrap();
+ std::fs::write(d.join("broken.icc"), b"not a profile").unwrap();
+ std::fs::write(d.join("empty.icc"), b"").unwrap();
+ std::fs::write(d.join("notes.txt"), b"x").unwrap();
+ let found = scan(&[d.clone(), d.join("missing")]);
+ let names: Vec<&str> = found.iter().map(|p| p.description.as_str()).collect();
+ assert_eq!(names.len(), 2, "{names:?}");
+ assert!(names[0].to_lowercase() <= names[1].to_lowercase());
+ let cmyk = found.iter().find(|p| p.color_space == ColorSpace::Cmyk).unwrap();
+ assert!(cmyk.path.ends_with("a.ICM"));
+ assert!(cmyk.is_destination());
+ // The listed path is what the profile commands accept.
+ assert!(crate::color_cmds::resolve_profile(&cmyk.path, None, None).is_ok());
+ let _ = std::fs::remove_dir_all(&d);
+ }
+
+ #[test]
+ fn scan_of_nothing_is_empty() {
+ assert!(scan(&[]).is_empty());
+ assert!(scan(&[PathBuf::from("/definitely/not/a/folder")]).is_empty());
+ }
+
+ #[test]
+ fn command_filters_and_rejects_bad_params() {
+ let mut s = Session::new();
+ let r = s.execute("edit.installedProfiles", json!({})).unwrap();
+ assert!(r["profiles"].is_array() && r["dirs"].is_array());
+ let r = s.execute("edit.installedProfiles", json!({"class": "output", "colorSpace": "cmyk"})).unwrap();
+ for p in r["profiles"].as_array().unwrap() {
+ assert_eq!((p["class"].as_str(), p["colorSpace"].as_str()), (Some("output"), Some("cmyk")));
+ }
+ for bad in [json!({"class": 3}), json!({"class": "printer"}), json!({"colorSpace": "lab"}), json!({"colorSpace": []})] {
+ assert!(s.execute("edit.installedProfiles", bad).is_err());
+ }
+ }
+}
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index 1fffd0bdc..401199f5f 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -53,6 +53,7 @@ pub mod hidden_target;
pub mod history_cmds;
pub mod image_cmds;
pub mod inspect;
+pub mod installed_profiles;
pub mod jobs;
pub mod kys;
pub mod layer_copy_cmds;
diff --git a/crates/engine/src/print_cmds.rs b/crates/engine/src/print_cmds.rs
index 96977a565..59d6b3e1e 100644
--- a/crates/engine/src/print_cmds.rs
+++ b/crates/engine/src/print_cmds.rs
@@ -68,6 +68,9 @@ pub struct PrintPage {
pub marks: Marks,
pub description: Option<String>,
pub label: Option<String>,
+ /// Photoshop's Functions › Emulsion Down: the whole page mirrored left to right, for transfer
+ /// printing (sublimation, iron-on, DTF, film read from the back).
+ pub emulsion_down: bool,
}
fn pdf_string(s: &str) -> String {
@@ -153,7 +156,11 @@ pub fn print_pdf(page: &PrintPage) -> Vec<u8> {
.as_bytes(),
);
// An explicit white page, so every viewer (and rasteriser) shows paper, not transparency.
- let mut content = format!("q 1 g 0 0 {pw:.2} {ph:.2} re f Q\nq {w:.3} 0 0 {h:.3} {x:.3} {y:.3} cm /Im0 Do Q\n");
+ let mut content = format!("q 1 g 0 0 {pw:.2} {ph:.2} re f Q\n");
+ if page.emulsion_down {
+ content.push_str(&format!("q -1 0 0 1 {pw:.2} 0 cm\n"));
+ }
+ content.push_str(&format!("q {w:.3} 0 0 {h:.3} {x:.3} {y:.3} cm /Im0 Do Q\n"));
content.push_str(&marks_ops(page.marks, page.rect));
let any_marks = page.marks.corner_crop || page.marks.center_crop || page.marks.registration;
let pad = if any_marks { 30.0 } else { 6.0 };
@@ -163,6 +170,9 @@ pub fn print_pdf(page: &PrintPage) -> Vec<u8> {
if let Some(d) = page.description.as_deref().filter(|d| !d.is_empty()) {
content.push_str(&format!("BT /F1 8 Tf 0 g {:.2} {:.2} Td {} Tj ET\n", x, y - pad - 8.0, pdf_string(d)));
}
+ if page.emulsion_down {
+ content.push_str("Q\n");
+ }
let c = deflate(content.as_bytes());
let mut body = format!("<< /Length {} /Filter /FlateDecode >>\nstream\n", c.len()).into_bytes();
body.extend_from_slice(&c);
@@ -281,6 +291,8 @@ pub struct PrintLayout {
/// Print scale (1.0 = 100 %).
pub scale: f64,
pub marks: Marks,
+ /// Emulsion Down: the page prints mirrored (`rect` is where the image is before mirroring).
+ pub emulsion_down: bool,
}
/// The print layout for `doc` with Print parameters `p` (used by the dialog's preview too).
@@ -310,14 +322,15 @@ pub fn layout(doc: &Document, p: &Value, cmd: &str) -> Result<PrintLayout> {
let left = p.get("left").and_then(Value::as_f64).unwrap_or(0.0) * 72.0;
(left, ph - top - h)
};
- Ok(PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks })
+ let emulsion_down = p.get("emulsionDown").and_then(Value::as_bool).unwrap_or(false);
+ Ok(PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down })
}
/// Lays out, renders and (unless dry-run) spools a print. Shared by Print and Print One Copy.
fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
let d = s.active().ok_or(EngineError::NoDocument)?;
let doc = d.doc.clone();
- let PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks } = layout(&doc, p, cmd)?;
+ let PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down } = layout(&doc, p, cmd)?;
let (img, color) = print_image(&doc, p, cmd)?;
let description = p
.get("description")
@@ -325,8 +338,7 @@ fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
.unwrap_or(false)
.then(|| crate::file_cmds::read_file_info(doc.metadata.xmp.as_deref())["description"].as_str().unwrap_or_default().to_string());
let label = p.get("labels").and_then(Value::as_bool).unwrap_or(false).then(|| doc.name.clone());
- let page = PrintPage { paper: (pw, ph), image: img, rect: (x, y, w, h), marks, description, label };
- let pdf = print_pdf(&page);
+ let page = PrintPage { paper: (pw, ph), image: img, rect: (x, y, w, h), marks, description, label, emulsion_down };
let output = p.get("output").and_then(Value::as_str).filter(|v| !v.is_empty()).map(str::to_string);
let send = p.get("send").and_then(Value::as_bool).unwrap_or(output.is_none());
let pdf_path = match &output {
@@ -339,8 +351,10 @@ fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
join(&tmp, &format!("{}-print-{}-{n}.pdf", crate::file_cmds::sanitize(&stem(&doc.name)), std::process::id()))
}
};
- write_file(&pdf_path, &pdf)?;
let copies = crate::commands::int(p, "copies").unwrap_or(1).clamp(1, 999);
+ let dry = p.get("dryRun").and_then(Value::as_bool).unwrap_or(false);
+ let pdf = print_pdf(&page);
+ write_file(&pdf_path, &pdf)?;
let mut argv: Vec<String> = vec!["lp".into()];
if let Some(pr) = p.get("printer").and_then(Value::as_str).filter(|v| !v.is_empty()) {
argv.extend(["-d".into(), pr.to_string()]);
@@ -349,23 +363,27 @@ fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
argv.extend(["-n".into(), copies.to_string()]);
}
argv.extend(["-t".into(), doc.name.clone(), pdf_path.clone()]);
- let dry = p.get("dryRun").and_then(Value::as_bool).unwrap_or(false);
let mut sent = false;
let mut spool = Value::Null;
if send && !dry {
spool = json!(spool_pdf(&argv)?);
sent = true;
}
+ remember_print(s, p);
+ crate::automate_cmds::fire_event(s, "print");
+ Ok(
+ json!({"pdf": pdf_path, "bytes": pdf.len(), "paper": [pw, ph], "imageRect": [x, y, w, h], "emulsionDown": emulsion_down, "scale": scale * 100.0, "copies": copies, "command": if send { json!(argv) } else { Value::Null }, "sent": sent, "spooler": spool, "color": color}),
+ )
+}
+
+/// Print One Copy repeats these.
+fn remember_print(s: &mut Session, p: &Value) {
let mut remembered = p.clone();
if let Some(o) = remembered.as_object_mut() {
o.remove("output");
o.remove("dryRun");
}
s.file_menu.last_print = Some(remembered);
- crate::automate_cmds::fire_event(s, "print");
- Ok(
- json!({"pdf": pdf_path, "bytes": pdf.len(), "paper": [pw, ph], "imageRect": [x, y, w, h], "scale": scale * 100.0, "copies": copies, "command": if send { json!(argv) } else { Value::Null }, "sent": sent, "spooler": spool, "color": color}),
- )
}
#[cfg(not(target_arch = "wasm32"))]
@@ -549,7 +567,7 @@ pub fn specs() -> Vec<CommandSpec> {
CommandSpec { id: $id, label: $label, menu: $menu, shortcut: $sc, params: $params, enabled: $enabled, journal: true, run: $run }
};
}
- const PRINT_PARAMS: &str = r##"{"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"dryRun":bool=false (render the PDF, report the lp command, don't spool)} → {pdf, imageRect, command, sent}"##;
+ const PRINT_PARAMS: &str = r##"{"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"emulsionDown":bool=false (mirror the page left to right, for sublimation and other transfer printing),"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"dryRun":bool=false (render the PDF, report the lp command, don't spool)} → {pdf, imageRect, command, sent}"##;
vec![
spec!("file.print", "Print…", &["File"], Some("Cmd+P"), PRINT_PARAMS, native_doc, print),
spec!(
diff --git a/crates/engine/src/print_cmds/tests.rs b/crates/engine/src/print_cmds/tests.rs
index 0adb00eb8..877fb945f 100644
--- a/crates/engine/src/print_cmds/tests.rs
+++ b/crates/engine/src/print_cmds/tests.rs
@@ -94,6 +94,61 @@ fn photocraft_manages_colors_converts_to_the_printer_profile() {
let _ = std::fs::remove_file(r["pdf"].as_str().unwrap());
}
+/// The inflated page content stream (object 4).
+fn pdf_content(pdf: &[u8]) -> String {
+ let i = find(pdf, b"4 0 obj\n", 0);
+ let len_at = find(pdf, b"/Length ", i) + 8;
+ let len: usize = String::from_utf8_lossy(&pdf[len_at..len_at + 12]).split_whitespace().next().unwrap().parse().unwrap();
+ let start = find(pdf, b"stream\n", i) + 7;
+ let mut out = String::new();
+ std::io::Read::read_to_string(&mut flate2::read::ZlibDecoder::new(&pdf[start..start + len]), &mut out).unwrap();
+ out
+}
+
+#[test]
+fn emulsion_down_mirrors_the_whole_page() {
+ let mut s = session("rgb", 8);
+ let plain = s.execute("file.print", json!({"dryRun": true, "paper": "a4", "center": false, "left": 1.0, "top": 1.0, "labels": true})).unwrap();
+ let mirrored = s
+ .execute("file.print", json!({"dryRun": true, "paper": "a4", "center": false, "left": 1.0, "top": 1.0, "labels": true, "emulsionDown": true}))
+ .unwrap();
+ assert_eq!(plain["emulsionDown"], false);
+ assert_eq!(mirrored["emulsionDown"], true);
+ // Same layout; only the page is flipped.
+ assert_eq!(plain["imageRect"], mirrored["imageRect"]);
+ let (p, m) = (std::fs::read(plain["pdf"].as_str().unwrap()).unwrap(), std::fs::read(mirrored["pdf"].as_str().unwrap()).unwrap());
+ let (pc, mc) = (pdf_content(&p), pdf_content(&m));
+ assert!(!pc.contains("-1 0 0 1"));
+ // The flip wraps the image and the label, after the white paper, and is closed again.
+ let flip = mc.find("q -1 0 0 1 595.28 0 cm").expect("mirror transform");
+ assert!(flip > mc.find("re f Q").unwrap() && flip < mc.find("/Im0 Do").unwrap() && flip < mc.find("Tj").unwrap());
+ assert_eq!(mc.matches("q ").count() + mc.matches("q\n").count(), mc.matches("Q\n").count(), "balanced q/Q: {mc}");
+ // The pixels themselves are not touched (the transform mirrors them).
+ assert_eq!(pdf_image(&p).3, pdf_image(&m).3);
+ // Print One Copy keeps it.
+ let again = s.execute("file.printOneCopy", json!({"dryRun": true})).unwrap();
+ assert_eq!(again["emulsionDown"], true);
+ for r in [plain, mirrored, again] {
+ let _ = std::fs::remove_file(r["pdf"].as_str().unwrap());
+ }
+}
+
+#[test]
+fn printer_profile_can_be_an_installed_icc_file() {
+ let dir = tmp("icc");
+ let icc = format!("{dir}/My Paper.icc");
+ std::fs::write(&icc, photocraft_cms::Builtin::CoatedCmyk.profile().to_bytes().as_slice()).unwrap();
+ let mut s = session("rgb", 16);
+ let r = s.execute("file.print", json!({"dryRun": true, "colorHandling": "photocraftManages", "printerProfile": icc, "emulsionDown": true})).unwrap();
+ assert_eq!(r["color"]["printerProfile"], json!(icc));
+ let (_, _, cs, data) = pdf_image(&std::fs::read(r["pdf"].as_str().unwrap()).unwrap());
+ assert_eq!(cs, "[/ICCBased 7 0 R]");
+ assert_eq!(data.len(), 300 * 150 * 4);
+ assert!(s.execute("file.print", json!({"dryRun": true, "colorHandling": "photocraftManages", "printerProfile": format!("{dir}/missing.icc")})).is_err());
+ let _ = std::fs::remove_file(r["pdf"].as_str().unwrap());
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
#[test]
fn print_one_copy_repeats_the_last_settings() {
let mut s = session("rgb", 8);
diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs
index e7c85e6ac..1db52eeb8 100644
--- a/crates/ui-egui/src/file_ui.rs
+++ b/crates/ui-egui/src/file_ui.rs
@@ -585,6 +585,8 @@ pub fn open_print(app: &mut PhotocraftApp) -> u64 {
("registrationMarks", json!(false)),
("description", json!(false)),
("labels", json!(false)),
+ ("emulsionDown", json!(false)),
+ ("units", json!("cm")),
("output", json!("")),
] {
f.entry(k.to_string()).or_insert(v);
@@ -592,6 +594,33 @@ pub fn open_print(app: &mut PhotocraftApp) -> u64 {
app.ui.open_dialog(DialogKind::Command, f)
}
+/// Points per unit for the Position and Size fields.
+fn unit_pt(units: &str) -> f64 {
+ match units {
+ "mm" => 72.0 / 25.4,
+ "in" => 72.0,
+ _ => 72.0 / 2.54,
+ }
+}
+
+/// A number field in `units` for a value kept in points; true when edited.
+fn length_field(ui: &mut egui::Ui, label: &str, pt: &mut f64, units: &str) -> bool {
+ let t = Tokens::get(ui.ctx());
+ let k = unit_pt(units);
+ let mut v = (*pt / k) as f32;
+ let mut changed = false;
+ ui.horizontal(|ui| {
+ ui.label(egui::RichText::new(label).color(t.text_dim));
+ let before = v;
+ crate::widgets::value_field(ui, &mut v, 0.0..=10000.0, units, 70.0);
+ if (v - before).abs() > 1e-4 && v.is_finite() {
+ *pt = f64::from(v) * k;
+ changed = true;
+ }
+ });
+ changed
+}
+
fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let t = Tokens::get(ui.ctx());
let Some(doc) = app.session.active().map(|d| d.doc.clone()) else { return };
@@ -609,6 +638,8 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
ui.painter().rect_filled(page, 0.0, egui::Color32::WHITE);
ui.painter().rect_stroke(page, 0.0, egui::Stroke::new(1.0, t.separator), egui::StrokeKind::Outside);
let (x, y, w, h) = l.rect;
+ // Emulsion Down shows the page as it prints: mirrored.
+ let x = if l.emulsion_down { pw - x - w } else { x };
let img = egui::Rect::from_min_size(
egui::pos2(page.left() + x as f32 * k, page.bottom() - (y + h) as f32 * k),
egui::vec2(w as f32 * k, h as f32 * k),
@@ -623,7 +654,12 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
tx
});
let clip = ui.painter().with_clip_rect(page);
- clip.image(tex.id(), img, egui::Rect::from_min_max(egui::Pos2::ZERO, egui::pos2(1.0, 1.0)), egui::Color32::WHITE);
+ let uv = if l.emulsion_down {
+ egui::Rect::from_min_max(egui::pos2(1.0, 0.0), egui::pos2(0.0, 1.0))
+ } else {
+ egui::Rect::from_min_max(egui::Pos2::ZERO, egui::pos2(1.0, 1.0))
+ };
+ clip.image(tex.id(), img, uv, egui::Color32::WHITE);
let mark = egui::Stroke::new(1.0, egui::Color32::BLACK);
if l.marks.corner_crop {
for (c, dx, dy) in
@@ -691,20 +727,27 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
240.0,
);
if s(f, "colorHandling", "") == "photocraftManages" {
- dropdown_str(
- ui,
- "print-profile",
- f,
- "printerProfile",
- &[
- ("coated-cmyk", tl!("Coated CMYK")),
- ("srgb", "sRGB IEC61966-2.1"),
- ("adobe-rgb-compat", tl!("Adobe RGB (1998) compatible")),
- ("display-p3", tl!("Display P3")),
- ("gray-gamma-2.2", tl!("Gray Gamma 2.2")),
- ],
- 240.0,
- );
+ // Photoshop's Printer Profile menu: the built-ins, then every installed printer
+ // (output class) profile by its description.
+ let installed: Vec<_> = photocraft_engine::installed_profiles::installed()
+ .into_iter()
+ .filter(|p| p.is_destination() && p.class == photocraft_cms::ProfileClass::Output)
+ .collect();
+ let mut profiles: Vec<(&str, &str)> = vec![
+ ("coated-cmyk", tl!("Coated CMYK")),
+ ("srgb", "sRGB IEC61966-2.1"),
+ ("adobe-rgb-compat", tl!("Adobe RGB (1998) compatible")),
+ ("display-p3", tl!("Display P3")),
+ ("gray-gamma-2.2", tl!("Gray Gamma 2.2")),
+ ];
+ profiles.extend(installed.iter().map(|p| (p.path.as_str(), p.description.as_str())));
+ // A remembered profile that is no longer installed still shows, by its file name.
+ let cur = s(f, "printerProfile", "coated-cmyk");
+ let stem = std::path::Path::new(&cur).file_stem().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
+ if !profiles.iter().any(|(v, _)| *v == cur) {
+ profiles.push((cur.as_str(), stem.as_str()));
+ }
+ dropdown_str(ui, "print-profile", f, "printerProfile", &profiles, 240.0);
ui.horizontal(|ui| {
dropdown_str(
ui,
@@ -723,16 +766,54 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
});
}
head(ui, tl!("Position and Size"));
+ dropdown_str(ui, "print-units", f, "units", &[("cm", tl!("Centimeters")), ("mm", tl!("Millimeters")), ("in", tl!("Inches"))], 130.0);
+ let units = s(f, "units", "cm");
check(ui, f, "center", tl!("Center"), true);
if !b(f, "center", true) {
ui.horizontal(|ui| {
- number(ui, f, "top", tl!("Top"), 0.0..=100.0, "in", 0.0);
- number(ui, f, "left", tl!("Left"), 0.0..=100.0, "in", 0.0);
+ // Kept in inches (Photoshop's Position fields), shown in the chosen units.
+ for (key, label) in [("top", tl!("Top")), ("left", tl!("Left"))] {
+ let mut pt = n(f, key, 0.0) * 72.0;
+ if length_field(ui, label, &mut pt, &units) {
+ f.insert(key.into(), json!(pt / 72.0));
+ }
+ }
});
}
check(ui, f, "scaleToFit", tl!("Scale to Fit Media"), false);
- if !b(f, "scaleToFit", false) {
- number(ui, f, "scale", tl!("Scale"), 1.0..=1000.0, "%", 100.0);
+ // Scaled Print Size: Scale, Height and Width move together; Print Resolution follows.
+ if let Ok(l) = photocraft_engine::print_cmds::layout(&doc, &params(f), "file.print") {
+ let (_, _, w, h) = l.rect;
+ let (mut w2, mut h2) = (w, h);
+ let fit = b(f, "scaleToFit", false);
+ if !fit {
+ // Two decimals: Height and Width set fractional scales.
+ ui.horizontal(|ui| {
+ ui.label(egui::RichText::new(tl!("Scale")).color(t.text_dim));
+ let mut v = n(f, "scale", 100.0) as f32;
+ crate::widgets::value_field(ui, &mut v, 1.0..=1000.0, "%", 64.0);
+ f.insert("scale".into(), json!((f64::from(v) * 100.0).round() / 100.0));
+ });
+ }
+ ui.horizontal(|ui| {
+ let hc = length_field(ui, tl!("Height"), &mut h2, &units);
+ let wc = length_field(ui, tl!("Width"), &mut w2, &units);
+ let k = if wc && w > 0.0 {
+ Some(w2 / w)
+ } else if hc && h > 0.0 {
+ Some(h2 / h)
+ } else {
+ None
+ };
+ if let Some(k) = k.filter(|k| k.is_finite() && *k > 0.0) {
+ f.insert("scale".into(), json!(((l.scale * k * 100.0) * 100.0).round() / 100.0));
+ f.insert("scaleToFit".into(), json!(false));
+ }
+ });
+ if w > 0.0 {
+ let ppi = f64::from(doc.size.width) / (w / 72.0);
+ ui.label(egui::RichText::new(format!("{} {ppi:.0} PPI", tl!("Print Resolution:"))).color(t.text_dim).size(11.0));
+ }
}
head(ui, tl!("Printing Marks"));
ui.horizontal(|ui| {
@@ -744,6 +825,8 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
check(ui, f, "description", tl!("Description"), false);
check(ui, f, "labels", tl!("Labels"), false);
});
+ head(ui, tl!("Functions"));
+ check(ui, f, "emulsionDown", tl!("Emulsion Down"), false);
head(ui, tl!("Save as PDF"));
let mut out = s(f, "output", "");
if ui.add(egui::TextEdit::singleline(&mut out).hint_text(tl!("(print to the printer)")).desired_width(300.0)).changed() {
diff --git a/crates/ui-egui/src/filter_dialog.rs b/crates/ui-egui/src/filter_dialog.rs
index f15fca02a..ee8e24fdb 100644
--- a/crates/ui-egui/src/filter_dialog.rs
+++ b/crates/ui-egui/src/filter_dialog.rs
@@ -491,6 +491,9 @@ fn uses_logarithmic_slider(min: f32, max: f32) -> bool {
min > 0.0 && max / min > 500.0
}
+/// Schema dialogs whose `profile` menu lists the installed profiles after the built-ins.
+const PROFILE_DIALOGS: &[&str] = &["edit.assignProfile", "edit.convertToProfile", "view.proofSetup"];
+
/// Commands whose `angle` is a direction in document angles (counter-clockwise from three
/// o'clock): a light or a blur direction, edited on a dial as in Photoshop's Motion Blur, Emboss
/// and Global Light (#3152). Rotation amounts (Twirl, Rotate Arbitrary, Crop, Lens Correction,
@@ -572,7 +575,21 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let initial = default.as_deref().or_else(|| options.first().map(String::as_str)).unwrap_or("");
let mut cur = f.get(&p.key).and_then(Value::as_str).unwrap_or(initial).to_string();
let labels: Vec<String> = options.iter().map(|o| choice_label(o)).collect();
- let opts: Vec<(String, &str)> = options.iter().cloned().zip(labels.iter().map(String::as_str)).collect();
+ let mut opts: Vec<(String, &str)> = options.iter().cloned().zip(labels.iter().map(String::as_str)).collect();
+ // Like Photoshop, the profile menus also list every profile installed in
+ // the system (printer and paper profiles), by description.
+ let installed = if p.key == "profile" && PROFILE_DIALOGS.contains(&cmd.as_str()) {
+ photocraft_engine::installed_profiles::installed().into_iter().filter(|i| i.is_destination()).collect()
+ } else {
+ Vec::new()
+ };
+ opts.extend(installed.iter().map(|i| (i.path.clone(), i.description.as_str())));
+ // A profile given by path that isn't listed (typed by an agent, or spelled with
+ // different case) still shows, by its file name, instead of a blank menu.
+ let stem = std::path::Path::new(&cur).file_stem().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
+ if p.key == "profile" && PROFILE_DIALOGS.contains(&cmd.as_str()) && !opts.iter().any(|(v, _)| *v == cur) {
+ opts.push((cur.clone(), stem.as_str()));
+ }
crate::widgets::dropdown(ui, &format!("flt-{cmd}-{}", p.key), &mut cur, &opts, 170.0);
f.insert(p.key.clone(), json!(cur));
});
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 94a46f6f2..81ccc1805 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -2589,3 +2589,7 @@ cameraData Lens Objektiv
Click to place · Alt-click or drag off-canvas to remove Kliknutím umístíte · Alt-kliknutím nebo přetažením mimo plátno odeberete
No document open Není otevřen žádný dokument
{n} of {max} sample points {n} z {max} bodů měření
+# Print dialog (#2697)
+ Emulsion Down Emulze dolů
+ Functions Funkce
+ Print Resolution: Rozlišení tisku:
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 7d6d9e8cf..08e86b65e 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -2620,3 +2620,7 @@ cameraData Lens Objektiv
Click to place · Alt-click or drag off-canvas to remove Klicken zum Platzieren · Alt-Klick oder Ziehen außerhalb der Arbeitsfläche zum Entfernen
No document open Kein Dokument geöffnet
{n} of {max} sample points {n} von {max} Messpunkten
+# Print dialog (#2697)
+ Emulsion Down Schichtseite unten
+ Functions Funktionen
+ Print Resolution: Druckauflösung:
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index 8556f6b5c..a19bf9069 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3679,3 +3679,7 @@ cameraData Lens Φακός
# Color Sampler (added with the i18n coverage repair)
Click to place · Alt-click or drag off-canvas to remove Κλικ για τοποθέτηση · Alt-κλικ ή σύρσιμο εκτός καμβά για αφαίρεση
{n} of {max} sample points {n} από {max} σημεία δειγματοληψίας
+# Print dialog (#2697)
+ Emulsion Down Γαλάκτωμα προς τα κάτω
+ Functions Λειτουργίες
+ Print Resolution: Ανάλυση εκτύπωσης:
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 8d4327e8a..844923df6 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2661,3 +2661,7 @@ cameraData Lens Objetivo
Click to place · Alt-click or drag off-canvas to remove Clic para colocar · Alt-clic o arrastrar fuera del lienzo para quitar
No document open Ningún documento abierto
{n} of {max} sample points {n} de {max} puntos de muestreo
+# Print dialog (#2697)
+ Emulsion Down Emulsión hacia abajo
+ Functions Funciones
+ Print Resolution: Resolución de impresión:
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 559c0989e..ef63939de 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -2998,3 +2998,7 @@ cameraData Lens Objectif
Click to place · Alt-click or drag off-canvas to remove Cliquez pour placer · Alt-clic ou glisser hors du canevas pour supprimer
No document open Aucun document ouvert
{n} of {max} sample points {n} sur {max} points d'échantillonnage
+# Print dialog (#2697)
+ Emulsion Down Émulsion verso
+ Functions Fonctions
+ Print Resolution: Résolution d’impression :
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 094fdd1f4..8a18cbfd8 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -2985,3 +2985,7 @@ cameraData Lens Lensa
Click to place · Alt-click or drag off-canvas to remove Klik untuk menempatkan · Alt-klik atau seret ke luar kanvas untuk menghapus
No document open Tidak ada dokumen yang terbuka
{n} of {max} sample points {n} dari {max} titik sampel
+# Print dialog (#2697)
+ Emulsion Down Emulsi di Bawah
+ Functions Fungsi
+ Print Resolution: Resolusi Cetak:
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index fce4454fc..6fe7c70ee 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -2652,3 +2652,7 @@ cameraData Lens Obiettivo
Click to place · Alt-click or drag off-canvas to remove Fai clic per posizionare · Alt-clic o trascina fuori dalla tela per rimuovere
No document open Nessun documento aperto
{n} of {max} sample points {n} di {max} punti di campionamento
+# Print dialog (#2697)
+ Emulsion Down Emulsione sotto
+ Functions Funzioni
+ Print Resolution: Risoluzione di stampa:
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 13de62b97..bbd5973d1 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3594,3 +3594,7 @@ cameraData Lens レンズ
Click to place · Alt-click or drag off-canvas to remove クリックで配置 · Alt キーを押しながらクリック、またはカンバス外へドラッグで削除
No document open ドキュメントが開かれていません
{n} of {max} sample points {max} 個中 {n} 個のサンプルポイント
+# Print dialog (#2697)
+ Emulsion Down 乳剤面を下
+ Functions 機能
+ Print Resolution: プリント解像度:
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 735241f8a..01bbfd010 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3163,3 +3163,7 @@ cameraData Lens 렌즈
Click to place · Alt-click or drag off-canvas to remove 클릭하여 배치 · Alt-클릭 또는 캔버스 밖으로 드래그하여 제거
No document open 열린 문서 없음
{n} of {max} sample points {max}개 중 {n}개의 샘플 지점
+# Print dialog (#2697)
+ Emulsion Down 감광면 아래로
+ Functions 기능
+ Print Resolution: 인쇄 해상도:
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index d85de7216..0b936867e 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3745,3 +3745,7 @@ cameraData Lens Lens
# Color Sampler (added with the i18n coverage repair)
Click to place · Alt-click or drag off-canvas to remove Klik om te plaatsen · Alt-klik of sleep buiten het canvas om te verwijderen
{n} of {max} sample points {n} van {max} steekproefpunten
+# Print dialog (#2697)
+ Emulsion Down Emulsie omlaag
+ Functions Functies
+ Print Resolution: Afdrukresolutie:
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 2fdfa368d..b32bf66ca 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3595,3 +3595,7 @@ cameraData Lens Obiektyw
Click to place · Alt-click or drag off-canvas to remove Kliknij, aby umieścić · Alt-kliknij lub przeciągnij poza obszar roboczy, aby usunąć
No document open Brak otwartego dokumentu
{n} of {max} sample points {n} z {max} punktów próbkowania
+# Print dialog (#2697)
+ Emulsion Down Emulsja w dół
+ Functions Funkcje
+ Print Resolution: Rozdzielczość druku:
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index d0289601a..03d52a5d8 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3775,3 +3775,7 @@ layerLabel No Color Sem cor
Set Colors Definir cores
Switch Foreground and Background Colors Alternar cores de primeiro plano e plano de fundo
Target Alvo
+# Print dialog (#2697)
+ Emulsion Down Emulsão para baixo
+ Functions Funções
+ Print Resolution: Resolução de impressão:
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 998678c04..47c209737 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -2927,3 +2927,7 @@ cameraData Lens Объектив
Click to place · Alt-click or drag off-canvas to remove Щёлкните, чтобы разместить · Alt-щелчок или перетаскивание за пределы холста для удаления
No document open Документ не открыт
{n} of {max} sample points {n} из {max} точек замера
+# Print dialog (#2697)
+ Emulsion Down Эмульсией вниз
+ Functions Функции
+ Print Resolution: Разрешение печати:
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index eaf6d1df9..4fadf2813 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3682,3 +3682,7 @@ cameraData Lens Об'єктив
Click to place · Alt-click or drag off-canvas to remove Клацніть, щоб розмістити · Alt-клацання або перетягування за межі полотна для видалення
No document open Документ не відкрито
{n} of {max} sample points {n} з {max} точок вимірювання
+# Print dialog (#2697)
+ Emulsion Down Емульсією донизу
+ Functions Функції
+ Print Resolution: Роздільна здатність друку:
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index 0b8c594e5..112b15ae0 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2596,3 +2596,7 @@ cameraData Lens 镜头
Click to place · Alt-click or drag off-canvas to remove 单击以放置 · Alt 单击或拖到画布外以移除
No document open 未打开任何文档
{n} of {max} sample points {max} 个取样点中的 {n} 个
+# Print dialog (#2697)
+ Emulsion Down 药膜朝下
+ Functions 功能
+ Print Resolution: 打印分辨率:
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 338897961..c995125f6 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2566,3 +2566,7 @@ cameraData Lens 鏡頭
Click to place · Alt-click or drag off-canvas to remove 按一下以放置 · Alt 按一下或拖曳至畫布外以移除
No document open 未開啟任何文件
{n} of {max} sample points {max} 個取樣點中的 {n} 個
+# Print dialog (#2697)
+ Emulsion Down 感光乳劑面朝下
+ Functions 功能
+ Print Resolution: 列印解析度: