From 396796ff9b574bb7bc653189848091b688bfcbca Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 21:46:30 -0800 Subject: [PATCH] Type: the Every-line Composer sets the visible lines of a mixed-size paragraph that overflows a shaped frame A paragraph whose characters differ in line metrics, in area type that is not a rectangle or that wraps around an object, was broken line by line with the Single-line Composer when the frame could not hold all of it. The lines the frame holds are now composed with the whole paragraph: a line the frame has no room for, and every line after it, is measured as wide as the span of the last line set in the frame, less its indents. Those lines overflow, or go on in the next threaded frame, which composes them again at its own widths. A paragraph whose first line has no room, and a search that passes its limits, still fall back to Single-line. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/text/src/layout/shaped.rs | 81 ++++++++++++++++++++++---------- crates/text/src/tests/combos.rs | 66 +++++++++++++++++++++++--- crates/text/src/thread/tests.rs | 74 +++++++++++++++++++++++++++++ docs/mcp.md | 10 ++-- docs/target-app-parity.md | 2 +- 5 files changed, 199 insertions(+), 34 deletions(-) diff --git a/crates/text/src/layout/shaped.rs b/crates/text/src/layout/shaped.rs index 72f6ed8733..63005364fb 100644 --- a/crates/text/src/layout/shaped.rs +++ b/crates/text/src/layout/shaped.rs @@ -5,6 +5,11 @@ //! line. Each line the composer tries is placed from where the lines above it left the pen, at its //! own tallest metrics, as the line loop in [`super::flow`] places a composed line: the span it //! gets is the room across its whole height. +//! +//! A paragraph the frame cannot hold is still composed whole: a line the frame has no room for, +//! and every line after it, is measured as wide as the span of the last line set in the frame, +//! less its own indents. The line loop sets only the lines that fit, and the rest overflows or +//! goes on in the next threaded frame, which composes it again at its own measures. use std::cell::Cell; use std::collections::HashMap; @@ -63,19 +68,33 @@ struct Start<'r> { /// The paragraph's first line (it takes the first-line indent). first: bool, pen: Pen<'r>, - /// The line placed at each of the metrics it was tried with: its width and the pen after it, - /// or `None` when the frame has no room for it. - placed: Vec<(Metrics, Option<(f64, Pen<'r>)>)>, + /// The width of the span the line above was set in, `None` for the paragraph's first line. + span: Option, + /// The line above was past the frame's end: this line is too, at the width of `span`. + past: bool, + /// The line placed at each of the metrics it was tried with, or `None` when it can't be set. + placed: Vec<(Metrics, Option>)>, /// The metrics of glyphs `pos..to`, measured so far. to: usize, m: Option, } -/// What a line's placement depends on: its first glyph, whether it is the paragraph's first line, -/// and the pen's cell, baselines, pending space, narrowest word without room and further spans. -type Key = (usize, bool, usize, Option, Option, u64, u64, Vec<[u64; 3]>); +/// A line set from a [`Start`]: its width, the pen after it, the width of the span it was set +/// in, and whether it is past the frame's end (measured, but not in the frame). +#[derive(Clone)] +struct Placed<'r> { + width: f64, + pen: Pen<'r>, + span: f64, + past: bool, +} -fn key(pos: usize, first: bool, pen: &Pen<'_>) -> Key { +/// What a line's placement depends on: its first glyph, whether it is the paragraph's first line, +/// the pen's cell, baselines, pending space, narrowest word without room and further spans, the +/// span of the line above and whether the line is past the frame's end. +type Key = (usize, bool, usize, Option, Option, u64, u64, Vec<[u64; 3]>, Option, bool); + +fn key(pos: usize, first: bool, pen: &Pen<'_>, span: Option, past: bool) -> Key { ( pos, first, @@ -85,6 +104,8 @@ fn key(pos: usize, first: bool, pen: &Pen<'_>) -> Key { pen.pending.to_bits(), pen.no_room_for.to_bits(), pen.queued.iter().map(|&(b, x0, x1)| [b.to_bits(), x0.to_bits(), x1.to_bits()]).collect(), + span.map(f64::to_bits), + past, ) } @@ -159,13 +180,14 @@ impl<'a, 'r> Shaped<'a, 'r> { } } - /// The start of a line at glyph `pos` with `pen`: an existing one when its placement is the same. - fn start(&mut self, pos: usize, first: bool, pen: Pen<'r>) -> usize { - let k = key(pos, first, &pen); + /// The start of a line at glyph `pos` with `pen`, after a line set in a span `span` wide (past + /// the frame's end with `past`): an existing one when its placement is the same. + fn start(&mut self, pos: usize, first: bool, pen: Pen<'r>, span: Option, past: bool) -> usize { + let k = key(pos, first, &pen, span, past); if let Some(&id) = self.known.get(&k) { return id; } - self.starts.push(Start { pos, first, pen, placed: vec![], to: pos, m: None }); + self.starts.push(Start { pos, first, pen, span, past, placed: vec![], to: pos, m: None }); let id = self.starts.len() - 1; self.known.insert(k, id); id @@ -177,7 +199,7 @@ impl Measure for Shaped<'_, '_> { fn first(&mut self) -> usize { let pen = self.pen.clone(); - self.start(0, !self.continued, pen) + self.start(0, !self.continued, pen, None, false) } fn line(&mut self, &id: &usize, pos: usize, end: usize) -> Result, Exhausted> { @@ -186,14 +208,14 @@ impl Measure for Shaped<'_, '_> { } self.probes += 1; let Some(start) = self.starts.get_mut(id) else { return Ok(None) }; - let Some((width, pen)) = line(&self.para, start, pos, end)? else { return Ok(None) }; - Ok(Some((width, self.start(end, false, pen)))) + let Some(placed) = line(&self.para, start, pos, end)? else { return Ok(None) }; + Ok(Some((placed.width, self.start(end, false, placed.pen, Some(placed.span), placed.past)))) } /// A longer line is placed as this one is, and gets the same room, unless a glyph after it - /// changes the line's tallest metrics. + /// changes the line's tallest metrics. Past the frame's end every line is as wide. fn may_widen(&mut self, &id: &usize, pos: usize, end: usize) -> bool { - let Some(start) = self.starts.get(id) else { return false }; + let Some(start) = self.starts.get(id).filter(|start| !start.past) else { return false }; let m = if start.pos == pos && start.to == end { start.m } else { self.para.sg.get(pos..end).and_then(Metrics::max) }; match (m, self.rest.get(end).copied().flatten()) { (Some(m), Some(rest)) => m.union(rest) != m, @@ -212,12 +234,14 @@ impl Drop for Shaped<'_, '_> { } } -/// The width of the line of glyphs `pos..end` from `start`, and the pen after it; `None` when -/// the frame has no room for it. -fn line<'r>(p: &Para<'_>, start: &mut Start<'r>, pos: usize, end: usize) -> Result)>, Exhausted> { +/// The line of glyphs `pos..end` from `start`; `None` when it can't be set. +fn line<'r>(p: &Para<'_>, start: &mut Start<'r>, pos: usize, end: usize) -> Result>, Exhausted> { if start.pos != pos || end <= pos { return Ok(None); } + if start.past { + return Ok(past_end(p, start)); + } // The line's tallest metrics, measured on from the glyphs already measured. if end < start.to { start.m = p.sg.get(pos..end).and_then(Metrics::max); @@ -239,9 +263,18 @@ fn line<'r>(p: &Para<'_>, start: &mut Start<'r>, pos: usize, end: usize) -> Resu Ok(placed) } -/// The line from `start` placed with metrics `m`: its width and the pen after it, as the line loop -/// places and settles it; `None` when no frame cell has room for it. -fn place<'r>(p: &Para<'_>, start: &Start<'r>, m: Metrics) -> Result)>, Exhausted> { +/// A line from `start` past the frame's end: as wide as the span of the last line set in the frame, +/// less its indents, and the pen left where the frame ran out. `None` when the paragraph has no line +/// in the frame to measure it by. +fn past_end<'r>(p: &Para<'_>, start: &Start<'r>) -> Option> { + let span = start.span.filter(|span| span.is_finite())?; + let (ind_l, ind_r) = line_indents(p.para, start.first, p.mirror); + Some(Placed { width: span - ind_l - ind_r, pen: start.pen.clone(), span, past: true }) +} + +/// The line from `start` placed with metrics `m`, as the line loop places and settles it; past the +/// frame's end ([`past_end`]) when no frame cell has room for it. +fn place<'r>(p: &Para<'_>, start: &Start<'r>, m: Metrics) -> Result>, Exhausted> { let (ind_l, ind_r) = line_indents(p.para, start.first, p.mirror); let word = word_width(p.sg, start.pos, p.line_end, p.para.kinsoku) - (p.start_credit)(start.pos); let mut pen = start.pen.clone(); @@ -262,12 +295,12 @@ fn place<'r>(p: &Para<'_>, start: &Start<'r>, m: Metrics) -> Result return Ok(None), // Out of steps: the frame may still have room further down. None if p.steps.get() == 0 => return Err(Exhausted), - None => return Ok(None), + None => return Ok(past_end(p, start)), } } } diff --git a/crates/text/src/tests/combos.rs b/crates/text/src/tests/combos.rs index 0146871265..4f57aa6972 100644 --- a/crates/text/src/tests/combos.rs +++ b/crates/text/src/tests/combos.rs @@ -465,18 +465,72 @@ fn composer_x_mixed_sizes_in_a_frame_that_widens() { #[test] fn composer_x_mixed_sizes_overflow_a_shaped_frame() { - // A stepped frame too short for the paragraph: the lines that fit are set, in order, each once - // and within its room, and the frame overflows. + // A stepped frame too short for the paragraph: the every-line composer still breaks the lines + // that fit as one paragraph, with the lines past the frame's end measured as wide as the last + // line the frame holds. Here that is the narrow part, so the lines that fit break as in a frame + // tall enough for the whole paragraph, and not as the single-line composer breaks them. They + // are set in order, each once and within its room, and the frame overflows. let w = x_width(); - let mut t = stepped(w, w * 0.5, 40.0, 75.0); - t.runs = with_x(sans(36.0)); - t.para.composer = Composer::EveryLine; - let l = layout(db(), &t); + let set = |bottom: f64, composer: Composer| { + let mut t = stepped(w, w * 0.5, 40.0, bottom); + t.runs = with_x(sans(36.0)); + t.para.composer = composer; + let l = layout(db(), &t); + (line_texts(&t, &l), l, t) + }; + let (every, l, t) = set(75.0, Composer::EveryLine); assert!(l.overflow && l.lines.len() >= 2, "{:?}", l.lines); assert_eq!(l.lines[0].start, 0); assert!(l.lines.windows(2).all(|p| p[0].end == p[1].start && p[0].start < p[0].end), "{:?}", l.lines); assert!(past_their_room(&t, &l).is_empty(), "{:?}", l.lines); assert!(l.lines.iter().all(|li| li.baseline + li.descent <= 75.0 + 0.01), "{:?}", l.lines); + assert_eq!(every, ["Destroy all creatures with toughness", "X or less. Then", "draw a card for each"]); + let (whole, ..) = set(300.0, Composer::EveryLine); + assert_eq!(every, whole[..every.len()]); + let (greedy, ..) = set(75.0, Composer::SingleLine); + assert_ne!(every, greedy); + // A frame with no room for a line sets none. + for composer in [Composer::EveryLine, Composer::SingleLine] { + let mut t = stepped(w, w * 0.5, 4.0, 8.0); + t.runs = with_x(sans(36.0)); + t.para.composer = composer; + let l = layout(db(), &t); + assert!(l.lines.is_empty() && l.overflow, "{composer:?}: {:?}", l.lines); + } +} + +#[test] +fn composer_x_mixed_sizes_overflow_around_text_wrap() { + // A rectangle that wraps around an object beside its lower lines, too short for the + // paragraph: the every-line composer breaks the lines that fit as one paragraph, each span + // measured across its line's whole height, and the frame overflows. No glyph runs into the + // object. + let w = x_width(); + let object = Rect::new(w * 0.4, 40.0, w * 0.6, 70.0); + let set = |composer: Composer| { + let mut runs = with_x(sans(36.0)); + runs[0] = run("Destroy all creatures with toughness\u{a0}", sans(12.0)); + let mut t = area(runs, Rect::new(0.0, 0.0, w, 80.0)); + t.wrap = vec![vectorcraft_doc::WrapShape { path: PathData::from_bezpath(&object.to_path(0.1)), wrap: Default::default() }]; + t.para.composer = composer; + let l = layout(db(), &t); + (line_texts(&t, &l), l, t) + }; + let (every, l, t) = set(Composer::EveryLine); + assert!(l.overflow && l.lines.len() >= 3, "{:?}", l.lines); + assert!(l.lines.windows(2).all(|p| p[0].end == p[1].start && p[0].start < p[0].end), "{:?}", l.lines); + assert!(past_their_room(&t, &l).is_empty(), "{:?}", l.lines); + let text = t.plain_text(); + let hits = l.glyphs.iter().filter(|g| { + let li = &l.lines[g.line]; + let across = li.baseline - li.ascent < object.y1 && li.baseline + li.descent > object.y0; + across && !text[g.byte..].starts_with(char::is_whitespace) && g.origin.x < object.x1 && g.origin.x + g.advance > object.x0 + }); + assert_eq!(hits.count(), 0, "{:?}", l.lines); + // The lines that fit break as in `composer_x_mixed_sizes_around_text_wrap`'s taller frame. + assert_eq!(every, ["Destroy all creatures with", "toughness\u{a0}X", "or less. Then", "draw a card for", "each creature"]); + let (greedy, ..) = set(Composer::SingleLine); + assert_ne!(every, greedy); } #[test] diff --git a/crates/text/src/thread/tests.rs b/crates/text/src/thread/tests.rs index 0ac64f5d27..adbf3b2c70 100644 --- a/crates/text/src/thread/tests.rs +++ b/crates/text/src/thread/tests.rs @@ -397,6 +397,80 @@ fn a_continued_paragraph_fills_the_frame_it_continues_into() { assert_eq!(checked, 16); } +/// Area type in a frame `w` wide down to `y` and `narrow` wide below it, down to `bottom`. +fn stepped_frame(w: f64, narrow: f64, y: f64, bottom: f64) -> TextObject { + let mut t = frame(0.0); + let path = kurbo::BezPath::from_vec(vec![ + kurbo::PathEl::MoveTo((0.0, 0.0).into()), + kurbo::PathEl::LineTo((w, 0.0).into()), + kurbo::PathEl::LineTo((w, y).into()), + kurbo::PathEl::LineTo((narrow, y).into()), + kurbo::PathEl::LineTo((narrow, bottom).into()), + kurbo::PathEl::LineTo((0.0, bottom).into()), + kurbo::PathEl::ClosePath, + ]); + t.kind = TextKind::Area { frame: PathData::from_bezpath(&path) }; + t +} + +/// A paragraph of mixed type sizes that a stepped frame cannot hold goes on in the next frame. The +/// every-line composer breaks the lines the first frame holds as one paragraph, as in a frame tall +/// enough for all of it and not as the single-line composer breaks them, and the first frame +/// takes the text of those lines. The next frame sets the rest at its own width, without the +/// first-line indent, and no character is lost or repeated. The frames take the same shares as +/// when each is measured with the whole rest of the story. +#[test] +fn a_mixed_size_paragraph_continued_from_a_shaped_frame_is_composed_in_both() { + use vectorcraft_doc::Composer; + let db = FontDb::global(); + let small = CharStyle { size: 12.0, ..CharStyle::default() }; + let big = CharStyle { size: 36.0, ..CharStyle::default() }; + let probe = layout(db, &TextObject::point(vectorcraft_geom::Point::ZERO, "Destroy all creatures with toughness X or", small.clone())); + let w = probe.lines[0].x1 - probe.lines[0].x0 + 2.0; + let story = vec![ + TextRun { text: "Destroy all creatures with toughness ".into(), style: small.clone(), inline: None }, + TextRun { text: "X".into(), style: big, inline: None }, + TextRun { text: " or less. Then draw a card for each creature destroyed this way.\nSecond paragraph.".into(), style: small, inline: None }, + ]; + let text: String = story.iter().map(|r| r.text.as_str()).collect(); + let (a, tall) = (stepped_frame(w, w * 0.5, 40.0, 85.0), stepped_frame(w, w * 0.5, 40.0, 300.0)); + let b = sized(200.0, w * 0.75, 300.0); + let texts = |lay: &crate::TextLayout, shown: &str| lay.lines.iter().map(|l| shown[l.start..l.end].trim_end().to_string()).collect::>(); + let shares = |composer: Composer, indent: f64| { + let para = ParaStyle { composer, first_line_indent: indent, ..Default::default() }; + let paras = [para.clone(), para]; + let parts = distribute(db, &[&a, &b], &story, ¶s); + assert_eq!(parts.iter().map(|p| p.continues).collect::>(), [false, true], "{composer:?}"); + let joined: String = parts.iter().flat_map(|p| &p.runs).map(|r| r.text.as_str()).collect(); + assert_eq!(joined, text, "{composer:?}: no character lost or repeated"); + same_as_whole_rest(db, &[&a, &b], &story, ¶s, &format!("{composer:?}, indent {indent}")); + let shown = |p: &Slice| p.runs.iter().map(|r| r.text.as_str()).collect::(); + let lays: Vec<_> = [&a, &b].iter().zip(&parts).map(|(f, p)| laid(db, f, p)).collect(); + assert!(lays.iter().all(|l| !l.overflow), "{composer:?}: each frame holds its share"); + let whole = + laid(db, &tall, &Slice { runs: story.clone(), paras: paras.to_vec(), list_count: 0, list_level_counts: vec![], continues: false }); + let first = texts(&lays[0], &shown(&parts[0])); + // The first frame takes the text of the lines it sets. + assert_eq!(shown(&parts[0]).split_whitespace().collect::>(), first.join(" ").split_whitespace().collect::>()); + (first, texts(&whole, &text), lays, parts) + }; + for indent in [0.0, 20.0] { + let (every, whole, lays, parts) = shares(Composer::EveryLine, indent); + assert!(every.len() >= 2, "{every:?}"); + assert_eq!(every, whole[..every.len()], "indent {indent}"); + if indent == 0.0 { + assert_eq!(every, ["Destroy all creatures with toughness", "X or less. Then", "draw a card for each"]); + let (greedy, ..) = shares(Composer::SingleLine, indent); + assert_eq!(greedy, ["Destroy all creatures with toughness X", "or less. Then draw a", "card for each", "creature destroyed"]); + } + // The next frame starts at its left edge, and its lines keep within it. + assert!((line_start(&lays[1], 0) - 200.0).abs() < 1e-6, "{}", line_start(&lays[1], 0)); + assert!(lays[1].lines.iter().all(|l| l.x1 <= 200.0 + w * 0.75 + 1e-6), "{:?}", lays[1].lines); + assert!((line_start(&lays[0], 0) - indent).abs() < 1e-6, "{}", line_start(&lays[0], 0)); + assert!(parts[1].continues && lays[1].lines.len() >= 2, "{:?}", lays[1].lines); + } +} + /// `frames` holding the runs of `parts`, for [`continued`]. fn filled(frames: &[&TextObject], parts: &[Slice]) -> Vec { frames diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..1c665098ae 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10445,9 +10445,13 @@ give the same result there. A paragraph whose characters differ in line metrics scale, or an inline graphic taller than the text) is composed with Every-line in area type of any shape, rows, columns and text wrap included. In a frame that is not a rectangle, or with text wrap, each line it tries is measured where the lines above it put it, across the line's own height, so a taller line that reaches where the frame is -narrower, or beside a wrap object, gets the room there. Such a paragraph falls back to Single-line when the frame has -no room for all of it, or when the search for its breaks passes VectorCraft's own limits (1,000,000 lines tried and -2,000,000 baseline steps for one paragraph, 2,000,000 lines and 4,000,000 steps for all the paragraphs of a frame). +narrower, or beside a wrap object, gets the room there. When the frame has no room for all of such a paragraph, the +lines it holds are still composed with the whole paragraph: VectorCraft measures the lines past the frame's end as +wide as the span of the last line the frame holds, less their indents. Those lines overflow, or go on in the next +threaded frame, which composes them again at its own widths. Such a paragraph falls back to Single-line when the +frame has no room for its first line, or when the search for its breaks passes VectorCraft's own limits (1,000,000 +lines tried and 2,000,000 baseline steps for one paragraph, 2,000,000 lines and 4,000,000 steps for all the +paragraphs of a frame). The UI command `type.lineComposer` (Cmd+Alt+Shift+C, in remote mode `press_key {key: "C", mods: {cmd: true, alt: true, shift: true}}` or `invoke_menu`) sets `singleLine` when every paragraph of the selected type (or every paragraph the Type tool's selection touches) uses Every-line, else `everyLine`, and returns the composer it set. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..ee1cc33480 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1299,7 +1299,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Mouse wheel over the font family field (#5253):** In the Character and Properties panels and the Control bar, turning the mouse wheel over the closed font family field applies the next family to the selected type (the previous one when turned up), keeping the style when the family has it, else its closest. Each notch is one undo step; leaving the field or Escape keeps the family, and Undo takes it back. The steps use the font menu's order at the first turn and keep it until the pointer leaves the field or the text selection changes, so recent-font updates do not reshuffle later turns. That order follows the font filters every font menu shares (one chosen in the Glyphs panel's menu or a dialog's applies too) but ignores its search text, puts recent families first, and stops at the first and last family. A turn with a modifier key is left to the panel and the canvas. Behavior reference: the [Illustrator CS6 reference](https://help.adobe.com/archive/en/illustrator/cs6/illustrator_reference.pdf#page=10) describes editing hovered dropdown controls with the mouse wheel; [Find and apply fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/find-and-apply-fonts.html) names the family field's places. Applying it to the font field, the order, the ends and the undo steps are VectorCraft's own rules. Tests: `crates/ui-egui/src/tests/font_menu.rs`, `crates/ui-egui/src/font_menu/tests.rs`, `crates/ui-egui/tests/font_wheel.rs`. - **Type:** Character size, leading, baseline shift and horizontal-scale controls account for object/group transforms (#1034): exact document-point sizes, mixed-value display and keyboard increments, range edits, resettable horizontal stretch, undo/redo and native save/reopen (`tests_typescale`, Character panel tests). Point size is the transformed em-height axis, independent of glyph ink bounds; affine rotation, reflection and shear are retained. Group scaling still scales text; preserving font sizes is a separate enhancement. Behaviour reference: [Transform text](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/transform-text.html) (public documentation). Text Wrap, Type on a Path effects (Rainbow/Skew/3D Ribbon/Stair Step/Gravity) and Options (Flip, Align to Path, Spacing; OK keeps the type where it is), type on a path's start, centre and end brackets (Selection and Direct Selection drag them to set where the type runs, slide it along its path and, across the path, flip it: #429), Character and Paragraph Styles (override-preserving redefine), paragraph attributes per paragraph (alignment, indents, spacing, hyphenation, hanging punctuation, tab stops, paragraph style, direction, mojikumi and leading model; the Paragraph, Tabs and Paragraph Styles panels act on the paragraphs the Type tool's selection or caret touches, Return continues the paragraph's style, threads and SVG keep them), Area Type Options (rows/columns/inset/first baseline, Text Flow by rows or by columns (#4978), vertical Align Top/Center/Bottom/Justify per row/column, reflowing non-rectangular frames and text wrap), threaded text across any closed shapes, Fit Headline, the Every-line Composer for justified and ragged text (paragraph-wide breaks for an even rag, Single-line per object from the Paragraph panel menu or `text.setFormat {composer}`). Area type resizes like Illustrator's type areas: a bounding-box handle drag (Selection tool) or Area Type Options Width/Height size the frame and the text reflows at its size (threads too); Direct Selection drags a frame corner or edge (`text.reshapeArea`), and an anchor of the path of type on a path outside perspective, the type reflowing along it (`text.reshapePath`, #3980). Point type still scales. Auto Size: the frame height follows the text after every edit, in the same undo step (rectangular frames of horizontal type in one row; columns get the least height that holds them; a height set by hand or threading turns it off), and the "Auto Size New Area Type" preference gives it to new area type. Shrink Text to Fit (beyond Illustrator): overflowing area type scales its sizes, leading and baseline shifts down by the largest factor (in 0.1 pt steps of the first run, down to a minimum percentage) that fits, at layout time so every export sees it. `text.areaOptions` and `document.inspect` report overflow and the shrink factor. The Selection tool shows the type widget beside selected type's bounding box (hollow on point type, filled on area type); double-clicking it converts between them (Type › Convert To Area Type / Convert To Point Type), keeping the text and its styles in place. Variable fonts list every named instance as a style of their family (Figtree Light to Black and their italics, Bahnschrift, Segoe UI Variable), and the instance chosen is shaped, drawn, outlined and measured at its axis settings; PDF and SVG embed it as that instance. The Character panel's Variable Font sliders set each axis (see Fonts). Beyond Illustrator: inline graphics (`text.insertInline`, Type ▸ Insert Inline Symbol) set a document symbol in a run of type as one character that flows, wraps and justifies like a glyph (InDesign-style inline objects, e.g. mana symbols in card rules text): sized to a multiple of the font size, centred on the cap height, opening up tall lines, following Redefine Symbol; a character of its run's size for Character Alignment and Top-to-Top leading, placed by the bidi reordering in right-to-left text (a neutral U+FFFC); drawn on the canvas, kept as live text plus a `` in SVG and as vector art in PDF; Backspace removes it whole. Hebrew and Arabic are laid out right to left with the Unicode bidirectional algorithm (embedded Latin and numbers keep their direction, lines put in visual order after wrapping) in point, area and path type, with caret, selection and arrow keys in visual order; each paragraph's direction comes from its first strong character unless Paragraph Direction sets it (Paragraph panel with Show Indic Options, `text.setFormat {direction}`), and new type aligns to the start of its direction. SVG export outlines right-to-left text. Arabic typefaces: builds made with a craft-fonts checkout that holds its Arabic families (Noto Sans Arabic, the Arabic fallback, plus Cairo, Tajawal, Almarai, IBM Plex Sans Arabic, Noto Kufi Arabic, Amiri, Alexandria, Fustat, Reem Kufi, Aref Ruqaa and Gulzar once craft-fonts adds them, storytold/craft-fonts#11; releases get them when their craft-fonts pin moves) list them in the font menus on desktop; the web build fetches them from beside the wasm (Noto Sans Arabic before start, so Arabic never shows as boxes, the rest in the background). Font Size and Leading are combo boxes in the Character and Properties panels (Font Size in the Control bar too, beside the Character link, font family and style): type, step with ↑/↓ or the spinner, scrub the label, or pick a preset (6–72 pt, shown in the type unit; Leading also Auto), each pick one undo step; Kerning and Tracking list -100…200; a size, leading, kerning or tracking the selected text doesn't share shows blank (#458). Type › Bold and Italic (beyond Illustrator, as page layout apps have them; Cmd+Shift+B / Cmd+Shift+I while the Type tool edits text) switch the selected type to its family's own Bold or Italic face and back, keeping its width (a Narrow face stays Narrow); a family without that face says so (#724). The commands that make or restyle type (and the MCP `add_text` tool) say in their result when area type does not fit its frame, and `add_text` takes Auto Size and Shrink Text to Fit (#1500, fixes #1471). Cmd+Shift+C (Align center) works on Windows and Linux too (#1940). A double-click on area type's bottom middle handle turns on Auto Size (#1940). Print and Print Preview warn about the area type and type on a path that prints without the text that doesn't fit, and give their ids. A tab stop in the Tabs panel drags from where the press landed, a stop just added included (#1487, fixes #1458). Area type in a non-rectangular shape moves a word too wide for the top lines down to the first line that holds it instead of breaking it (#1617, fixes #1615). Stylistic sets (ss01–ss20), stylistic and titling alternates, proportional and lining figures, and superscript and subscript glyphs can be turned on as OpenType features of a character style (`text.setStyle {features}`), and the OpenType panel keeps them (#1611, fixes #1607). Escape while typing ends the edit, keeps the type selected and switches back to the tool that was active before type editing began (kept while clicks move editing to other text), or to the Selection tool when there was none (#1802, #1686, #1656). Select › Same matches type on its characters' fill and stroke (#1746, #1737). `text.create`, `text.createInPath` and the MCP `add_text` tool take `justify`, so point type can be centred on or end at its point (#1752, #1748). The Character panel menu's Show Font Height Options shows a Set Font Height Reference dropdown under Font Size (`text.setFormat` or `text.setRangeStyle` `{fontHeightReference}`). Each reference shows an icon of the height it measures before its name, in the open list and in the closed field (#6304): a frame around a letter for Em Box, a bar from the baseline to the top of a capital for Cap Height and of a lowercase x for x-Height, and a frame inset in the em square for ICF Box. With Em Box, the default, the font size is the size of the em square; with Cap Height, x-Height or ICF Box, the characters are set at the em size at which the font's OS/2 cap height, its x height or the height of its ideographic character face equals the font size. With a font that has no such value, or one outside 0.1 to 2 em, the size measures the em box. SVG, PDF and legacy `.ai` export and the CSS Properties rules write the em size the characters are drawn at, and DXF export writes 0.7 times that em size as each TEXT entity's height (group 40, the height of its capitals). Behavior reference: [Vary font height](https://web.archive.org/web/20251118174722/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/vary-font-height.html). - The Every-line Composer composes a paragraph whose characters differ in line metrics (type size, font, leading or vertical scale, or an inline graphic taller than the text) in area type of any shape, rows, columns and text wrap included. In a frame that is not a rectangle, or with text wrap, each line it tries is measured where the lines above it put it, across the line's own height, so a taller line gets the room of the narrower part of the frame, or of the span beside a wrap object, that it reaches. Such a paragraph is broken with the Single-line Composer when the frame has no room for all of it or when the search passes VectorCraft's own limits. Behavior reference: [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/set-hyphenation-and-line-breaks.html). + The Every-line Composer composes a paragraph whose characters differ in line metrics (type size, font, leading or vertical scale, or an inline graphic taller than the text) in area type of any shape, rows, columns and text wrap included. In a frame that is not a rectangle, or with text wrap, each line it tries is measured where the lines above it put it, across the line's own height, so a taller line gets the room of the narrower part of the frame, or of the span beside a wrap object, that it reaches. When the frame cannot hold all of such a paragraph, the lines it holds are still composed with the whole paragraph, the lines past the frame's end measured as wide as the last line the frame holds (VectorCraft's own rule); they overflow or go on in the next threaded frame, which composes them again. Such a paragraph is broken with the Single-line Composer when the frame has no room for its first line or when the search passes VectorCraft's own limits. Behavior reference: [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/set-hyphenation-and-line-breaks.html), and for text that flows on between threaded objects, [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/create-text-threads-between-objects.html). A text wrap object's Offset may be negative as well as positive ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=307)). A negative Offset (to -1000 pt) shrinks the wrap object by that distance, measured from each edge itself and from the edges of its holes, so lines beside it, above it and below it run that far into it, and an object narrower than twice the distance no longer moves text aside. With Invert Wrap, a negative Offset keeps the text that far inside the object. These are VectorCraft's own rules for the shape of the shrunk object. Text Wrap Options, `object.textWrap.make` and `object.textWrap.options` and the MCP `text_wrap` tool take the negative value, and layout uses it (`crates/text/src/layout/region.rs` tests, `cmd::textwrap::tests::text_wrap_options_negative_offset_reflows_and_round_trips`). In area type of a shape other than a rectangle, each line's whole band, ascent to descent, stays inside the frame: where an edge pinches in within the band, the line ends at the narrowest point, and a line runs beside a hole that starts and ends within its band, not across it. In area type of any shape, a line also stays clear of a text wrap object that reaches into any part of its band, and inside an Invert Wrap object over its whole band (`crates/text/src/layout/region.rs` tests). In area type whose frame has several contours, a line runs across an edge two contours share only when their edges lie exactly on one line, so a gap between contours keeps lines from crossing it, even a gap one unit in the last place wide near the edge of the canvas; an edge divided by an anchor exactly on it still lets lines cross (`layout::region::separate_slanted_contours_keep_a_four_ulp_gap_near_canvas_limit`, `shared_slanted_edge_still_joins_near_canvas_limit`, `area_type_sets_no_line_across_a_four_ulp_gap_between_slanted_contours`).