PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Comments: font size for text boxes in Comment Properties (#1908) (#1984)
Valentin Klein75c9a9c27b33
diff --git a/ATTRIBUTION.toml b/ATTRIBUTION.tomlindex d09755298..7bb657250 100644--- a/ATTRIBUTION.toml+++ b/ATTRIBUTION.toml@@ -7,7 +7,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Greek UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "0c9691685fecfc582ae81c748bcbf645044722e3c233d4502cb49b5a98f93af9"+sha256 = "30b8a13b90b850f7d837d1a458df70fa08ae38b5aa0af9c197de620729089a88"# ATTRIBUTION.toml: one entry per asset (AGENTS.md §1). The source of truth for provenance and licences.# ATTRIBUTION.md is generated from this file: `cargo xtask assets --write`. Checked by `cargo xtask assets` (part of `xtask ci`).@@ -30,7 +30,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Simplified Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "219efe9f342aa269d4ecfef9617fa39064ea63ac7148231493068470f8257700"+sha256 = "bc71a9ceefbeb481e331e218578d4d65d220731da09cafc3ca9e32da792cb4fb"[[asset]]path = "crates/ui-egui/src/i18n/zh-hant.tsv"@@ -41,7 +41,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Traditional Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "e730271977b4d89e30f2d822e65f8894b832a1b2ba66f816828a106cc6b20e8e"+sha256 = "6d8e89cd5c2d2fe209867eff4dbc670a00927f5ce2a05ebb7b56d66b858e6b48"[[asset]]path = "crates/ui-egui/src/i18n/cs.tsv"@@ -52,7 +52,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Czech UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "a209f68c88cab1c19e095e9e12bc6f9251bbabc0a411d0e5aba7c1399c94159e"+sha256 = "12287718a0846e043253fbbbc3ac9d7a67ed838e66b1b55e47c343153b1bbc6d"[[asset]]path = "crates/ui-egui/src/i18n/pt-br.tsv"@@ -63,7 +63,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Brazilian Portuguese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "d174236d0bf87e2c212fa4c4c1b7cd2a2438150a13af0a2ca08194170d192b8d"+sha256 = "6397dc77f168f6db633c09424a60f6b1042218fc2625a030143e25e8e193e44a"[[asset]]path = "crates/ui-egui/src/i18n/es.tsv"@@ -74,7 +74,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Spanish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "b588396c7c4972709843ea3bfc42213780a11c92b83d52292926b6eb9ed52167"+sha256 = "cad58817e722d974ff38ce3e57419e87d332d082c2ecad11b040cfee05f2a5de"[[asset]]path = "crates/ui-egui/src/i18n/fr.tsv"@@ -85,7 +85,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "French UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "762a8220093ad1a51126f850e6c8692067a626f528e2cd88b40a1f04d9482c9a"+sha256 = "a5662ab337d49184e709ab6f5fbc30398c937ec3d8fdb835efc8076b7ea182b6"[[asset]]path = "crates/ui-egui/src/i18n/de.tsv"@@ -96,7 +96,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "German UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "61c4bdac7f60d924ec548c84d04b4c9ef137f27096f958f3584207b50c8e91d5"+sha256 = "e47428da655a1179d8809a0d96e1860ce12c0f05e179bc584c7dfb28a4c75f04"[[asset]]path = "crates/ui-egui/src/i18n/te.tsv"@@ -107,7 +107,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Telugu UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "91808c674033322c15fa4b40f9175551bcd66bdc02769a90df04c3fa33d710ef"+sha256 = "e5f95f946060eea5c5a85848cf465952278c782c6150c03517355da68150f867"[[asset]]path = "crates/ui-egui/src/i18n/it.tsv"@@ -118,7 +118,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Italian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "70ae72cd45e6084be65cda4adbfbc1fba31dc92ef46ece38064f4a21755d096b"+sha256 = "f42099446b10e95c7188c3a0551c96ce6c9c87f69f4a7cf93de65225ec16ba7c"[[asset]]path = "crates/ui-egui/src/i18n/pl.tsv"@@ -129,7 +129,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Polish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "94b507ad2d09e04339d4307ea44281c0bb27eb5f04f616c4e9e9bb69613fd5cb"+sha256 = "dce2fb816235f9a271348d1d2c9ddcdeb6e7c5a91b4deb52b3cfbed358b75718"[[asset]]path = "crates/ui-egui/src/i18n/ru.tsv"@@ -140,7 +140,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Russian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "b69396f3c0049eaf788fcd742d067857dacb0ae61fb84e22888373b647a62c1c"+sha256 = "6358f605742f4b8c351392df9ad3b634f3ab508ea09e11ddf76d617e809dd4c5"[[asset]]path = "crates/ui-egui/src/i18n/hu.tsv"@@ -151,7 +151,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Hungarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "778e2c93af6178fa9ec3544d10716174259a8587cf0912b0d5ab4c769b50a514"+sha256 = "7d4ab7edc9d0ddc9426a26a646293fba95c0bf5a0fd4717c127cd19cb2e2e584"[[asset]]path = "crates/ui-egui/src/i18n/bg.tsv"@@ -162,7 +162,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Bulgarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "1d8ef2cb8b2010178bf5036c4563dec00bfca8d5ef1ad436dacf6412567e74d7"+sha256 = "16bffa630c2bd94a226cf3246e367b51db14efe5e576b5106ba4742c8cca2fa6"[[asset]]path = "crates/ui-egui/src/i18n/kk.tsv"@@ -173,7 +173,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Kazakh UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "d722c9d6d0427b9f50119df0cde7b4f3341779bdfaa349460b68f02bc21ca5f8"+sha256 = "a4150b6b602849a54523c22faa552dcdf9a596afee55396fac4f32592f948487"[[asset]]path = "crates/ui-egui/src/i18n/ja.tsv"@@ -184,7 +184,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Japanese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "79033f5db7d2a5ab1aebaa6cadb77806d45d072fdf250bd2086974a77f4bf7ce"+sha256 = "8c4894897538c5f95d2e1c312e424b5fd0f427405512da604a64764d1120394e"[[asset]]path = "crates/ui-egui/src/i18n/uk.tsv"@@ -195,7 +195,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Ukrainian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "fe159f37f57f1d49e6a80b6b971f799a19a49b6feaf91d40424d0d5837e8bfb5"+sha256 = "1dde51fbb63fdbacf0b9d091cd191ee63b1e4ee322729577b45bc791b5807915"[[asset]]path = "crates/ui-egui/src/i18n/ar.tsv"@@ -206,7 +206,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Arabic UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "79332492b077695340b023c6e0b33523ae40f7a77f88eedc739cb8cff4c6b29e"+sha256 = "de5e9932aa69dcf8796ce90a21ca4496e0db884bb37755e5c7e9e23d4acd3e2e"[[asset]]path = "crates/ui-egui/src/i18n/tr.tsv"@@ -217,7 +217,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Turkish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "5eaa8ca29239cd92d64e343e5a2809a5e02239ccd06e7ac16774335328f01c80"+sha256 = "a3f6fb73c122ca2f52dabc6ae86d24e70afd97c7461f09ac20c66296863685c0"[[asset]]path = "crates/ui-egui/src/i18n/lt.tsv"@@ -228,7 +228,7 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Lithuanian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "122781df7711e41ce2462eea032133c449c5cafbdb528dc7fd096d7ff033e587"+sha256 = "661a2f8da7a3406d2dbed23e77030921be3f8e57ff91a769ee70d2ffdc560f41"[[asset]]@@ -3363,4 +3363,4 @@ licence = "MIT OR Apache-2.0"licence_file = "LICENSE-MIT"kind = "translation"usage = "Slovene UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"-sha256 = "c81dcea055935312c77aea40928748a95f179d85a0418968d2893a479a1272bd"+sha256 = "d6715789a67cfeeab549380ef49b7cb501b401b0ae6abb3f8f0ff182cae4e212"diff --git a/ROADMAP.md b/ROADMAP.mdindex 82c885fd9..f8ead1deb 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -163,6 +163,7 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md- **2026-10-13 (M4, #1910 Organize on the current page):** Opening Organize Pages from the toolbar, tool panel, command or `--organize` selects the page being read and scrolls its cell into view, replacing a stale grid selection that did not include it. One UI regression covers a middle page, the last page and reopening after an earlier selection. Estimates unchanged.- **2026-10-13 (M5, signature pad undo):** The Draw tab of Create signature/initials has an Undo button and Ctrl/Cmd+Z that take back the last stroke (#1963). Pad is UI-only, so no automation tool. Estimates unchanged.- **2026-10-13 (M2, raw crop and page-unit floor):** The renderer applies its existing one-point minimum in physical points for non-nearly-zero raw crop dimensions on scaled pages. Five synthetic regressions cover inspection, crop origins and rotations, reciprocal rounding and bounded raster controls. Existing UserUnit policy, nearly-zero fallback, feature statuses and estimates are unchanged.+- **2026-10-13 (M5, text box font size, #1908):** Comment Properties has a Font size control for text boxes, typewriter text and callouts (1-400 pt); it writes `/DA` and the rich-text strings, redraws the appearance and grows the box to fit. `comment_edit` takes `font_size`. Annot, tool and UI regressions. Estimates unchanged.- **2026-10-13 (M3, native-opening candidate):** Chosen tools survive preparation, conversion and password retries; startup intake waits for pending preparation. Regression tests cover completion, cancellation and document identity. Estimates unchanged.- **2026-10-13 (community, M3, #531 touchpad momentum):** On Wayland a two-finger swipe keeps gliding after the fingers lift and slows to a stop, measured from the gesture's last 0.1 s and decaying with a 0.35 s time constant through the #759 1:1 path. Any wheel input, click, key, zoom or edge ends it (fingers resting on the touchpad don't yet: the vendored winit binds no Wayland hold gestures); single-page paging, macOS (which sends its own momentum), the web, and Animation effects Off never glide. Unit tests for the physics and two headless view tests. Estimates unchanged.- **2026-10-13 (M3, native-open admission):** Later prepared replies stay queued while a modal or native picker owns the foreground. Picker completion, cancellation and abandonment wake retained opens. Regressions cover recipient ownership, exactly-once admission, source/history preservation and one-shot repaint requests. Estimates unchanged.diff --git a/crates/annot/src/lib.rs b/crates/annot/src/lib.rsindex 5621f4638..f4973aa02 100644--- a/crates/annot/src/lib.rs+++ b/crates/annot/src/lib.rs@@ -1946,6 +1946,47 @@ pub fn set_style(redraw_or_restore(doc, r, before)}+/// Change the font size of a text box, typewriter text or callout (`/DA` keeps its colour; the+/// rich-text strings follow) and redraw it. The box grows to hold the wrapped text at the new+/// size and never shrinks, so a box the user drew large stays large. Sizes are 1 to 400 pt.+pub fn set_font_size(doc: &mut Document, page: usize, index: usize, size: f64, meta: &Meta) -> Result<(), AnnotError> {+ let (_, r) = annot_ref(doc, page, index)?;+ unlocked(doc, r)?;+ let d = annot_dict(doc, r);+ if d.name(b"Subtype") != Some(b"FreeText") {+ return Err(AnnotError::Invalid("only text boxes, typewriter text and callouts have a font size".into()));+ }+ if !size.is_finite() || !(1.0..=400.0).contains(&size) {+ return Err(AnnotError::Invalid("font size must be 1\u{2013}400 pt".into()));+ }+ refuse_foreign_text(doc, &d)?;+ let before = d;+ doc.update_dict(r, |d| {+ let (col, _) = appearance::parse_da(d);+ d.set(b"DA".to_vec(), PdfString::literal(format!("{} {} {} rg /Helv {} Tf", n(col[0]), n(col[1]), n(col[2]), n(size)).into_bytes()));+ rich_text(d);+ touch(d, meta);+ })?;+ let text = text_value(doc, &annot_dict(doc, r), b"Contents").unwrap_or_default();+ let result = match fitted_box(doc, r, &text) {+ Some(fit) => {+ let cur = annot_dict(doc, r);+ let nums: Vec<f64> =+ cur.get(b"Rect").and_then(|o| o.as_array()).map(|a| a.iter().filter_map(|x| x.as_f64()).collect()).unwrap_or_default();+ // Keep the top and sides; only the bottom edge moves, and only downwards.+ match four(&nums).map(normalize) {+ Some(old) if !cur.contains(b"CL") => apply_text_box(doc, r, [fit[0], fit[1].min(old[1]), fit[2], fit[3]], meta, false),+ _ => apply_text_box(doc, r, fit, meta, false),+ }+ }+ None => redraw_or_restore(doc, r, before.clone()),+ };+ if result.is_err() {+ doc.set(r, Object::Dict(before));+ }+ result+}+/// Whether a comment of this subtype has an interior that can be filled (`/IC`: rectangles,/// ovals, polygons and clouds, §12.5.6.8–9).pub fn fillable(subtype: &str) -> bool {@@ -2180,6 +2221,8 @@ pub struct Props {pub fillable: bool,/// `/IC`, the interior colour (`None`: no fill).pub fill: Option<Rgb>,+ /// Text boxes, typewriter text and callouts: the `/DA` font size in points.+ pub font_size: Option<f64>,}/// The current properties of the comment at `(page, index)`.@@ -2205,6 +2248,7 @@ pub fn props(doc: &Document, page: usize, index: usize) -> Option<Props> {locked: annotation_flags(doc, d) & FLAG_LOCKED != 0,fillable: fillable(&subtype),fill: fill_of(d),+ font_size: (subtype == "FreeText").then(|| appearance::parse_da(d).1),subtype,endings: line_endings_of(d),})diff --git a/crates/annot/src/tests.rs b/crates/annot/src/tests.rsindex 2ae46a246..faed409ab 100644--- a/crates/annot/src/tests.rs+++ b/crates/annot/src/tests.rs@@ -1273,3 +1273,38 @@ fn cached_appearances_are_reused_while_annotations_are_unchanged() {assert!(!a.is_empty());assert_eq!(a, b, "the reused appearance is byte-identical");}++/// #1908: a text box's font size changes in `/DA` (colour kept), the rich text follows, the box+/// grows to hold the bigger text but never shrinks, and bad sizes and other subtypes are refused.+#[test]+fn text_box_font_size_changes_the_da_and_grows_the_box() {+ let mut doc = fixture();+ let t = add_annotation(&mut doc, &new(0, Shape::TextBox { rect: [100.0, 680.0, 220.0, 692.0], font_size: 12.0 }), &meta("t")).unwrap();+ set_style(&mut doc, 0, t, Some([1.0, 0.0, 0.0]), None, None, None, &meta("")).unwrap();+ set_contents(&mut doc, 0, t, "one two three four five six seven eight nine ten eleven twelve", &meta("")).unwrap();+ let height = |doc: &Document| {+ let rect: Vec<f64> = list(doc, 0)[t].get(b"Rect").unwrap().as_array().unwrap().iter().map(|x| x.as_f64().unwrap()).collect();+ rect[3] - rect[1]+ };+ let before = height(&doc);+ set_font_size(&mut doc, 0, t, 24.0, &meta("")).unwrap();+ let doc = reopen(&doc);+ let d = &list(&doc, 0)[t];+ assert_eq!(text(d, b"DA"), "1 0 0 rg /Helv 24 Tf");+ assert!(text(d, b"DS").contains("24pt") && text(d, b"RC").contains("font-size:24pt"));+ assert_eq!(props(&doc, 0, t).unwrap().font_size, Some(24.0));+ assert!(height(&doc) > before, "the box grows");+ let mut doc = doc;+ let grown = height(&doc);+ set_font_size(&mut doc, 0, t, 6.0, &meta("")).unwrap();+ assert!(height(&doc) >= grown, "the box never shrinks");+ for bad in [0.0, 0.5, 401.0, f64::NAN, f64::INFINITY] {+ assert!(matches!(set_font_size(&mut doc, 0, t, bad, &meta("")), Err(AnnotError::Invalid(_))), "{bad}");+ }+ assert_eq!(props(&doc, 0, t).unwrap().font_size, Some(6.0));+ let note = add_annotation(&mut doc, &new(0, Shape::Note { at: [50.0, 50.0], icon: NoteIcon::Note }), &meta("t"));+ if let Ok(i) = note {+ assert!(set_font_size(&mut doc, 0, i, 12.0, &meta("")).is_err());+ assert_eq!(props(&doc, 0, i).unwrap().font_size, None);+ }+}diff --git a/crates/automation/src/comments.rs b/crates/automation/src/comments.rsindex 10036d7e6..302688f72 100644--- a/crates/automation/src/comments.rs+++ b/crates/automation/src/comments.rs@@ -619,6 +619,12 @@ impl Automation {let fill = if f.eq_ignore_ascii_case("none") { None } else { Some(parse_color(f)?) };edits.push(Edit::FillAnnotation { page, index, fill });}+ if let Some(size) = a.opt_num("font_size")? {+ if !(1.0..=400.0).contains(&size) {+ return Err(ToolError::InvalidArgs("font_size must be 1–400 pt".into()));+ }+ edits.push(Edit::FontSizeAnnotation { page, index, size });+ }if let Some(r) = a.nums::<4>("rect")? {edits.push(Edit::ResizeAnnotation { page, index, rect: rect_to_user(&info, r) });}@@ -627,7 +633,7 @@ impl Automation {edits.push(Edit::MoveAnnotation { page, index, dx: d[0] - o[0], dy: d[1] - o[1] });}if edits.is_empty() {- return Err(ToolError::InvalidArgs("nothing to change: pass contents, color, opacity, width, rect or move".into()));+ return Err(ToolError::InvalidArgs("nothing to change: pass contents, color, opacity, width, fill, font_size, rect or move".into()));}let edit = if edits.len() == 1 { edits.remove(0) } else { Edit::Batch { label: "Edit comment".into(), edits } };self.apply(a, edit)diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rsindex 26744483a..909fe47cf 100644--- a/crates/automation/src/tools.rs+++ b/crates/automation/src/tools.rs@@ -778,13 +778,14 @@ pub fn tools() -> Vec<ToolDef> {json!({ "doc": doc(), "sort": { "type": "string", "enum": ["page", "author", "date", "type"] }, "out": save_out, "open": open }),&["doc"],)),- t("comment_edit", "Edit a comment", "Change a comment's text, colour, opacity, line width, fill (rectangle/oval/polygon; \"none\" removes it), rectangle (rectangle/oval/text box/stamp) or position (`move` [dx, dy] in points). Stamps keep their original appearance when resized. One undo step.").with(schema(+ t("comment_edit", "Edit a comment", "Change a comment's text, colour, opacity, line width, font size (text box/typewriter/callout), fill (rectangle/oval/polygon; \"none\" removes it), rectangle (rectangle/oval/text box/stamp) or position (`move` [dx, dy] in points). Stamps keep their original appearance when resized. One undo step.").with(schema(comment_ref(json!({"contents": { "type": "string" },"color": color(),"opacity": { "type": "number", "minimum": 0, "maximum": 1 },"width": { "type": "number", "minimum": 0 },"fill": { "type": "string", "description": "Interior colour of a rectangle, oval or polygon: #RRGGBB, a colour name, or \"none\" for no fill." },+ "font_size": { "type": "number", "minimum": 1, "maximum": 400, "description": "Font size in points of a text box, typewriter text or callout; the box grows to hold the text." },"rect": { "type": "array", "items": { "type": "number" }, "minItems": 4, "maxItems": 4 },"move": point(),})),diff --git a/crates/automation/tests/automation.rs b/crates/automation/tests/automation.rsindex 9f4ca1b40..09a7c9ade 100644--- a/crates/automation/tests/automation.rs+++ b/crates/automation/tests/automation.rs@@ -3952,6 +3952,33 @@ fn text_the_standard_fonts_cannot_draw_is_never_silent_through_tools() {assert!(!text.contains("?? OK"), "{text}");}+/// #1908: `comment_edit font_size` resizes the text of a text box, in one undo step, and refuses+/// sizes outside 1-400 pt and comments without text.+#[test]+fn text_box_font_size_through_the_tool() {+ let dir = workdir("fontsize");+ let mut a = auto(&dir);+ let doc = ok(&mut a, "doc_open", json!({ "path": "a.pdf" }))["doc"].as_u64().unwrap();+ ok(&mut a, "comment_add", json!({ "doc": doc, "page": 1, "type": "textbox", "rect": [20, 40, 200, 80], "contents": "Hello" }));+ ok(&mut a, "comment_add", json!({ "doc": doc, "page": 1, "type": "rectangle", "rect": [20, 120, 80, 160] }));+ ok(&mut a, "comment_edit", json!({ "doc": doc, "page": 1, "index": 1, "font_size": 30 }));+ for bad in [0, 401] {+ assert!(matches!(a.call("comment_edit", &json!({ "doc": doc, "page": 1, "index": 1, "font_size": bad })), Err(ToolError::InvalidArgs(_))));+ }+ assert!(a.call("comment_edit", &json!({ "doc": doc, "page": 1, "index": 2, "font_size": 12 })).is_err());+ ok(&mut a, "doc_save", json!({ "doc": doc, "path": "sized.pdf" }));+ let saved = pdfcraft_cos::Document::open(std::sync::Arc::new(std::fs::read(dir.join("sized.pdf")).unwrap())).unwrap();+ let sizes: Vec<String> = saved+ .object_numbers()+ .iter()+ .filter_map(|n| saved.try_get(*n).ok())+ .filter_map(|o| o.as_dict().and_then(|d| d.get(b"DA")?.as_string().map(|s| String::from_utf8_lossy(&s.bytes).into_owned())))+ .collect();+ assert_eq!(sizes.len(), 1, "{sizes:?}");+ assert!(sizes[0].ends_with("/Helv 30 Tf"), "{sizes:?}");+ assert_eq!(ok(&mut a, "edit_undo", json!({ "doc": doc }))["undone"], "Change comment properties");+}+#[test]fn line_endings_through_the_tool() {let dir = workdir("endings");diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rsindex 831d24e58..4141064c9 100644--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@ -230,6 +230,7 @@ fn scope_of(edit: &Edit) -> Scope {| Edit::ResizeAnnotation { .. }| Edit::StyleAnnotation { .. }| Edit::FillAnnotation { .. }+ | Edit::FontSizeAnnotation { .. }| Edit::SetAnnotationInfo { .. } => Scope::Comments,Edit::SetFieldValue { .. } | Edit::ResetForm { .. } | Edit::SetFieldImage { .. } | Edit::ApplyScriptChanges { .. } => Scope::Form,// Page content, resources and added content/marks only: the page tree, annotations,@@ -1301,6 +1302,12 @@ pub enum Edit {index: usize,fill: Option<Rgb>,},+ /// Change the font size (pt) of a text box, typewriter text or callout.+ FontSizeAnnotation {+ page: usize,+ index: usize,+ size: f64,+ },/// Comment properties ▸ General / note icon.SetAnnotationInfo {page: usize,@@ -1833,7 +1840,9 @@ impl Edit {Edit::LockAnnotation { .. } => Label::of("Unlock comment"),Edit::MoveAnnotation { .. } => Label::of("Move comment"),Edit::ResizeAnnotation { .. } => Label::of("Resize comment"),- Edit::StyleAnnotation { .. } | Edit::FillAnnotation { .. } | Edit::SetAnnotationInfo { .. } => Label::of("Change comment properties"),+ Edit::StyleAnnotation { .. } | Edit::FillAnnotation { .. } | Edit::FontSizeAnnotation { .. } | Edit::SetAnnotationInfo { .. } => {+ Label::of("Change comment properties")+ }Edit::SetFieldValue { name, .. } => Label::with("Fill in {name}", name.as_str()),Edit::SetFieldImage { name, .. } => Label::with("Set the image of {name}", name.as_str()),Edit::ResetForm { .. } => Label::of("Clear form"),@@ -1984,6 +1993,7 @@ fn check_permission(edit: &Edit, p: &pdfcraft_cos::Permissions) -> Result<(), Ed| Edit::ResizeAnnotation { .. }| Edit::StyleAnnotation { .. }| Edit::FillAnnotation { .. }+ | Edit::FontSizeAnnotation { .. }| Edit::SetAnnotationInfo { .. }| Edit::SetMeasurementScale { .. } => {if p.annotate() {@@ -2244,6 +2254,7 @@ fn run_edit(doc: &mut pdfcraft_cos::Document, edit: &Edit, cx: &mut EditCtx) ->pdfcraft_annot::set_style(doc, *page, *index, *color, *opacity, *width, endings.as_deref(), &cx.meta())?;}Edit::FillAnnotation { page, index, fill } => pdfcraft_annot::set_fill(doc, *page, *index, *fill, &cx.meta())?,+ Edit::FontSizeAnnotation { page, index, size } => pdfcraft_annot::set_font_size(doc, *page, *index, *size, &cx.meta())?,Edit::SetAnnotationInfo { page, index, author, subject, icon } => {pdfcraft_annot::set_info(doc, *page, *index, author.as_deref(), subject.as_deref(), *icon, &cx.meta())?;}diff --git a/crates/ui-egui/src/comment_props.rs b/crates/ui-egui/src/comment_props.rsindex 48d3571e1..093aa592e 100644--- a/crates/ui-egui/src/comment_props.rs+++ b/crates/ui-egui/src/comment_props.rs@@ -134,6 +134,11 @@ pub fn edits(d: &PropsDraft) -> Vec<Edit> {if e.restylable && e.fillable && e.fill != o.fill {out.push(Edit::FillAnnotation { page: d.page, index: d.index, fill: e.fill });}+ if e.restylable+ && let Some(size) = e.font_size.filter(|s| Some(*s) != o.font_size)+ {+ out.push(Edit::FontSizeAnnotation { page: d.page, index: d.index, size });+ }let author = (e.author != o.author).then(|| e.author.clone());let subject = (e.subject != o.subject).then(|| e.subject.clone());let icon = (e.icon != o.icon).then_some(e.icon).flatten();@@ -207,6 +212,11 @@ pub(crate) fn body(ui: &mut egui::Ui, app: &mut PdfCraftApp, t: &Tokens) -> (boo}ui.end_row();}+ if let Some(size) = e.font_size.as_mut() {+ ui.label(tl!("Font size"));+ ui.add(egui::DragValue::new(size).range(1.0..=400.0).speed(0.5).suffix(" pt"));+ ui.end_row();+ }ui.label(tl!("Opacity"));let mut pct = e.opacity * 100.0;if ui.add(egui::Slider::new(&mut pct, 0.0..=100.0).suffix("%")).changed() {diff --git a/crates/ui-egui/src/editing.rs b/crates/ui-egui/src/editing.rsindex 19cd043bf..4d2e09168 100644--- a/crates/ui-egui/src/editing.rs+++ b/crates/ui-egui/src/editing.rs@@ -879,6 +879,7 @@ fn comment_page(edit: &Edit) -> Option<usize> {| Edit::ResizeAnnotation { page, .. }| Edit::StyleAnnotation { page, .. }| Edit::FillAnnotation { page, .. }+ | Edit::FontSizeAnnotation { page, .. }| Edit::SetAnnotationInfo { page, .. } => Some(*page),_ => None,}diff --git a/crates/ui-egui/src/i18n/ar.tsv b/crates/ui-egui/src/i18n/ar.tsvindex 50e270722..1b271e4d8 100644--- a/crates/ui-egui/src/i18n/ar.tsv+++ b/crates/ui-egui/src/i18n/ar.tsv@@ -1152,6 +1152,7 @@Redaction code: رمز الحجب:Font: الخط:Font size: حجم الخط:+ Font size حجم الخطAuto-size text to fit redaction region تحجيم النص تلقائيًا ليلائم منطقة الحجبFont colour: لون الخط:Repeat overlay text تكرار نص التراكبdiff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsvindex 850fc6269..d4911e343 100644--- a/crates/ui-egui/src/i18n/bg.tsv+++ b/crates/ui-egui/src/i18n/bg.tsv@@ -834,6 +834,7 @@Redaction code: Код за заличаване:Font: Шрифт:Font size: Размер на шрифта:+ Font size Размер на шрифтаAuto-size text to fit redaction region Автоматично оразмеряване на текста според областта на заличаванеFont colour: Цвят на шрифта:Repeat overlay text Повтаряй текста върху заличаванетоdiff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 41de4a2cf..edad18660 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -1220,6 +1220,7 @@ key Space MezerníkRedaction code: Kód začernění:Font: Písmo:Font size: Velikost písma:+ Font size Velikost písmaAuto-size text to fit redaction region Automaticky přizpůsobit velikost textu oblasti začerněníFont colour: Barva písma:Repeat overlay text Opakovat překryvný textdiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 4a36d792b..4729053d9 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -1138,6 +1138,7 @@Redaction code: Schwärzungscode:Font: Schrift:Font size: Schriftgröße:+ Font size SchriftgrößeAuto-size text to fit redaction region Textgröße automatisch an Schwärzungsbereich anpassenFont colour: Schriftfarbe:Repeat overlay text Überlagerungstext wiederholendiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex 1565b771a..7bcd1fc90 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -735,6 +735,7 @@Redaction code: Κωδικός απόκρυψης:Font: Γραμματοσειρά:Font size: Μέγεθος γραμματοσειράς:+ Font size Μέγεθος γραμματοσειράςAuto-size text to fit redaction region Αυτόματη προσαρμογή μεγέθους κειμένου στην περιοχή απόκρυψηςFont colour: Χρώμα γραμματοσειράς:Repeat overlay text Επανάληψη κειμένου επικάλυψηςdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 89ff594f0..8467a0013 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -1147,6 +1147,7 @@Redaction code: Código de censura:Font: Fuente:Font size: Tamaño de fuente:+ Font size Tamaño de fuenteAuto-size text to fit redaction region Ajustar automáticamente el tamaño del texto a la zona censuradaFont colour: Color de fuente:Repeat overlay text Repetir el texto superpuestodiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 233f6bc2f..5e4a76732 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -1133,6 +1133,7 @@Redaction code: Code de biffure :Font: Police :Font size: Corps :+ Font size CorpsAuto-size text to fit redaction region Ajuster automatiquement le corps du texte à la zone de biffureFont colour: Couleur de police :Repeat overlay text Répéter le texte en superpositiondiff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsvindex a2f065a9c..1312608c5 100644--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@ -1123,6 +1123,7 @@Redaction code: Kitakarási kód:Font: Betűtípus:Font size: Betűméret:+ Font size BetűméretAuto-size text to fit redaction region A szöveg automatikus méretezése a kitakarási területhezFont colour: Betű színe:Repeat overlay text Fedőszöveg ismétlésediff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex e5f161c70..9f7b92a94 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -1149,6 +1149,7 @@Redaction code: Codice di oscuramento:Font: Carattere:Font size: Dimensione carattere:+ Font size Dimensione carattereAuto-size text to fit redaction region Adatta automaticamente il testo all'area oscurataFont colour: Colore carattere:Repeat overlay text Ripeti testo sovrappostodiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 0fe685803..386d024a3 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -1153,6 +1153,7 @@Redaction code: 墨消しコード:Font: フォント:Font size: フォントサイズ:+ Font size フォントサイズAuto-size text to fit redaction region 墨消し領域に合わせて文字サイズを自動調整Font colour: 文字色:Repeat overlay text オーバーレイテキストを繰り返すdiff --git a/crates/ui-egui/src/i18n/kk.tsv b/crates/ui-egui/src/i18n/kk.tsvindex ad19a1aeb..c546b8320 100644--- a/crates/ui-egui/src/i18n/kk.tsv+++ b/crates/ui-egui/src/i18n/kk.tsv@@ -1097,6 +1097,7 @@Custom text: Жеке мәтін:Font: Қаріп:Font size: Қаріп өлшемі:+ Font size Қаріп өлшеміAuto-size text to fit redaction region Мәтін өлшемін жасыру аймағына автоматты бейімдеуFont colour: Қаріп түсі:Repeat overlay text Үстеме мәтінді қайталауdiff --git a/crates/ui-egui/src/i18n/lt.tsv b/crates/ui-egui/src/i18n/lt.tsvindex f0835d906..df454fbed 100644--- a/crates/ui-egui/src/i18n/lt.tsv+++ b/crates/ui-egui/src/i18n/lt.tsv@@ -594,6 +594,7 @@Font colour: Šrifto spalva:Font size 0 uses automatic sizing. Šrifto dydis 0 reiškia, kad dydis parenkamas automatiškai.Font size: Šrifto dydis:+ Font size Šrifto dydisFont: Šriftas:Font: Helvetica Šriftas: „Helvetica“Fonts Šriftaidiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 817188131..bc929c202 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -1136,6 +1136,7 @@Custom text: Własny tekst:Font: Czcionka:Font size: Rozmiar czcionki:+ Font size Rozmiar czcionkiAuto-size text to fit redaction region Dopasuj rozmiar tekstu do utajnianego obszaruFont colour: Kolor czcionki:Repeat overlay text Powtarzaj tekst nakładanydiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex c82232e1a..242e4ecc9 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -780,6 +780,7 @@Redaction code: Código de ocultação:Font: Fonte:Font size: Tamanho da fonte:+ Font size Tamanho da fonteAuto-size text to fit redaction region Ajustar tamanho do texto automaticamente à região de ocultaçãoFont colour: Cor da fonte:Repeat overlay text Repetir texto de sobreposiçãodiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 328ec8379..d91061635 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -1153,6 +1153,7 @@Redaction code: Код сокрытия:Font: Шрифт:Font size: Размер шрифта:+ Font size Размер шрифтаAuto-size text to fit redaction region Автоподбор размера текста по области сокрытияFont colour: Цвет шрифта:Repeat overlay text Повторять текст поверхdiff --git a/crates/ui-egui/src/i18n/sl.tsv b/crates/ui-egui/src/i18n/sl.tsvindex fd2b70da2..d787292c0 100644--- a/crates/ui-egui/src/i18n/sl.tsv+++ b/crates/ui-egui/src/i18n/sl.tsv@@ -842,6 +842,7 @@Font Size: Velikost pisave:Font colour: Barva pisave:Font size: Velikost pisave:+ Font size Velikost pisaveFont: Pisava:Font: Helvetica Pisava: HelveticaFonts Pisavediff --git a/crates/ui-egui/src/i18n/te.tsv b/crates/ui-egui/src/i18n/te.tsvindex 3fe502bfe..92c43cdbf 100644--- a/crates/ui-egui/src/i18n/te.tsv+++ b/crates/ui-egui/src/i18n/te.tsv@@ -1123,6 +1123,7 @@ comment menu Edit సవరించుRedaction code: రెడాక్షన్ కోడ్:Font: ఫాంట్:Font size: ఫాంట్ పరిమాణం:+ Font size ఫాంట్ పరిమాణంAuto-size text to fit redaction region రెడాక్షన్ ప్రాంతానికి సరిపోయేలా టెక్స్ట్ పరిమాణాన్ని స్వయంచాలకంగా మార్చుFont colour: ఫాంట్ రంగు:Repeat overlay text ఓవర్లే టెక్స్ట్ను పునరావృతం చేయిdiff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsvindex ce68ea61e..c353976de 100644--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@ -1110,6 +1110,7 @@Redaction code: Karartma kodu:Font: Yazı tipi:Font size: Yazı tipi boyutu:+ Font size Yazı tipi boyutuAuto-size text to fit redaction region Metni karartma bölgesine sığacak şekilde otomatik boyutlandırFont colour: Yazı tipi rengi:Repeat overlay text Üst metni yinelediff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex bc93471f7..fc47b826a 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -1150,6 +1150,7 @@Redaction code: Код вилучення:Font: Шрифт:Font size: Розмір шрифту:+ Font size Розмір шрифтуAuto-size text to fit redaction region Автоматично добирати розмір тексту до області вилученняFont colour: Колір шрифту:Repeat overlay text Повторювати накладений текстdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex 9068f1663..0be259299 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -841,6 +841,7 @@Redaction code: 密文代码:Font: 字体:Font size: 字号:+ Font size 字号Auto-size text to fit redaction region 自动调整文本大小以适应密文区域Font colour: 字体颜色:Repeat overlay text 重复覆盖文本diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex c45d99f6e..56145d364 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -785,6 +785,8 @@Redaction code: 遮蔽代碼:Font: 字型:Font size: 字型大小:+ Font size: 字號:+ Font size 字號Auto-size text to fit redaction region 自動調整文字大小以適應遮蔽內容區域Font colour: 字型顏色:Repeat overlay text 重複覆蓋文字diff --git a/crates/ui-egui/tests/comments.rs b/crates/ui-egui/tests/comments.rsindex 18539535e..503ae7a04 100644--- a/crates/ui-egui/tests/comments.rs+++ b/crates/ui-egui/tests/comments.rs@@ -1181,3 +1181,34 @@ fn a_closed_comments_panel_stays_closed_when_picking_comment_tools() {h.run_steps(2);assert_eq!(h.state().right, Some(RightPanel::Comments));}++/// #1908: Comment properties of a text box has a Font size control; changing it redraws the box+/// with the new /DA size as one undo step, and shapes without text have no such control.+#[test]+fn text_box_properties_change_the_font_size() {+ use pdfcraft_engine::{Edit, NewAnnotation, Shape};+ let mut h = harness(|_| {});+ let tb = NewAnnotation {+ page: 0,+ shape: Shape::TextBox { rect: [40.0, 600.0, 240.0, 640.0], font_size: 12.0 },+ style: Default::default(),+ contents: "Hello".into(),+ author: "Ada".into(),+ };+ h.state_mut().apply_edit(Edit::AddAnnotation(tb));+ h.run_steps(2);+ h.state_mut().open_comment_props(0, 0);+ h.run_steps(2);+ h.get_by_label("Font size");+ {+ let d = h.state_mut().comment_props.as_mut().expect("open");+ assert_eq!(d.original.font_size, Some(12.0));+ d.edited.font_size = Some(30.0);+ }+ h.get_by_label("OK").click();+ h.run_steps(3);+ let s = h.state();+ let doc = s.session.get(s.views[0].id).unwrap();+ assert_eq!(doc.comment_props(0, 0).unwrap().font_size, Some(30.0));+ assert_eq!(doc.can_undo(), Some("Change comment properties"));+}diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.tomlindex 8eb5176fb..c177114e1 100644--- a/parity/acrobat-features.toml+++ b/parity/acrobat-features.toml@@ -3860,8 +3860,8 @@ milestone = "M5"status = "shipped"commands = ["comment.list"]tools = ["comment_edit"]-evidence = ["crates/ui-egui/tests/comments.rs::comment_properties_change_appearance_and_author", "crates/annot/src/tests.rs::author_subject_and_note_icon_change", "crates/ui-egui/tests/comments.rs::shapes_take_a_fill_colour_from_the_quick_bar_and_properties"]-notes = "Appearance (colour, fill colour for rectangles/ovals/polygons, opacity, thickness, note icon), General (author, subject), Review History"+evidence = ["crates/ui-egui/tests/comments.rs::comment_properties_change_appearance_and_author", "crates/annot/src/tests.rs::author_subject_and_note_icon_change", "crates/ui-egui/tests/comments.rs::shapes_take_a_fill_colour_from_the_quick_bar_and_properties", "crates/ui-egui/tests/comments.rs::text_box_properties_change_the_font_size", "crates/annot/src/tests.rs::text_box_font_size_changes_the_da_and_grows_the_box", "crates/automation/tests/automation.rs::text_box_font_size_through_the_tool"]+notes = "Appearance (colour, fill colour for rectangles/ovals/polygons, opacity, thickness, note icon, font size of text boxes, typewriter text and callouts: 1-400 pt, written to /DA and the rich-text strings, the box grows to fit and never shrinks; comment_edit font_size), General (author, subject), Review History. Still missing: font family, bold/italic, alignment and per-run formatting of text boxes; the quick bar has no font size for new text boxes (they start at 12 pt, callouts 10 pt)"[[feature]]id = "comment.properties-bar"