# Conflicts:
#	crates/engine/src/cmd/text.rs
This commit is contained in:
Brandon Thomas
2026-10-14 23:31:51 -04:00
2 changed files with 42 additions and 4 deletions
+1
View File
@@ -144,6 +144,7 @@ Newest first.
- **2026-10-15** · A line of text is set when its baseline fits in the frame, as in InDesign: descenders may hang below the frame's bottom. A frame sized to the cap height of a big heading (103 pt in a 2.77 cm frame, as Zero2Graphic's magazine tutorial draws them) no longer oversets. No readiness percentage change.
- **2026-10-15** · A story that ends with a return is no longer overset when only its empty last paragraph doesn't fit, as in InDesign (Preflight said "Overset text: 0 characters" for a caption InDesign shows with no errors). No readiness percentage change.
- **2026-10-15** · IDML: the CJK leading model InDesign writes on [No paragraph style] of every document (Aki Below) only applies when the document uses a Japanese composer, as in InDesign; a Western document's paragraphs after a size change no longer sit lower than in InDesign (Montilla Design's Flex Layout file: its captions came out overset). No readiness percentage change.
- **2026-10-14** · Type › Fill with Placeholder Text fills a frame with paragraphs of a few sentences, as InDesign does, so one paragraph can be styled on its own (it was one long paragraph, and the filler ran sentences together, "interit.Ovid"). No readiness percentage change.
- **2026-10-13** · Object › Fitting has InDesign's shortcuts: Fill Frame Proportionally ⌘⌥⇧C, Fit Content Proportionally ⌘⌥⇧E, Fit Frame to Content ⌘⌥C, Fit Content to Frame ⌘⌥E, Center Content ⌘⇧E. No readiness percentage change.
- **2026-10-13** · Gradients between process colours blend as inks, as InDesign shows them: magenta to cyan passes through C 50 M 50 (a light lilac) on screen instead of the darker RGB mix, and a midpoint between CMYK or grey stops no longer turns the PDF shading RGB. No readiness percentage change.
- **2026-10-14** · The Swatches panel has InDesign's header: a Fill/Stroke proxy, Formatting Affects Container/Text and the Tint of the colour in front (a tint alone keeps each object's own swatch). Clicking a swatch applies it to the fill or stroke in front (of the text, when formatting affects text), and the bottom row has New Color Group, New Swatch and Delete Swatch. No readiness percentage change.
+41 -4
View File
@@ -1587,20 +1587,30 @@ fn fill_placeholder(s: &mut Session, p: &Value) -> Result<Value> {
story_of(s, p).ok_or_else(|| bad("type.fillWithPlaceholder", "select a text frame"))?
}
};
// Fill until overset: repeat the filler sentences.
// Fill until overset with paragraphs of two to five sentences, as InDesign's placeholder text
// comes (so a paragraph can be styled on its own).
const SENTENCES_PER_PARAGRAPH: [usize; 7] = [2, 2, 3, 3, 5, 2, 4];
let mut text = String::new();
let sentences: Vec<&str> = PLACEHOLDER.split_inclusive(". ").collect();
let sentences: Vec<&str> = PLACEHOLDER.split_inclusive(". ").map(str::trim_end).collect();
let doc = s.doc()?.doc.clone();
let mut d2 = (*doc).clone();
let (mut paragraph, mut in_paragraph) = (0, 0);
for i in 0..400 {
text.push_str(sentences[i % sentences.len()]);
in_paragraph += 1;
if in_paragraph >= SENTENCES_PER_PARAGRAPH[paragraph % SENTENCES_PER_PARAGRAPH.len()] {
text.push('\n');
(paragraph, in_paragraph) = (paragraph + 1, 0);
} else {
text.push(' ');
}
if i % 3 == 2 {
d2.set_story_text(sid, &text)?;
let cs = compose::compose_story(&d2, sid, &compose::ComposeOptions::default());
if cs.is_overset() {
// Trim to the last sentence that fits.
let cut = cs.overset_at.unwrap_or(text.len());
let keep = text[..cut.min(text.len())].rfind(". ").map(|k| k + 1).unwrap_or(cut);
let cut = cs.overset_at.unwrap_or(text.len()).min(text.len());
let keep = text.get(..cut).and_then(|t| t.rfind('.')).map(|k| k + 1).unwrap_or(cut);
text.truncate(keep);
break;
}
@@ -3008,3 +3018,30 @@ mod compose_tests {
}
}
}
#[cfg(test)]
mod placeholder_tests {
use serde_json::json;
use crate::Session;
/// Fill with Placeholder Text gives paragraphs of a few sentences, as InDesign's does (it was one
/// paragraph, and the filler ran sentences together: "interit.Ovid").
#[test]
fn placeholder_text_comes_in_paragraphs() {
let mut s = Session::new();
s.execute("file.new", &json!({})).unwrap();
let r = s.execute("frame.create", &json!({"rect": [36, 36, 336, 736], "content": "text", "text": ""})).unwrap();
s.execute("type.fillWithPlaceholder", &json!({"frame": r["id"]})).unwrap();
let st = s.execute("story.get", &json!({"story": r["story"]})).unwrap();
let text = st["text"].as_str().unwrap();
let paragraphs: Vec<&str> = text.split('\n').collect();
assert!(paragraphs.len() >= 4, "{} paragraphs", paragraphs.len());
for p in &paragraphs {
assert!(p.ends_with('.') && !p.starts_with(' '), "a paragraph of whole sentences: {p:?}");
}
assert!(!text.contains(".O") && !text.contains(".L"), "sentences are spaced: {text}");
assert!(st["overset"].is_null(), "nothing overset: {}", st["overset"]);
assert!(text.len() > 1500, "the frame is filled: {}", text.len());
}
}