From 24e528abcf9296cc147df6cf4116930423f7ff00 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 07:40:47 -0800 Subject: [PATCH] Type: Area Type Options First Baseline offers Em Box Height First Baseline gains Em Box Height (`text.areaOptions {firstBaseline: "emBoxHeight"}`, and the Area Type Options dropdown). The top of the first line's ideographic em box, the largest on a line of several sizes, touches the top of the type area inside the inset, in each row/column cell and in vertical type. It is the em box that Top-to-Top leading uses. Min is the least distance, as with the other kinds. Native files save it as `emBoxHeight`. The .ai reader reads editing-data kind 5 as Em Box Height and the writer writes it back; Legacy (6) and unknown kinds keep today's fallback. The dropdown's Ascent and x Height labels, and Fixed in Gujarati, get the catalog rows nine languages were missing, beside the new label in every catalog. Help page: https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/add-margins-to-text-and-adjust-the-first-baseline.html --- crates/doc/src/text/para_style.rs | 2 + crates/doc/src/text/tests.rs | 14 +++++++ crates/engine/src/cmd/typecmd.rs | 2 +- crates/engine/src/cmd/typecmd/area_tests.rs | 38 ++++++++++++++++++ crates/eps/src/ai_editing/tests.rs | 31 +++++++++++++++ crates/eps/src/ai_editing/writer/texts.rs | 1 + crates/eps/src/import/ate.rs | 12 +++--- crates/text/src/layout/breaking.rs | 1 + crates/text/src/tests/typo.rs | 44 ++++++++++++++++++++- crates/text/src/tests/vertical.rs | 26 ++++++++++++ crates/text/src/tests/warichu.rs | 2 +- crates/ui-egui/src/dialogs/command.rs | 39 +++++++++++++++++- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 3 ++ crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/gu.tsv | 4 ++ crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 3 ++ crates/ui-egui/src/i18n/ja.tsv | 3 ++ crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 3 ++ crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tests.rs | 15 +++++++ crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 3 ++ crates/ui-egui/src/i18n/vi.tsv | 3 ++ crates/ui-egui/src/i18n/zh-hans.tsv | 3 ++ crates/ui-egui/src/i18n/zh-hant.tsv | 3 ++ docs/mcp.md | 17 ++++++++ docs/target-app-parity.md | 1 + 43 files changed, 281 insertions(+), 11 deletions(-) diff --git a/crates/doc/src/text/para_style.rs b/crates/doc/src/text/para_style.rs index 62c6b8dd33..17325d071c 100644 --- a/crates/doc/src/text/para_style.rs +++ b/crates/doc/src/text/para_style.rs @@ -631,6 +631,8 @@ pub enum FirstBaseline { XHeight, /// The first line's leading. Leading, + /// The top of the first line's ideographic em box touches the frame top. + EmBoxHeight, /// Exactly `first_baseline_min` below the top. Fixed, } diff --git a/crates/doc/src/text/tests.rs b/crates/doc/src/text/tests.rs index a5230d5d86..2a7237eda5 100644 --- a/crates/doc/src/text/tests.rs +++ b/crates/doc/src/text/tests.rs @@ -554,6 +554,20 @@ fn text_flow_is_saved_only_when_by_rows() { assert!(serde_json::from_value::(serde_json::json!({"flow": "diagonal"})).is_err()); } +/// First Baseline Em Box Height saves as `emBoxHeight` with its minimum and reads back; files from +/// before it read their own first baseline as they did, Ascent when they have none. +#[test] +fn em_box_height_first_baseline_is_saved_and_read_back() { + let set = AreaOptions { first_baseline: FirstBaseline::EmBoxHeight, first_baseline_min: 9.0, ..AreaOptions::default() }; + let saved = serde_json::to_value(&set).unwrap(); + assert_eq!((saved["firstBaseline"].as_str(), saved["firstBaselineMin"].as_f64()), (Some("emBoxHeight"), Some(9.0))); + assert_eq!(serde_json::from_value::(saved).unwrap(), set); + let old = serde_json::json!({"firstBaseline": "leading", "firstBaselineMin": 3.0}); + assert_eq!(serde_json::from_value::(old).unwrap().first_baseline, FirstBaseline::Leading); + assert_eq!(serde_json::from_value::(serde_json::json!({})).unwrap().first_baseline, FirstBaseline::Ascent); + assert!(serde_json::from_value::(serde_json::json!({"firstBaseline": "emBox"})).is_err()); +} + /// 120 × 40 area type at (40, 40), its text drawn at twice its size. fn area_type() -> TextObject { let mut t = TextObject::point(Point::ZERO, "Some text", CharStyle::default()); diff --git a/crates/engine/src/cmd/typecmd.rs b/crates/engine/src/cmd/typecmd.rs index c239cf040e..f50a2c7364 100644 --- a/crates/engine/src/cmd/typecmd.rs +++ b/crates/engine/src/cmd/typecmd.rs @@ -95,7 +95,7 @@ pub fn specs() -> Vec { "Area Type Options…", ["Type"], None, - "{ids?|id?, width?: pt, height?: pt, rows?, columns?, gutter?: pt (between rows and columns), rowGutter?: pt|null (between rows when it differs from gutter, which is then between columns; gutter given alone sets both; the reply gives the rows' gutter either way), inset?: pt, firstBaseline?: ascent|capHeight|xHeight|leading|fixed, firstBaselineMin?: pt, verticalAlign?: top|center|bottom|justify, flow?: columns|rows (Text Flow: down each column's rows, then across, the default; or across each row's columns, then down), fit?: none|autoHeight|shrinkText|block, fitMinPercent?: 10..100, wordGap?: % 0..1000, lineGap?: pt -1296..1296, …the keys of its own reply (it can be passed back; the values it only reports are ignored)} set the selected area type's options (each frame takes the options given over its own and keeps the rest; fit resolves against each frame's own; options that change nothing add no undo step); width and height size the type area from its top-left corner, along the type's own axes, and the text reflows at its size (with fit autoHeight, Auto Size, the frame's height follows the text after every edit and height is ignored; setting the height by hand turns it off); fit shrinkText scales overflowing text down (size, leading, baseline shift) by the largest factor down to fitMinPercent % (default 50) that makes it fit; fit block is Dynamic Text's Block, as type.dynamicText sets it (in place of Auto Size and Shrink Text to Fit; threaded frames are refused; another fit turns it off, keeping the sizes it wrote), and wordGap and lineGap set its gaps (kept while Block is off; out of range is an error) (none given: query) → the first object's options, plus wordGap and lineGap, overflow (the text doesn't fit its frame) and fitScale (Shrink Text's factor, 1 unshrunk)", + "{ids?|id?, width?: pt, height?: pt, rows?, columns?, gutter?: pt (between rows and columns), rowGutter?: pt|null (between rows when it differs from gutter, which is then between columns; gutter given alone sets both; the reply gives the rows' gutter either way), inset?: pt, firstBaseline?: ascent|capHeight|xHeight|leading|emBoxHeight|fixed (emBoxHeight: the top of the first line's ideographic em box, the largest on the line, touches the top of the type area inside the inset), firstBaselineMin?: pt (the least distance from that top to the first baseline; with fixed, the distance), verticalAlign?: top|center|bottom|justify, flow?: columns|rows (Text Flow: down each column's rows, then across, the default; or across each row's columns, then down), fit?: none|autoHeight|shrinkText|block, fitMinPercent?: 10..100, wordGap?: % 0..1000, lineGap?: pt -1296..1296, …the keys of its own reply (it can be passed back; the values it only reports are ignored)} set the selected area type's options (each frame takes the options given over its own and keeps the rest; fit resolves against each frame's own; options that change nothing add no undo step); width and height size the type area from its top-left corner, along the type's own axes, and the text reflows at its size (with fit autoHeight, Auto Size, the frame's height follows the text after every edit and height is ignored; setting the height by hand turns it off); fit shrinkText scales overflowing text down (size, leading, baseline shift) by the largest factor down to fitMinPercent % (default 50) that makes it fit; fit block is Dynamic Text's Block, as type.dynamicText sets it (in place of Auto Size and Shrink Text to Fit; threaded frames are refused; another fit turns it off, keeping the sizes it wrote), and wordGap and lineGap set its gaps (kept while Block is off; out of range is an error) (none given: query) → the first object's options, plus wordGap and lineGap, overflow (the text doesn't fit its frame) and fitScale (Shrink Text's factor, 1 unshrunk)", has_selection, area_options ), diff --git a/crates/engine/src/cmd/typecmd/area_tests.rs b/crates/engine/src/cmd/typecmd/area_tests.rs index aa6b75032d..a8aecac1d1 100644 --- a/crates/engine/src/cmd/typecmd/area_tests.rs +++ b/crates/engine/src/cmd/typecmd/area_tests.rs @@ -2613,6 +2613,44 @@ fn area_options_columns_change_layout() { assert!(s.execute("text.areaOptions", &json!({"firstBaseline": "nope"})).is_err()); } +/// First Baseline Em Box Height: set, reported and undone like the other kinds, with Min as the +/// least distance; setting it again adds no undo step, and the refusal of an unknown kind lists it. +#[test] +fn area_options_set_the_em_box_height_first_baseline() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let id = s.execute("text.create", &json!({"x": 10, "y": 10, "text": "word ".repeat(20), "area": {"width": 300, "height": 120}})).unwrap()["id"] + .as_u64() + .unwrap(); + s.execute("select.set", &json!({"ids": [id]})).unwrap(); + let first = |s: &Session| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind { + NodeKind::Text(t) => vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t).lines[0].first_baseline, + _ => panic!("area type"), + }; + let ascent = first(&s); + let r = s.execute("text.areaOptions", &json!({"firstBaseline": "emBoxHeight"})).unwrap(); + assert_eq!((r["firstBaseline"].as_str(), r["firstBaselineMin"].as_f64()), (Some("emBoxHeight"), Some(0.0))); + let em_box = first(&s); + assert!(em_box > 0.0 && (em_box - ascent).abs() > 0.1, "{em_box} {ascent}"); + let steps = s.doc().unwrap().history.undo.len(); + s.execute("text.areaOptions", &json!({"firstBaseline": "emBoxHeight"})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), steps, "no change, no undo step"); + // A Min nearer the top keeps the em box; one further down is the distance. + s.execute("text.areaOptions", &json!({"firstBaselineMin": em_box / 2.0})).unwrap(); + assert!((first(&s) - em_box).abs() < 1e-9); + let r = s.execute("text.areaOptions", &json!({"firstBaselineMin": 30})).unwrap(); + assert_eq!((r["firstBaseline"].as_str(), r["firstBaselineMin"].as_f64()), (Some("emBoxHeight"), Some(30.0))); + assert!((first(&s) - 30.0).abs() < 1e-9); + for _ in 0..3 { + s.execute("edit.undo", &json!({})).unwrap(); + } + assert_eq!(s.execute("text.areaOptions", &json!({})).unwrap()["firstBaseline"], "ascent"); + assert!((first(&s) - ascent).abs() < 1e-9); + let e = s.execute("text.areaOptions", &json!({"firstBaseline": "emBox"})).unwrap_err().to_string(); + assert!(e.contains("emBoxHeight"), "{e}"); + assert_eq!(s.execute("text.areaOptions", &json!({})).unwrap()["firstBaseline"], "ascent"); +} + /// `rowGutter` sets a gutter between rows of its own, the reply passes it back, and a gutter /// given alone is the rows' and the columns' again. #[test] diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index f8e39a4048..476a6b0356 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -5397,6 +5397,37 @@ fn an_empty_last_frame_keeps_the_style_of_the_last_paragraph() { assert_eq!(justify, [Justify::Left, Justify::Right]); } +/// Each First Baseline kind the text document holds, Em Box Height included, comes back with its +/// minimum, without a warning. +#[test] +fn every_first_baseline_kind_comes_back_with_its_minimum() { + use vectorcraft_doc::{FirstBaseline, TextKind, TextObject}; + for (kind, min) in [ + (FirstBaseline::Ascent, 0.0), + (FirstBaseline::CapHeight, 6.0), + (FirstBaseline::XHeight, 0.0), + (FirstBaseline::Leading, 4.0), + (FirstBaseline::EmBoxHeight, 0.0), + (FirstBaseline::EmBoxHeight, 18.5), + (FirstBaseline::Fixed, 40.0), + ] { + let mut d = Document::new(300.0, 200.0); + let layer = d.layers[0].id; + let mut area = TextObject::point(vectorcraft_geom::Point::ZERO, "Area", style(12.0, Color::BLACK)); + area.kind = TextKind::Area { frame: shapes::rectangle(Rect::new(20.0, 20.0, 140.0, 160.0)) }; + area.xf = Affine::IDENTITY; + area.area.first_baseline = kind; + area.area.first_baseline_min = min; + let n = text_node(&mut d, area); + d.insert(Some(layer), usize::MAX, n).unwrap(); + let warnings = export_ai_editing(&d, &opts()).unwrap().warnings; + assert!(warnings.is_empty(), "{kind:?}: {warnings:?}"); + let back = read_back(&d); + let NodeKind::Text(t) = &back.layers[0].children().unwrap()[0].kind else { panic!("type") }; + assert_eq!((t.area.first_baseline, t.area.first_baseline_min), (kind, min), "{kind:?}"); + } +} + /// A minimum first baseline with the Ascent first baseline is reported, and kept with the others. /// An end bracket of an open path that the reader would read as none is reported, and one further /// from the path's end comes back. diff --git a/crates/eps/src/ai_editing/writer/texts.rs b/crates/eps/src/ai_editing/writer/texts.rs index 506d13d9fc..d3c2c2e493 100644 --- a/crates/eps/src/ai_editing/writer/texts.rs +++ b/crates/eps/src/ai_editing/writer/texts.rs @@ -1002,6 +1002,7 @@ impl TextDoc { FirstBaseline::CapHeight => Some(2), FirstBaseline::Leading => Some(3), FirstBaseline::XHeight => Some(4), + FirstBaseline::EmBoxHeight => Some(5), }; if let Some(k) = kind { data.push((10, dict(vec![(0, V::Int(k)), (1, real(o.first_baseline_min / scale))]))); diff --git a/crates/eps/src/import/ate.rs b/crates/eps/src/import/ate.rs index 0c73b65092..160310dd4e 100644 --- a/crates/eps/src/import/ate.rs +++ b/crates/eps/src/import/ate.rs @@ -345,8 +345,9 @@ impl AreaFrame { 2 => F::CapHeight, 3 => F::Leading, 4 => F::XHeight, - // Em Box Height (5) and Legacy (6) have no first baseline of their own here: the - // first baseline stays as it was. + 5 => F::EmBoxHeight, + // Legacy (6) has no first baseline of its own here: the first baseline stays as it + // was. _ => return None, }; Some((kind, length(b.get("1")).unwrap_or(0.0))) @@ -2936,12 +2937,12 @@ mod tests { #[test] fn area_frame_first_baseline_kinds_and_minimum_are_read() { use vectorcraft_doc::FirstBaseline as F; - for (code, kind) in [(0, F::Fixed), (2, F::CapHeight), (3, F::Leading), (4, F::XHeight)] { + for (code, kind) in [(0, F::Fixed), (2, F::CapHeight), (3, F::Leading), (4, F::XHeight), (5, F::EmBoxHeight)] { let a = area_of(vec![area_frame(&format!("/10 << /0 {code} /1 30 >>"))], 0, 2.0); assert_eq!((a.first_baseline, a.first_baseline_min), (kind, 60.0), "code {code}"); } // A kind without its own first baseline here, or none known, leaves Ascent. - for code in ["1", "5", "6", "7", "-1", "2.5", "(x)"] { + for code in ["1", "6", "7", "-1", "2.5", "(x)"] { let a = area_of(vec![area_frame(&format!("/10 << /0 {code} /1 30 >>"))], 0, 1.0); assert_eq!((a.first_baseline, a.first_baseline_min), (F::Ascent, 0.0), "code {code}"); } @@ -2972,9 +2973,10 @@ mod tests { }; let placed = |options: &str| placed_in(&[options]); assert_eq!(placed("/10 << /0 2 /1 0 >>"), (false, vectorcraft_doc::FirstBaseline::CapHeight)); + assert_eq!(placed("/10 << /0 5 /1 0 >>"), (false, vectorcraft_doc::FirstBaseline::EmBoxHeight)); // Without one (Ascent), or with one that isn't read, the line goes where the file has it. assert_eq!(placed(""), (true, vectorcraft_doc::FirstBaseline::Fixed)); - assert_eq!(placed("/10 << /0 5 /1 0 >>"), (true, vectorcraft_doc::FirstBaseline::Fixed)); + assert_eq!(placed("/10 << /0 6 /1 0 >>"), (true, vectorcraft_doc::FirstBaseline::Fixed)); // Another frame of the thread keeping one doesn't count for the first. assert_eq!(placed_in(&["", "/10 << /0 2 /1 0 >>"]), (true, vectorcraft_doc::FirstBaseline::Fixed)); } diff --git a/crates/text/src/layout/breaking.rs b/crates/text/src/layout/breaking.rs index ef62fa2bcc..375bc343a2 100644 --- a/crates/text/src/layout/breaking.rs +++ b/crates/text/src/layout/breaking.rs @@ -47,6 +47,7 @@ impl Metrics { FirstBaseline::CapHeight => self.cap, FirstBaseline::XHeight => self.xh, FirstBaseline::Leading => self.lead, + FirstBaseline::EmBoxHeight => self.top, FirstBaseline::Fixed => 0.0, }; v.max(min) diff --git a/crates/text/src/tests/typo.rs b/crates/text/src/tests/typo.rs index 351c698451..be0b36124f 100644 --- a/crates/text/src/tests/typo.rs +++ b/crates/text/src/tests/typo.rs @@ -1329,6 +1329,40 @@ fn inset_and_first_baseline_options() { assert!(cap.lines[0].baseline < base.lines[0].baseline && cap.lines[0].baseline > 5.0); } +/// First Baseline Em Box Height: the top of the first line's ideographic em box (the one leading +/// measured from em box top to top uses) touches the top of the type area inside the inset. On a +/// line of several sizes the largest em box decides, and a Min further down sets the baseline. +#[test] +fn em_box_height_puts_the_first_lines_em_box_top_at_the_type_area_top() { + let frame = Rect::new(0.0, 0.0, 300.0, 300.0); + let em_box = |t: &TextObject, inset: f64, min: f64| { + let opts = LayoutOptions { first_baseline: FirstBaseline::EmBoxHeight, first_baseline_min: min, inset, ..Default::default() }; + layout_with(db(), t, &opts).lines[0].baseline + }; + // The em box top the EmBoxTop leading model sets a frame's first line at. + let em_top = |t: &TextObject| { + let mut t = t.clone(); + t.para.leading_model = vectorcraft_doc::LeadingModel::EmBoxTop; + layout(db(), &t).lines[0].baseline + }; + let t = area(COPY, style(12.0), frame, Justify::Left); + let top = em_top(&t); + assert!(top > 5.0 && top < 12.0, "{top}"); + let ascent = layout(db(), &t).lines[0].baseline; + assert!((top - ascent).abs() > 0.1, "not the ascent: {top} {ascent}"); + assert!((em_box(&t, 0.0, 0.0) - top).abs() < 1e-9); + assert!((em_box(&t, 10.0, 0.0) - (10.0 + top)).abs() < 1e-9, "measured from the inset"); + // A Min nearer the top than the em box changes nothing; one further down is the baseline. + assert!((em_box(&t, 10.0, top / 2.0) - (10.0 + top)).abs() < 1e-9); + assert!((em_box(&t, 10.0, 30.0) - 40.0).abs() < 1e-9); + // 10 pt and 20 pt on the first line: the 20 pt em box top is at the top. + let mut mixed = area("small Large", style(10.0), frame, Justify::Left); + mixed.runs = vec![run("small ", 10.0), run("Large", 20.0)]; + let large = area("Large", style(20.0), frame, Justify::Left); + assert!((em_box(&mixed, 0.0, 0.0) - em_box(&large, 0.0, 0.0)).abs() < 1e-9); + assert!((em_box(&large, 0.0, 0.0) - 2.0 * top * 10.0 / 12.0).abs() < 1e-6); +} + /// `LineInfo::first_baseline`: each line that starts a column has its baseline that far below the /// column's top inside the inset, for every first baseline option, with and without a minimum and /// an inset, in both leading models, and for lines of several sizes (each line in one size). @@ -1343,8 +1377,14 @@ fn lines_starting_a_column_sit_at_their_first_baseline() { let text: String = runs.iter().map(|r| r.text.as_str()).collect(); let mut other_sizes = 0; for model in [vectorcraft_doc::LeadingModel::RomanBaseline, vectorcraft_doc::LeadingModel::EmBoxTop] { - for first_baseline in [FirstBaseline::Ascent, FirstBaseline::CapHeight, FirstBaseline::XHeight, FirstBaseline::Leading, FirstBaseline::Fixed] - { + for first_baseline in [ + FirstBaseline::Ascent, + FirstBaseline::CapHeight, + FirstBaseline::XHeight, + FirstBaseline::Leading, + FirstBaseline::EmBoxHeight, + FirstBaseline::Fixed, + ] { for (first_baseline_min, inset) in [(0.0, 0.0), (18.0, 6.0)] { for height in [100.0, 120.0, 140.0] { let mut t = area(&text, style(12.0), Rect::new(0.0, 0.0, 420.0, height), Justify::Left); diff --git a/crates/text/src/tests/vertical.rs b/crates/text/src/tests/vertical.rs index dd12804e91..40c8076b2d 100644 --- a/crates/text/src/tests/vertical.rs +++ b/crates/text/src/tests/vertical.rs @@ -142,6 +142,32 @@ fn fit_first_line_widens_a_vertical_frame_from_its_right_edge() { assert_eq!(layout(FontDb::global(), &t).lines.len(), 1); } +/// First Baseline Em Box Height in vertical area type: the first column's em box edge touches the +/// frame's right edge inside the inset, as far in as leading measured from em box top to top sets +/// it. +#[test] +fn em_box_height_sets_a_vertical_frames_first_column_at_its_em_box() { + use vectorcraft_doc::{FirstBaseline, LeadingModel}; + let first = |fb: FirstBaseline, model: LeadingModel| { + let mut t = vertical("§§"); + t.kind = TextKind::Area { frame: PathData::from_bezpath(&Rect::new(0.0, 0.0, 100.0, 105.0).to_path(0.1)) }; + t.area.first_baseline = fb; + t.area.inset = 5.0; + t.para.leading_model = model; + let l = layout(FontDb::global(), &t); + (l.lines[0].baseline, l.lines[0].first_baseline) + }; + let (baseline, distance) = first(FirstBaseline::EmBoxHeight, LeadingModel::RomanBaseline); + let (em_top, _) = first(FirstBaseline::Ascent, LeadingModel::EmBoxTop); + let (ascent, ascent_distance) = first(FirstBaseline::Ascent, LeadingModel::RomanBaseline); + assert!((baseline - em_top).abs() < 1e-9, "{baseline} {em_top}"); + // Measured from the edge inside the inset, where a Fixed first baseline of 0 sits. + let (edge, _) = first(FirstBaseline::Fixed, LeadingModel::RomanBaseline); + assert!((baseline - distance - edge).abs() < 1e-9, "{baseline} {distance} {edge}"); + assert!((ascent - ascent_distance - edge).abs() < 1e-9, "{ascent} {ascent_distance} {edge}"); + assert!((baseline - ascent).abs() > 0.1, "not the ascent: {baseline} {ascent}"); +} + /// `baselines`: one per line that holds characters, along it for horizontal type and down the /// column's centre line for vertical type (where point type's anchor is); none on a path. #[test] diff --git a/crates/text/src/tests/warichu.rs b/crates/text/src/tests/warichu.rs index cbefb86bb5..7434e43db2 100644 --- a/crates/text/src/tests/warichu.rs +++ b/crates/text/src/tests/warichu.rs @@ -231,7 +231,7 @@ fn a_warichu_line_keeps_the_auto_leading_of_its_own_size() { #[test] fn the_first_baseline_measures_a_block_at_its_own_size() { use vectorcraft_doc::FirstBaseline; - for first in [FirstBaseline::Ascent, FirstBaseline::CapHeight, FirstBaseline::XHeight, FirstBaseline::Leading] { + for first in [FirstBaseline::Ascent, FirstBaseline::CapHeight, FirstBaseline::XHeight, FirstBaseline::Leading, FirstBaseline::EmBoxHeight] { let baseline = |inside: CharStyle| { let mut t = area("", style(20.0), Rect::new(0.0, 0.0, 300.0, 300.0), Justify::Left); t.area.first_baseline = first; diff --git a/crates/ui-egui/src/dialogs/command.rs b/crates/ui-egui/src/dialogs/command.rs index f5215092e8..bd0484c4d1 100644 --- a/crates/ui-egui/src/dialogs/command.rs +++ b/crates/ui-egui/src/dialogs/command.rs @@ -208,8 +208,14 @@ const PATH_ALIGN: form::Choices = &[("Ascender", "ascender"), ("Descender", "des const AREA_FIT: form::Choices = &[("None", "none"), ("Auto Size", "autoHeight"), ("Shrink Text to Fit", "shrinkText"), ("Block", "block")]; /// Area Type Options › First Baseline. -const FIRST_BASELINE: form::Choices = - &[("Ascent", "ascent"), ("Cap Height", "capHeight"), ("x Height", "xHeight"), ("Leading", "leading"), ("Fixed", "fixed")]; +const FIRST_BASELINE: form::Choices = &[ + ("Ascent", "ascent"), + ("Cap Height", "capHeight"), + ("x Height", "xHeight"), + ("Leading", "leading"), + ("Em Box Height", "emBoxHeight"), + ("Fixed", "fixed"), +]; /// Area Type Options › Align (vertical alignment of the lines in each row/column). const VERTICAL_ALIGN: form::Choices = &[("Top", "top"), ("Center", "center"), ("Bottom", "bottom"), ("Justify", "justify")]; @@ -271,6 +277,35 @@ mod tests { assert_eq!(t.area.vertical_align, VerticalAlign::Center); } + /// Area Type Options › First Baseline offers Em Box Height: OK sets it with its Min, and the + /// dialog opens again with it chosen. + #[test] + fn area_type_options_dialog_sets_the_em_box_height_first_baseline() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 400})).unwrap(); + let id = app.run("text.create", json!({"x": 20, "y": 20, "text": "Hello", "area": {"width": 200, "height": 200}})).unwrap()["id"] + .as_u64() + .unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + // The labels `i18n::tests::first_baseline_choices_are_in_complete_catalogs` checks. + let labels: Vec<&str> = choices("text.areaOptions", "firstBaseline").unwrap().iter().map(|(l, _)| *l).collect(); + assert_eq!(labels, ["Ascent", "Cap Height", "x Height", "Leading", "Em Box Height", "Fixed"]); + crate::menus::invoke(&mut app, "text.areaOptions", json!({})); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("firstBaseline"), "ascent"); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::dialogs::show(&mut app, ui.ctx())); + out.textures_delta.clear(); + let fields = &mut app.ui.dialog.as_mut().unwrap().fields; + fields.insert("firstBaseline".into(), json!("emBoxHeight")); + fields.insert("firstBaselineMin".into(), json!(4.0)); + crate::dialogs::confirm(&mut app).unwrap(); + let NodeKind::Text(t) = &app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().kind else { panic!("text") }; + assert_eq!((t.area.first_baseline, t.area.first_baseline_min), (vectorcraft_doc::FirstBaseline::EmBoxHeight, 4.0)); + crate::menus::invoke(&mut app, "text.areaOptions", json!({})); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("firstBaseline"), "emBoxHeight"); + } + /// Area Type Options shows the gutter between rows beside the gutter, and OK sets a gutter /// between rows of its own. #[test] diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 71e443a399..d739d4989a 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -5756,6 +5756,7 @@ lighting Light Светлина of от sRGB IEC61966-2.1 sRGB IEC61966-2.1 x Height Височина на x + Em Box Height Височина на квадратната касетка ▾ Default Actions ▾ Действия по подразбиране ⚠ {chord} was already used by {names} — it has been removed there. Внимание: Комбинацията {chord} вече се използва от {names} — премахната е там. @id file.close file.close diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 883d6dd387..d65970cbfe 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -5703,6 +5703,7 @@ imageTrace Outline Obris Ascent Uspon Cap Height Visina velikih slova x Height Visina malog slova x + Em Box Height Visina em okvira Justify Poravnaj obostrano First Baseline Prva osnovna linija Vertical Align Okomito poravnanje diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index a8a63cbf55..ea2d9c4868 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -5322,6 +5322,7 @@ digits Malayalam Malaiàlam Write Layers Escriu les capes Writes, moves or deletes files Escriu, mou o suprimeix fitxers x Height Alçada de la x + Em Box Height Alçada de la caixa em X11 (XWayland) X11 (XWayland) X11 (XWayland) When a Pen Is Attached X11 (XWayland) quan hi ha un llapis connectat X: X: diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 569b1347ec..d302279e32 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -6026,6 +6026,7 @@ liquify-list-end {0}, {1} {0} a {1} Ascent Výška nad účařím Cap Height Výška verzálek x Height Výška x + Em Box Height Výška čtverčíku Justify Do bloku First Baseline První účaří Vertical Align Svislé zarovnání diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 4578e4efc1..7448ae0314 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -8097,6 +8097,7 @@ imageTrace Outline Kontur Ascent Overhøjde Cap Height Versalhøjde x Height x-højde + Em Box Height Em-felthøjde Justify Justér First Baseline Første basislinje Vertical Align Lodret justering diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index c943c89dd2..f551b9a339 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5366,6 +5366,9 @@ liquify-list-end {0}, {1} {0} und {1} Cap Height Versalhöhe x-Height x-Höhe ICF Box ICF-Rahmen + Ascent Oberlänge + x Height x-Höhe + Em Box Height Gevierthöhe Show Sample Muster einblenden Hide Sample Muster ausblenden Max Ascent/Descent Max. Höhe/Tiefe diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 906640aa0a..e6a38c3f8b 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5941,6 +5941,7 @@ digits Malayalam Μαλαγιάλαμ [VectorCraft Default] [Προεπιλογή VectorCraft] of από x Height Ύψος x + Em Box Height Ύψος τετραγώνου em ▾ Default Actions ▾ Προεπιλεγμένες ενέργειες ⚠ {chord} was already used by {names} — it has been removed there. Προσοχή: το {chord} χρησιμοποιούνταν ήδη από {names} — αφαιρέθηκε από εκεί. @msg give corners of the path: anchors between two straight sides ορίστε τις γωνίες της διαδρομής: σημεία αγκύρωσης μεταξύ δύο ευθύγραμμων πλευρών diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 9239c93a73..574c1c50d8 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5964,6 +5964,7 @@ effect Regular Regular Ascent Ascendente Cap Height Altura de mayúsculas x Height Altura de la x + Em Box Height Altura del cuadro eme Justify Justificar First Baseline Primera línea de base Vertical Align Alineación vertical diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 423703e5c1..4c674feafc 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5942,6 +5942,7 @@ liquify-list-end {0}, {1} {0} ja {1} Ascent Nousu Cap Height Versaalikorkeus x Height x-korkeus + Em Box Height Em-laatikon korkeus Justify Tasaa molemmat reunat First Baseline Ensimmäinen perusviiva Vertical Align Pystytasaus diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 1cff1c8ad0..7b55bccb02 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -6237,6 +6237,7 @@ lighting Light Lumière of sur sRGB IEC61966-2.1 sRGB IEC61966-2.1 x Height Hauteur d’x + Em Box Height Hauteur du cadratin ▾ Default Actions ▾ Scripts par défaut ⚠ {chord} was already used by {names} — it has been removed there. Attention : {chord} était déjà utilisé par {names} ; il en a été retiré. @id file.close Fermer diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 4eed343e3d..e6e32ac6ac 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -4352,6 +4352,10 @@ tile {number} ટાઇલ {number} to થી x-Height x-ઊંચાઈ + Ascent એસેન્ટ + x Height x ઊંચાઈ + Fixed નિશ્ચિત + Em Box Height Em બૉક્સ ઊંચાઈ {count} of {total} artboards {total} માંથી {count} આર્ટબોર્ડ {effect} is already applied {effect} પહેલેથી લાગુ છે {file}, line {line} {file}, લાઇન {line} diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index de33cdbd92..25f4a34397 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -5738,6 +5738,7 @@ antiAlias Sharp शार्प Write Layers लेयर लिखें Writes, moves or deletes files फ़ाइलों को राइट्स, मूव या डिलीट करता है x Height x ऊँचाई + Em Box Height एम बॉक्स ऊँचाई X Position X स्थिति x-height x-ऊँचाई x-Height x-ऊँचाई diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index f869e7d07b..d13751bd22 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4943,6 +4943,7 @@ mark-style Japanese Japán Wrinkle Tool Gyűrés Write Layers Rétegek írása x Height x-magasság + Em Box Height Kvirtmező magassága X11 (XWayland) When a Pen Is Attached X11 (XWayland), ha toll csatlakozik If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Ha a grafikus tábla tolla nem rajzol, válassz egy X11 (XWayland) beállítást. X11 (XWayland) X11 (XWayland) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index c5f865e69b..ac89a615bc 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -5369,6 +5369,7 @@ imageTrace Outline Kontur Ascent Ascent Cap Height Tinggi kapital x Height Tinggi x + Em Box Height Tinggi Em Box Justify Ratakan First Baseline Baseline pertama Vertical Align Perataan vertikal diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 08cefdbed7..04f9889508 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1045,6 +1045,9 @@ font-technology Variable Variabili Cap Height Altezza maiuscole x-Height Altezza x ICF Box Riquadro ICF + Ascent Ascendente + x Height Altezza x + Em Box Height Altezza riquadro em Show Sample Mostra campione Hide Sample Nascondi campione Max Ascent/Descent Altezza/profondità max diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 59c7628f40..c6757d1b02 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -49,6 +49,9 @@ font-technology Variable バリアブル Cap Height キャップハイト x-Height x ハイト ICF Box 平均字面 + Ascent アセント + x Height x ハイト + Em Box Height 仮想ボディの高さ Show Sample サンプルを表示 Hide Sample サンプルを隠す Max Ascent/Descent 最大アセント/ディセント diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 9393433cdb..d6a613507c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -7359,6 +7359,7 @@ font-technology Variable ცვლადი Ascent ზედა გამონაშვერი Cap Height მთავრული ასოს სიმაღლე x Height x-სიმაღლე + Em Box Height Em-ბლოკის სიმაღლე Justify ორმხრივი სწორება First Baseline პირველი საბაზისო ხაზი Vertical Align ვერტიკალური სწორება diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 49d5e10dc1..1635c51fbb 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -43,6 +43,9 @@ font-technology Variable 가변 Cap Height 대문자 높이 x-Height x 높이 ICF Box ICF 박스 + Ascent 어센트 + x Height x 높이 + Em Box Height 엠 박스 높이 Show Sample 샘플 표시 Hide Sample 샘플 숨기기 Max Ascent/Descent 최대 어센트/디센트 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index f071ebd0e2..05a9d1b6ef 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -7817,6 +7817,7 @@ imageTrace Outline Contour Ascent Stijghoogte Cap Height Kaphoogte x Height x-hoogte + Em Box Height Em-vakhoogte Justify Uitvullen First Baseline Eerste basislijn Vertical Align Verticaal uitlijnen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 2477c73abd..873104f5fc 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5874,6 +5874,7 @@ liquify-list-end {0}, {1} {0} i {1} Ascent Wydłużenie górne Cap Height Wysokość wersalików x Height Wysokość x + Em Box Height Wysokość ramki firetowej Justify Justuj First Baseline Pierwsza linia bazowa Vertical Align Wyrównanie pionowe diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 333351b9af..9be13009ce 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -5953,6 +5953,7 @@ effect Regular Regular Ascent Ascensão Cap Height Altura das Maiúsculas x Height Altura do x + Em Box Height Altura da Caixa Eme Justify Justificar First Baseline Primeira Linha de Base Vertical Align Alinhamento Vertical diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ae33aa0d55..e32f6022e2 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -6995,6 +6995,7 @@ axis Y Axis Ось Y [Press Quality] [Типографское качество] of из x Height Высота строчных + Em Box Height Высота кегельной площадки ▾ Default Actions ▾ Стандартные действия ⚠ {chord} was already used by {names} — it has been removed there. ⚠ {chord} уже было назначено: {names}; там оно удалено. @plural {n} shortcut is assigned more than once|{n} shortcuts are assigned more than once {n} сочетание клавиш назначено несколько раз|{n} сочетания клавиш назначены несколько раз|{n} сочетаний клавиш назначены несколько раз diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 1bd4fd0692..542e9222ec 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -6158,6 +6158,7 @@ lighting Light Ljus of av sRGB IEC61966-2.1 sRGB IEC61966-2.1 x Height x-höjd + Em Box Height Em-rutans höjd ▾ Default Actions ▾ Standardåtgärder ⚠ {chord} was already used by {names} — it has been removed there. Obs! {chord} användes redan av {names} – det har tagits bort där. @id file.close Stäng diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 0daefad24a..c465bb5328 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -434,6 +434,21 @@ fn font_height_reference_labels_are_in_complete_catalogs() { } } +/// Area Type Options › First Baseline's choices (the dropdown reads them in the "effect" context, +/// falling back to the plain row). +#[test] +fn first_baseline_choices_are_in_complete_catalogs() { + let mut missing = vec![]; + for lang in LANGUAGES.iter().filter(|lang| lang.complete_menus) { + for label in ["Ascent", "Cap Height", "x Height", "Leading", "Em Box Height", "Fixed"] { + if lang.catalog().plain(label).is_none() && lang.catalog().contextual("effect", label).is_none() { + missing.push(format!("{} {label}", lang.code)); + } + } + } + assert!(missing.is_empty(), "{missing:?}"); +} + /// The Objects on Path Options section's Detach button, its undo step and the message for a /// Detach with no object chosen. #[test] diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index a2a38c679a..b4beca188a 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -6014,6 +6014,7 @@ lighting Light Işık of arasında sRGB IEC61966-2.1 sRGB IEC61966-2.1 x Height x Yükseklik + Em Box Height Em Kutusu Yüksekliği ▾ Default Actions ▾ Varsayılan Eylemler ⚠ {chord} was already used by {names} — it has been removed there. ⚠ {chord} zaten {names} tarafından kullanılmıştı — oradan kaldırıldı. @id file.close Kapat diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 17c673885d..9692df3189 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -1039,6 +1039,9 @@ font-technology Variable Варіативні Cap Height Висота великих літер x-Height Висота малих літер ICF Box Рамка ICF + Ascent Підйом + x Height Висота малих літер + Em Box Height Висота кегельного майданчика Show Sample Показати зразок Hide Sample Приховати зразок Max Ascent/Descent Макс. висота/глибина diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index da89525314..08315ad0aa 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -2014,6 +2014,9 @@ digits Hindi Hindi Cap Height Chiều cao chữ hoa x-Height Chiều cao chữ x ICF Box Ô ICF + Ascent Độ cao nét trên + x Height Chiều cao chữ x + Em Box Height Chiều cao ô em Show Sample Hiện mẫu Hide Sample Ẩn mẫu Max Ascent/Descent Độ cao/sâu tối đa diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 5f612cb0d4..a24077a4ac 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -976,6 +976,9 @@ antiAlias Sharp 锐利 Cap Height 大写字母高度 x-Height x 字高 ICF Box ICF 框 + Ascent 上缘 + x Height x 字高 + Em Box Height 全角字框高度 Show Sample 显示样本 Hide Sample 隐藏样本 Max Ascent/Descent 最大上升/下降 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e0b5a13ee2..cbfa7bbb62 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1007,6 +1007,9 @@ font-technology Variable 可變 Cap Height 大寫字母高度 x-Height x 字高 ICF Box ICF 框 + Ascent 上緣 + x Height x 字高 + Em Box Height 全形字框高度 Show Sample 顯示樣本 Hide Sample 隱藏樣本 Max Ascent/Descent 最大上升/下降 diff --git a/docs/mcp.md b/docs/mcp.md index c7aa202d3f..5fbc7b9d5c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9365,6 +9365,23 @@ Native files save it only when it is `rows`, so files from before it open by col {"name":"run_command","arguments":{"command":"text.areaOptions","params":{"rows":2,"columns":3,"flow":"rows"}}} ``` +### First baseline + +`text.areaOptions {firstBaseline: ascent|capHeight|xHeight|leading|emBoxHeight|fixed, firstBaselineMin?: pt}` (Area +Type Options › First Baseline and Min) sets how far below the top of the type area, inside the inset, the first line +of each row/column cell sits. `emBoxHeight` (Em Box Height) puts the top of the line's ideographic em box at that +top; on a line of several sizes the largest em box is used, and vertical type measures it from the frame's right +edge. The em box is the one leading measured from em box top to top uses: an ideograph's cell in the font's +vertical metrics, or 0.88 em above the baseline when the font has none (VectorCraft's own rule). With every kind but +`fixed`, `firstBaselineMin` is the least distance from the top to the first baseline; with `fixed` it is the +distance. Each threaded frame keeps its own setting. Native files and `.ai` files save `emBoxHeight` and open it again; other values are refused. The help +page describes the option: +https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/add-margins-to-text-and-adjust-the-first-baseline.html + +```json +{"name":"run_command","arguments":{"command":"text.areaOptions","params":{"firstBaseline":"emBoxHeight","firstBaselineMin":6}}} +``` + ## Fitting area type: Auto Size, Shrink Text to Fit, overflow `text.areaOptions` (and `text.create`'s `area`, `text.createInPath` in area mode) take a `fit`: diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..1be6cfce83 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1468,6 +1468,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur For Auto Size area type in columns, the bisection for the frame's height runs on the lines of the one-column layout, and its result is checked with at most two layouts of the columns. When the text wraps around objects or does not fit the one-column layout, or when the check fails, the columns are laid out at every step of the bisection, as before. Typing at the start of a story of 50,000 characters in 2 columns took 1,670 ms a keystroke and now takes 292 ms (release build, `auto_height_in_columns_typing_timing`). Exports to PDF, EPS, SVG, EMF, WMF and the raster formats warn about the area type and type on a path that they draw without the text that doesn't fit, and give their ids, as Print and Print Preview do. On a shaped area type frame, Inset Spacing keeps text that far from the frame's edge, holes included, measured from the edge itself rather than along the line; the archived help treats the inset as the space an area type object leaves between its text and the path that bounds it (, ). A rectangular frame keeps its inset from each side as before, and a column's inner edges keep it once. An edge that two contours of the frame share lies inside the frame, so text runs across it with no inset on either side, and a negative text wrap offset does not shrink a wrap object beside such an edge. Tests: `layout::region::inset_on_a_shaped_frame_is_measured_from_its_sloped_edge`, `inset_keeps_text_clear_of_a_hole_s_sloped_edges`, `inset_applies_once_at_a_column_s_edge_and_at_the_frame_s_edge`, `inset_is_not_kept_beside_an_edge_two_contours_share`, `negative_wrap_offset_does_not_shrink_beside_an_edge_two_contours_share`. + Area Type Options › First Baseline offers Em Box Height (`text.areaOptions {firstBaseline: "emBoxHeight"}`), which the help page describes as using the font's em box height (): the top of the first line's ideographic em box, the largest on a line of several sizes, touches the top of the type area inside the inset, in each row/column cell and in vertical type from the frame's right edge. The em box is the one Top-to-Top leading uses (VectorCraft's own measure: an ideograph's cell in the font's vertical metrics, else 0.88 em above the baseline), and Min is the least distance, as with the other kinds. Native files and `.ai` files save and open it; a `.ai` First Baseline kind VectorCraft does not read keeps today's fallback. Tests: `em_box_height_puts_the_first_lines_em_box_top_at_the_type_area_top`, `em_box_height_sets_a_vertical_frames_first_column_at_its_em_box`, `area_options_set_the_em_box_height_first_baseline`, `every_first_baseline_kind_comes_back_with_its_minimum`. An edit copies a thread's story only when it changes one of the thread's frames: with a story of 50,000 characters threaded through 8 frames with a style change at every word, moving another object took 7.8 ms and now takes 0.013 ms, and a frame of a drag took 7.2 ms and now takes 0.012 ms (release build, `threaded_story_edit_timing`). When a story flows through threaded area type, each frame is measured with the whole paragraphs of the story that it needs and a few more, not with the whole rest of the story, and it keeps the same text as before. A story of 1,500 one-line paragraphs (55,892 bytes) through 40 frames was laid out over 2,126,762 bytes of text while the frames were measured, and is now laid out over 21,035 (`thread::tests::many_frames_measure_about_the_text_they_take`). Area type with its lines aligned to the center, the bottom or justified vertically, and type on a path whose first paragraph is aligned Left, Justify Left, Justify All or Auto, are measured the same way: the same story through 40 area frames aligned to the center was laid out over 2,126,762 bytes and is now laid out over 21,035, through 40 paths aligned Left over 2,135,202 bytes and now over 20,583, and through 40 paths aligned Justify All over 2,135,202 bytes and now over 20,583 (same test). Shrink Text to Fit, Dynamic Text, Optical Margin Alignment and Roman Hanging Punctuation on a path, a path aligned to the center or the right, horizontal type on a path whose first paragraph is set right to left or with right-to-left text in the rest of the story, and a frame whose share ends in the story's last paragraph are still measured with the whole rest. A paragraph that continues from one threaded frame into the next has its first-line indent and bullet or number in the frame where it starts; in the next frame its first line starts where its wrapped lines start. In frames that are no longer threaded, copies of a frame and point type converted from one, the first paragraph has its indent and bullet or number again.