From 68df6224ea52c9622c38cf3dd4dfd1fc875ab7ad Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 07:00:55 -0800 Subject: [PATCH] Accessibility: Save PDF and Print name every number and length field Screen readers found six image resolution fields in Save PDF with no name, and the four bleed fields were not connected to their labels. In Print, the artboard Range field had no name, Width and Height were both named Width:, Placement X and Y both Placement:, and Scale W and H both Scale:. - save_pdf::number_named and length_named take a name for a field that shares its row or has none; number and length keep naming a field by its row. - The resolution fields are named by their group and the word before them (Color images to, Color images above), the bleed fields by their side, Width and Height by their own labels, and Placement and Scale by the row and the axis. - No visible text changes. Tests: dialogs::save_pdf::tests and dialogs::tests_print every_number_and_length_field_is_named_by_its_label. --- crates/ui-egui/src/dialogs/print.rs | 40 ++++++++++------- crates/ui-egui/src/dialogs/save_pdf.rs | 28 +++++++++--- crates/ui-egui/src/dialogs/save_pdf/tests.rs | 38 ++++++++++++++++ crates/ui-egui/src/dialogs/tests_print.rs | 47 ++++++++++++++++++++ docs/target-app-parity.md | 1 + 5 files changed, 130 insertions(+), 24 deletions(-) diff --git a/crates/ui-egui/src/dialogs/print.rs b/crates/ui-egui/src/dialogs/print.rs index de04998800..532b9031e7 100644 --- a/crates/ui-egui/src/dialogs/print.rs +++ b/crates/ui-egui/src/dialogs/print.rs @@ -26,7 +26,9 @@ use vectorcraft_pdf::{ PrintSettings, }; -use super::save_pdf::{TOP_LABEL_WIDTH, choice, current_section, flag, get, heading, length, note, number, pick, row, row_with, set, text}; +use super::save_pdf::{ + TOP_LABEL_WIDTH, choice, current_section, flag, get, heading, length, length_named, note, number, pick, row, row_with, set, text, +}; use super::{DialogSpec, form}; use crate::state::Dialog; use crate::theme::{self, Tokens}; @@ -606,10 +608,11 @@ fn whole(ui: &mut egui::Ui, d: &mut Dialog, path: &str, range: std::ops::RangeIn }); } -/// A Scale percentage at `path`, 1–1000 %: the value typed, once one was. -fn percent(ui: &mut egui::Ui, d: &mut Dialog, path: &str, enabled: bool) -> Option { +/// A Scale percentage at `path`, 1–1000 %, that screen readers name `name`: the value typed, once +/// one was. +fn percent(ui: &mut egui::Ui, d: &mut Dialog, path: &str, name: &str, enabled: bool) -> Option { let v = get(d, path).as_f64().unwrap_or(100.0); - let typed = ui.add_enabled_ui(enabled, |ui| widgets::range_field(ui, path, v, 1.0..=1000.0, "%", 3, 64.0)).inner; + let typed = ui.add_enabled_ui(enabled, |ui| widgets::range_field_named(ui, path, Some(name), v, 1.0..=1000.0, "%", 3, 64.0)).inner; if let Some(x) = typed { set(d, path, json!(x)); } @@ -694,7 +697,7 @@ fn general(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) { } let mut range = get(d, "range").as_str().unwrap_or_default().to_string(); let edit = egui::TextEdit::singleline(&mut range).align(egui::Align2::LEFT_CENTER).desired_width(140.0).hint_text("1-3, 5"); - if ui.add_enabled(artboards == PrintArtboards::Range, edit).changed() { + if ui.add_enabled(artboards == PrintArtboards::Range, edit).accessible_name(tl!("Range:")).changed() { set(d, "range", json!(range)); } }); @@ -706,18 +709,19 @@ fn general(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) { row(ui, tl!("Size:"), |ui| { pick::(ui, d, "media", 160.0, |_| true); }); - // A paper size shows its size; Custom takes one. + // A paper size shows its size; Custom takes one. Each field is named by its own label. let media = choice::(d, "media").unwrap_or_default(); - row(ui, tl!("Width:"), |ui| match media.size() { + let (width, height) = (tl!("Width:"), tl!("Height:")); + row(ui, width, |ui| match media.size() { Some((w, h)) => { - ui.add_enabled_ui(false, |ui| widgets::num_field(ui, "print-media-w", Some(w), unit, 80.0)); - ui.label(tl!("Height:")); - ui.add_enabled_ui(false, |ui| widgets::num_field(ui, "print-media-h", Some(h), unit, 80.0)); + ui.add_enabled_ui(false, |ui| widgets::num_field_named(ui, "print-media-w", Some(width), Some(w), unit, 80.0)); + ui.label(height); + ui.add_enabled_ui(false, |ui| widgets::num_field_named(ui, "print-media-h", Some(height), Some(h), unit, 80.0)); } None => { - length(ui, d, "width", unit, true); - ui.label(tl!("Height:")); - length(ui, d, "height", unit, true); + length_named(ui, d, "width", Some(width), unit, true); + ui.label(height); + length_named(ui, d, "height", Some(height), unit, true); } }); heading(ui, tl!("Orientation")); @@ -741,10 +745,11 @@ fn general(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) { if let Some(o) = widgets::reference_point_named(ui, current, tl!("Placement:")).and_then(|i| Origin::ALL.get(i)) { set(d, "placement.origin", json!(o.id())); } + // Each offset is named by the row and its axis. ui.label("X:"); - length(ui, d, "placement.x", unit, true); + length_named(ui, d, "placement.x", Some(&format!("{} X:", tl!("Placement:"))), unit, true); ui.label("Y:"); - length(ui, d, "placement.y", unit, true); + length_named(ui, d, "placement.y", Some(&format!("{} Y:", tl!("Placement:"))), unit, true); }); }); if placed { @@ -761,13 +766,14 @@ fn general(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) { row(ui, tl!("Scale:"), |ui| { let on = scaling == PrintScaling::Custom || tiles; let linked = get(d, SCALE_LINKED).as_bool() == Some(true); + // Each percentage is named by the row and its own label. ui.label(tl!("W:")); - let w = percent(ui, d, "scale.width", on); + let w = percent(ui, d, "scale.width", &format!("{} {}", tl!("Scale:"), tl!("W:")), on); if let Some(w) = w.filter(|_| linked) { set(d, "scale.height", json!(w)); } ui.label(tl!("H:")); - let h = percent(ui, d, "scale.height", on); + let h = percent(ui, d, "scale.height", &format!("{} {}", tl!("Scale:"), tl!("H:")), on); if let Some(h) = h.filter(|_| linked) { set(d, "scale.width", json!(h)); } diff --git a/crates/ui-egui/src/dialogs/save_pdf.rs b/crates/ui-egui/src/dialogs/save_pdf.rs index a8db555bfb..e096ece979 100644 --- a/crates/ui-egui/src/dialogs/save_pdf.rs +++ b/crates/ui-egui/src/dialogs/save_pdf.rs @@ -399,9 +399,15 @@ pub(super) fn choice_label<'a>(lang: crate::i18n::Lang, path: &str, label: &'a s } pub(super) fn number(ui: &mut egui::Ui, d: &mut Dialog, path: &str, suffix: &str, enabled: bool) { + number_named(ui, d, path, None, suffix, enabled); +} + +/// [`number`] that screen readers name `name` (already translated) instead of by its row's label: +/// for a field that shares its row with another, or that has no row. +pub(super) fn number_named(ui: &mut egui::Ui, d: &mut Dialog, path: &str, name: Option<&str>, suffix: &str, enabled: bool) { let v = get(d, path).as_f64().unwrap_or(0.0); ui.add_enabled_ui(enabled, |ui| { - if let Some(x) = widgets::plain_field(ui, path, v, suffix, 3, 64.0) { + if let Some(x) = widgets::plain_field_named(ui, path, name, v, suffix, 3, 64.0) { set(d, path, json!(x)); } }); @@ -409,9 +415,14 @@ pub(super) fn number(ui: &mut egui::Ui, d: &mut Dialog, path: &str, suffix: &str /// A length in points, shown in the document's units. pub(super) fn length(ui: &mut egui::Ui, d: &mut Dialog, path: &str, unit: Unit, enabled: bool) { + length_named(ui, d, path, None, unit, enabled); +} + +/// [`length`] that screen readers name `name` (already translated), as [`number_named`] is. +pub(super) fn length_named(ui: &mut egui::Ui, d: &mut Dialog, path: &str, name: Option<&str>, unit: Unit, enabled: bool) { let v = get(d, path).as_f64(); ui.add_enabled_ui(enabled, |ui| { - if let Some(x) = widgets::num_field(ui, path, v, unit, 80.0) { + if let Some(x) = widgets::num_field_named(ui, path, name, v, unit, 80.0) { set(d, path, json!(x)); } }); @@ -637,6 +648,7 @@ fn general(ui: &mut egui::Ui, d: &mut Dialog, editor: bool) { let mut range = d.str("range"); if ui .add_enabled(!all, egui::TextEdit::singleline(&mut range).align(egui::Align2::LEFT_CENTER).desired_width(140.0).hint_text("1-3, 5")) + .accessible_name(tl!("Range:")) .changed() { d.fields.insert("range".into(), json!(range)); @@ -650,11 +662,12 @@ fn image_rows(ui: &mut egui::Ui, d: &mut Dialog, key: &str, title: &str) { let on = get(d, &format!("{base}.downsample")) != Downsample::None.id(); ui.horizontal(|ui| { pick::(ui, d, &format!("{base}.downsample"), 150.0, |_| true); + // Each resolution is named by its group and the word before it. ui.label(tl!("to")); let ppi = super::ppi_suffix(); - number(ui, d, &format!("{base}.ppi"), &ppi, on); + number_named(ui, d, &format!("{base}.ppi"), Some(&format!("{title} {}", tl!("to"))), &ppi, on); ui.label(tl!("above")); - number(ui, d, &format!("{base}.abovePpi"), &ppi, on); + number_named(ui, d, &format!("{base}.abovePpi"), Some(&format!("{title} {}", tl!("above"))), &ppi, on); }); ui.horizontal(|ui| { ui.label(tl!("Compression:")); @@ -728,16 +741,17 @@ pub(super) fn marks_and_bleeds(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut ] { for (i, p, label) in pair { ui.label(label); + // Each side's field is named by its label. match document { Some(b) => { - ui.add_enabled_ui(false, |ui| widgets::num_field(ui, p, b.get(i).copied(), unit, 80.0)); + ui.add_enabled_ui(false, |ui| widgets::num_field_named(ui, p, Some(label), b.get(i).copied(), unit, 80.0)); } None if pdf => { - if let Some(x) = widgets::num_field(ui, p, get(d, p).as_f64(), unit, 80.0) { + if let Some(x) = widgets::num_field_named(ui, p, Some(label), get(d, p).as_f64(), unit, 80.0) { edit_bleed(d, i, x); } } - None => length(ui, d, p, unit, true), + None => length_named(ui, d, p, Some(label), unit, true), } } ui.end_row(); diff --git a/crates/ui-egui/src/dialogs/save_pdf/tests.rs b/crates/ui-egui/src/dialogs/save_pdf/tests.rs index 501aed4ed0..929342832a 100644 --- a/crates/ui-egui/src/dialogs/save_pdf/tests.rs +++ b/crates/ui-egui/src/dialogs/save_pdf/tests.rs @@ -1570,3 +1570,41 @@ fn save_pdf_opens_with_the_flattener_options_given_and_refuses_bad_ones() { assert!(app.ui.dialog.is_none(), "{bad}"); } } + +/// Every number and length field is named by its visible label: the image resolutions by their +/// group and the word before the field, the bleed sides by theirs. +#[test] +fn every_number_and_length_field_is_named_by_its_label() { + let (mut app, _, _) = app(); + app.run("ui.savePdfDialog", json!({"path": "/tmp/names.pdf"})).unwrap(); + let ctx = egui::Context::default(); + ctx.enable_accesskit(); + theme::install_fonts(&ctx); + let names = |app: &mut VectorcraftApp, section: &str| { + set_field(app, "__section", json!(section)); + let mut out = egui::FullOutput::default(); + for _ in 0..2 { + out = ctx.run_ui(egui::RawInput::default(), |ui| super::super::show(app, ui.ctx())); + out.textures_delta.clear(); + } + let names = super::super::tests_print::field_names(&out); + assert!(names.iter().all(|n| !n.trim().is_empty()), "{section}: {names:?}"); + names + }; + let has = |names: &[String], expected: &[&str]| { + for name in expected { + assert_eq!(names.iter().filter(|n| n == name).count(), 1, "{name} in {names:?}"); + } + }; + has(&names(&mut app, "General"), &["Range:"]); + let compression = + ["Color images to", "Color images above", "Grayscale images to", "Grayscale images above", "Monochrome images to", "Monochrome images above"]; + has(&names(&mut app, "Compression"), &compression); + // Without the document's bleed the sides take values; with it they show it dimmed. + let bleed = ["Offset:", "Top:", "Bottom:", "Left:", "Right:"]; + set_field(&mut app, "bleed.useDocument", json!(false)); + has(&names(&mut app, "Marks and Bleeds"), &bleed); + set_field(&mut app, "bleed.useDocument", json!(true)); + has(&names(&mut app, "Marks and Bleeds"), &bleed); + has(&names(&mut app, "Advanced"), &["Subset fonts below:"]); +} diff --git a/crates/ui-egui/src/dialogs/tests_print.rs b/crates/ui-egui/src/dialogs/tests_print.rs index 00b45e0db7..f60131e1a8 100644 --- a/crates/ui-egui/src/dialogs/tests_print.rs +++ b/crates/ui-egui/src/dialogs/tests_print.rs @@ -532,3 +532,50 @@ fn a_spot_inks_icon_converts_it_to_process_and_back() { screen.run(&mut app, vec![click(keep)]); assert_eq!(dialog(&mut app).fields["output"]["inks"], json!([{"name": "Gold", "print": true, "convertToProcess": false}])); } + +/// The names screen readers give the text fields in `out`'s accessibility tree: a field's own +/// name, else the text of a label it is labeled by, else "". +pub(super) fn field_names(out: &egui::FullOutput) -> Vec { + use egui::accesskit::Role; + let nodes = &out.platform_output.accesskit_update.as_ref().expect("an accessibility tree").nodes; + // A label node carries its text as its value. + let text_of = |id| nodes.iter().find(|(n, _)| *n == id).and_then(|(_, n)| n.label().or(n.value())).map(str::to_string); + nodes + .iter() + .filter(|(_, n)| matches!(n.role(), Role::TextInput | Role::SpinButton)) + .map(|(_, n)| n.label().map(str::to_string).or_else(|| n.labelled_by().iter().find_map(|l| text_of(*l))).unwrap_or_default()) + .collect() +} + +/// Every number and length field of every section is named by its visible label, and the fields +/// of a row with several are told apart by theirs. +#[test] +fn every_number_and_length_field_is_named_by_its_label() { + let (mut app, _) = app(); + app.run("file.print", json!({})).unwrap(); + let mut screen = Screen::new(); + let mut names = |app: &mut VectorcraftApp, section: &str| { + set(app, "__section", json!(section)); + screen.run(app, vec![]); + let names = field_names(&screen.run(app, vec![])); + assert!(names.iter().all(|n| !n.trim().is_empty()), "{section}: {names:?}"); + names + }; + let has = |names: &[String], expected: &[&str]| { + for name in expected { + assert_eq!(names.iter().filter(|n| n == name).count(), 1, "{name} in {names:?}"); + } + }; + // A paper size shows its size in dimmed fields; Custom takes one. + let general = ["Copies:", "Range:", "Width:", "Height:", "Placement: X:", "Placement: Y:", "Scale: W:", "Scale: H:", "Overlap:", "Gutter:"]; + has(&names(&mut app, "General"), &general); + set(&mut app, "media", json!("custom")); + has(&names(&mut app, "General"), &general); + // The document's bleed shows in dimmed fields; without it the fields take the values. + let bleed = ["Offset:", "Top:", "Bottom:", "Left:", "Right:"]; + has(&names(&mut app, "Marks and Bleed"), &bleed); + super::save_pdf::set(dialog(&mut app), "bleed.useDocument", json!(false)); + has(&names(&mut app, "Marks and Bleed"), &bleed); + has(&names(&mut app, "Graphics"), &["Flatness:"]); + has(&names(&mut app, "Advanced"), &["Unprintable margin:"]); +} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3da663c191..4ea84bb12e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -803,6 +803,7 @@ since 2026-10-01. - **EPS Save with Use Artboards:** Save As › EPS Options show Use Artboards with All or Range, for a separate file per artboard ([saving in EPS](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/save-artwork-in-eps-format.html)), unchecked by default (the scripting reference's EPS save options list `saveMultipleArtboards` with a default of false, [scripting reference](https://web.archive.org/web/20160803105056/https://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015_3/Illustrator%20JavaScript%20Scripting%20Reference.pdf)). Unchecked, Save writes one file whose bounding box fits all the visible art, as Export does, without the artboards' background colors; when no art shows, the page is the first artboard in its color. An opened EPS saved back this way loses its page margins. Checked with two or more chosen artboards, the file at the path is the central file of the visible art and each artboard is also written to `_.eps` beside it. Checked with one chosen artboard, VectorCraft writes that artboard as the page of the file at the path alone (the behavior Save had since #4293). Evidence: `cmd::fileio::tests_artboard_fill::eps_save_draws_the_color_on_an_artboard_page`, `tests::save::eps_save_without_use_artboards_fits_the_box_to_art_past_the_artboard`, `tests::save::opened_eps_saves_to_its_own_file_around_its_art_or_on_its_page`, `tests::save::eps_save_with_use_artboards_writes_the_central_file_and_one_per_artboard`, `dialogs::save_options::tests::eps_save_as_shows_use_artboards_off_and_writes_the_art_or_the_artboard`. - **EPS Options custom flattener settings:** the help page describes flattening an EPS's transparency with a preset or with custom options, adjusted through Custom ([saving in EPS](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/save-artwork-in-eps-format.html)). EPS Options now has Custom… beside the flattener Preset. It opens Custom Transparency Flattener Options on the settings the export would use: the raster/vector balance, both resolutions, the text and stroke outline switches, Clip Complex Regions and Anti-alias Rasters. OK goes back to EPS Options with the preset shown as [Custom], the export flattens with those settings, and the next EPS Options start from them; choosing a preset drops them, and Cancel goes back to EPS Options unchanged. Preserve Alpha Transparency stays off, and overprints are kept only with Overprints set to Preserve. The [Custom] label, the remembering, the Cancel behavior, Anti-alias Rasters and the ranges (balance 0 to 100, resolutions 1 to 2400 ppi) are VectorCraft's own. Evidence: `dialogs::tests_eps::custom_flattener_options_start_from_the_preset_and_cancel_goes_back_unchanged`, `custom_flattener_options_are_exported_and_remembered_until_a_preset_is_chosen`, `bad_custom_flattener_options_keep_the_dialog_open`. - **Save PDF custom flattener settings:** the help page describes the Advanced section's flattener preset for PDF 1.3 saves of transparent art, with a Custom button for adjusting the flattener settings, and says neither is available at PDF 1.4 and later ([PDF options](https://helpx.adobe.com/illustrator/using/pdf-options.html)). Save PDF › Advanced now has Custom… beside Flattener preset, enabled for PDF 1.3, PDF/X-1a and PDF/X-3. It opens Custom Transparency Flattener Options on the settings the save would use: the raster/vector balance, both resolutions, the text and stroke outline switches and Anti-alias Rasters; Clip Complex Regions shows on, as the PDF 1.3 writer always clips, overprints are kept only with Overprint set to Preserve, and Preserve Alpha Transparency shows off, as PDF 1.3 rasters keep no alpha. OK goes back to Save PDF with the preset shown as [Custom] and the save flattens with those settings; settings equal to the preset's leave its name, choosing a preset drops them, and Cancel goes back unchanged. PDF presets keep the flattener preset but not these settings, and Save Preset… says so while they are set. `ui.savePdfDialog` keeps a `flattener` it is given. The [Custom] label, the Cancel behavior, Anti-alias Rasters, the editor's absence from the PDF preset editor and the ranges (balance 0 to 100, resolutions 1 to 2400 ppi) are VectorCraft's own. Evidence: `dialogs::save_pdf::tests::custom_is_enabled_where_the_save_flattens`, `custom_starts_from_the_preset_and_cancel_goes_back_unchanged`, `custom_options_are_written_until_a_preset_is_chosen`, `custom_options_equal_to_the_preset_leave_its_name`, `custom_shows_alpha_as_the_pdf_1_3_writer_drops_it`, `save_preset_says_it_leaves_the_custom_flattener_options_out`, `save_pdf_opens_with_the_flattener_options_given_and_refuses_bad_ones`. +- **Save PDF and Print field names for screen readers:** every number, length and range field in Save PDF and Print has a name in the accessibility tree. Screen readers name the image resolution fields by their group and the word before them ("Color images to", "Color images above"), the bleed fields by their side ("Top:"), Print's Width and Height fields by their own labels, the Placement and Scale fields by the row and their axis ("Placement: X:", "Scale: W:"), and the artboard range fields "Range:". Scores and estimates are unchanged. Evidence: `dialogs::save_pdf::tests::every_number_and_length_field_is_named_by_its_label`, `dialogs::tests_print::every_number_and_length_field_is_named_by_its_label`. - **Raster export backgrounds (#6125):** a raster export draws its background under the finished art, and blend modes read only the art below them, as on the canvas. An Outer Glow in Screen mode on the bare page shows in a PNG on white and in a JPEG. Flatten Transparency puts its white under the finished art the same way. Evidence: `tests::file::a_screen_outer_glow_is_in_raster_exports`, `tests::objectfx::a_screen_outer_glow_on_the_bare_page_shows_on_a_background`, `tests::knockout::page_knockout_and_isolated_blending`, `tests::knockout::no_blend_mode_reads_the_background`, `tests::cmykflatten::every_blend_mode_flattens_to_the_canvas_pixels_in_cmyk`.