From d4c28a246db349c96cf3a49ecc1a9345a82a2c99 Mon Sep 17 00:00:00 2001 From: midasdf Date: Thu, 22 Oct 2026 01:50:07 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat(compose):=20apply=20=E7=A6=81=E5=89=87?= =?UTF-8?q?=20push-in/push-out=20priorities=20(JIS=20X=204051)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The four JIS X 4051 禁則処理 modes are now reached from the paragraph settings and applied to CJK text by both composers. The empty default and Push In First compose as push-in-first (InDesign's Japanese default); Push Out First, Push Out Only and adjustment-amount as their names say. A per-paragraph CJK flag keeps the default from biasing Latin paragraphs, and mode 3's compression-off is gated by it. The adjustment-amount value is an explicit mapping to the breaker's minimum-adjustment mode instead of falling through the wildcard. docs/cjk-typography.md moves the modes from Unfinished behavior to implemented and corrects the preflight claim; ROADMAP gets a progress line. New regressions pin the default = push-in-first, the push-out-only line-end behavior, the mode mapping and the Latin non-bias. --- ROADMAP.md | 4 +- crates/compose/src/breaker.rs | 53 +++++++++++------ crates/compose/src/lib.rs | 37 ++++++++++-- crates/compose/src/tests.rs | 106 ++++++++++++++++++++++++++++++++++ crates/doc/src/attrs.rs | 5 +- docs/cjk-typography.md | 15 +++-- 6 files changed, 191 insertions(+), 29 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index a7b5105d3..c79b2f7a2 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -3,7 +3,7 @@ **Stage: pre-alpha** · next: alpha, ~5–7 h away; beta ~28 points and ~420–750 h beyond that (the core-workflow gate, not the percentage: ready for real work is already ~47%) - FID1: PDF export normalizes mixed emitted gradient color spaces to RGB with an explicit warning; homogeneous device-space gradients retain their components. Linear/radial, midpoint, archival and print policies have synthetic regression coverage. -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-13 · **Change:** minor (File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text) · **Target:** Adobe InDesign 2026 +> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-22 · **Change:** minor (Compose: the JIS X 4051 禁則処理 push-in/push-out priorities are applied by both composers over CJK text — the empty default and Push In First compose as push-in-first as in InDesign's Japanese default, Push Out First, Push Out Only and adjustment-amount as their names say; Latin paragraphs are not biased; preflight reports only unknown values; previously minor: File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text) · **Target:** Adobe InDesign 2026 - AR1.1: Kashida justification tests verify space fallback without Tatweel fonts using an isolated font database, while retaining elongation assertions when fonts support it. - AR1: Arabic IDML controls now retain character direction, kashida switches, diacritic offsets/forms, paragraph policy values and independent story/table directions. Shaping preserves joining context and script/language selection; paragraph-level bidi, contextual digit conversion, mark-safe elongation, RTL columns/tables and physical column insertion have regression coverage. Vendor-specific justification and diacritic presets remain explicit preflight warnings; see docs/arabic-typography.md. @@ -348,6 +348,8 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m Newest first. +- **2026-10-22** · Compose: the JIS X 4051 禁則処理 push-in/push-out priorities are applied, not just preserved. Both composers bias the break candidates by the selected type over CJK text: push-in-first (the empty default and the UI's Push In First, as in InDesign's Japanese default) rates breaks that would stretch the line worse than ones it can reach by compressing, push-out-first the other way, push-out-only leaves no compression at the line end, and adjustment-amount takes the smallest adjustment. Latin paragraphs are not biased by the default. New regressions pin the default = push-in-first, the push-out-only line-end fits, the mode mapping and the Latin non-bias; `docs/cjk-typography.md` now lists the modes as implemented and preflight reports only unknown values. No readiness percentage change. + - **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change. - **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change. - **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change. diff --git a/crates/compose/src/breaker.rs b/crates/compose/src/breaker.rs index 0dff34702..e861eb023 100644 --- a/crates/compose/src/breaker.rs +++ b/crates/compose/src/breaker.rs @@ -50,8 +50,12 @@ pub struct Spacing { pub optical: bool, /// Korean text breaks between syllables instead of at spaces. pub korean_char_breaks: bool, - /// 0: minimum adjustment; 1: push in; 2: push out first; 3: push out only. + /// JIS X 4051 禁則処理 type: 0: minimum adjustment (調整量優先); 1: push in first (追い込み + /// 優先, the default); 2: push out first (追い出し優先); 3: push out only (追い出しのみ). pub kinsoku_priority: u8, + /// The paragraph has CJK text, so the 禁則 priority biases its breaks. A Latin paragraph's + /// breaks are left alone by the (default) push-in-first policy. + pub kinsoku_cjk: bool, } impl Default for Spacing { @@ -73,19 +77,25 @@ impl Default for Spacing { hyph_zone: 0.0, optical: false, korean_char_breaks: false, - kinsoku_priority: 0, + kinsoku_priority: 1, + kinsoku_cjk: false, } } } impl Spacing { + /// Push out only: the 追い込み (compression that would pull the next character in) is + /// unavailable, so every line end is pushed out (and no line is compressed at its end). + pub(crate) fn push_out_only(&self) -> bool { + self.kinsoku_cjk && self.kinsoku_priority == 3 + } /// Per-tier (word, letter, glyph) stretch and shrink of glyph `g` as a box. fn box_elastic(&self, g: &Glyph) -> ([f64; 3], [f64; 3]) { if g.locked_advance { return ([0.0; 3], [0.0; 3]); } let moji_stretch = if self.justify { g.moji.stretch } else { 0.0 }; - let moji_shrink = if self.kinsoku_priority == 3 { 0.0 } else { g.moji.shrink }; + let moji_shrink = if self.push_out_only() { 0.0 } else { g.moji.shrink }; if !self.justify { return ([0.0; 3], [moji_shrink, 0.0, 0.0]); } @@ -386,7 +396,7 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S let mut p = Item::penalty(0.0, -INF, false); p.hang = prev_hang; if let Some(prev) = i.checked_sub(1).and_then(|j| glyphs.get(j)) { - p.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, sp.kinsoku_priority != 3); + p.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, !sp.push_out_only()); } it.push(p); ig.push(i + 1); @@ -400,7 +410,7 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S let mut gl = Item::glue(w, st, sh); gl.hang = prev_hang; if let Some(prev) = i.checked_sub(1).and_then(|j| glyphs.get(j)) { - gl.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, sp.kinsoku_priority != 3); + gl.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, !sp.push_out_only()); } gl.over = sp.space_overflow(g); last_space = it.len(); @@ -413,7 +423,7 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S let mut p = Item::penalty(0.0, 0.0, false); p.hang = prev_hang; if let Some(prev) = i.checked_sub(1).and_then(|j| glyphs.get(j)) { - p.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, sp.kinsoku_priority != 3); + p.edge_elastic = crate::mojikumi::end_elastic(prev, sp.justify, !sp.push_out_only()); } last_space = it.len(); it.push(p); @@ -437,7 +447,7 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S let (st, sh) = sp.box_elastic(g); let mut bx = Item::boxed(g.adv, st, sh); bx.hang = (if sp.optical { hang_left(g) } else { 0.0 }) - g.moji.start; - bx.start_elastic = crate::mojikumi::start_elastic(g, sp.justify, sp.kinsoku_priority != 3); + bx.start_elastic = crate::mojikumi::start_elastic(g, sp.justify, !sp.push_out_only()); it.push(bx); ig.push(i); let next_is_space = glyphs.get(i + 1).is_none_or(|n| n.is_space()); @@ -445,12 +455,12 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S if matches!(g.ch, '-' | '\u{2010}') { let mut p = Item::penalty(0.0, 50.0, true); p.hang = right_hang(g, sp); - p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, sp.kinsoku_priority != 3); + p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, !sp.push_out_only()); push_inword(&mut it, &mut ig, p, i + 1, sp); } else if matches!(g.ch, '\u{2013}' | '\u{2014}' | '/') || g.break_after.unwrap_or_else(|| cjk_break(g, &glyphs[i + 1], sp)) { let mut p = Item::penalty(0.0, 0.0, false); p.hang = right_hang(g, sp); - p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, sp.kinsoku_priority != 3); + p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, !sp.push_out_only()); push_inword(&mut it, &mut ig, p, i + 1, sp); } else if hyph_after[i] { let hw = hyphen_width(g, &mut hy_cache); @@ -474,7 +484,7 @@ fn items(glyphs: &[Glyph], hyph_after: &[bool], emergency_after: &[bool], sp: &S let mut p = Item::penalty(0.0, -INF, false); p.hang = if n > 0 { right_hang(&glyphs[n - 1], sp) } else { 0.0 }; if let Some(g) = glyphs.last() { - p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, sp.kinsoku_priority != 3); + p.edge_elastic = crate::mojikumi::end_elastic(g, sp.justify, !sp.push_out_only()); } it.push(p); ig.push(n); @@ -693,10 +703,18 @@ fn kp_pass( } } } - let preference = match sp.kinsoku_priority { - 1 if r > 0.0 => 4.0, - 2 if r < 0.0 => 4.0, - _ => 1.0, + // 禁則 priority (JIS X 4051): push-in-first rates breaks whose line would have to be + // stretched (r > 0: the next character is pushed out) worse than ones it can reach by + // compressing (追い込み); push-out-first the other way. Adjustment-amount mode and a + // paragraph without CJK text rate every candidate by its adjustment alone. + let preference = if !sp.kinsoku_cjk { + 1.0 + } else { + match sp.kinsoku_priority { + 1 if r > 0.0 => 4.0, + 2 if r < 0.0 => 4.0, + _ => 1.0, + } }; let bad = preference * 100.0 * r.abs().powi(3); let lp = 10.0 + bad; @@ -877,7 +895,7 @@ pub fn greedy( while start < n { let w = width(line).max(1.0); let mut x = (if sp.optical { -hang_left(&glyphs[start]) } else { 0.0 }) + glyphs[start].moji.start; - let mut shrink = crate::mojikumi::start_elastic(&glyphs[start], sp.justify, sp.kinsoku_priority != 3)[1]; + let mut shrink = crate::mojikumi::start_elastic(&glyphs[start], sp.justify, !sp.push_out_only())[1]; let mut last_natural: Option<(usize, bool)> = None; let mut last_ok: Option<(usize, bool)> = None; // (break position = end glyph, hyphen) let mut last_space: Option<(usize, f64)> = None; // (break position, line width there) @@ -904,9 +922,10 @@ pub fn greedy( } let hang_r = right_hang(g, sp); let adv = if g.ch == '\t' { tab(line, x, i) } else { g.adv }; - let end_shrink = crate::mojikumi::end_elastic(g, sp.justify, sp.kinsoku_priority != 3)[1]; + let end_shrink = crate::mojikumi::end_elastic(g, sp.justify, !sp.push_out_only())[1]; let available = shrink + sp.box_elastic(g).1.iter().sum::() + end_shrink; - if sp.kinsoku_priority == 2 + if sp.kinsoku_cjk + && sp.kinsoku_priority == 2 && x + adv - hang_r > w + FIT_EPS && let Some((end, hyphen)) = last_natural { diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 4a2c66397..67b2fb7ff 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -1067,7 +1067,7 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &C let cols_here = &cols[cur.fi]; let col = span_rect(cols_here, cols_here[cur.col.min(cols_here.len() - 1)], pp.span_columns); let col = SplitCfg::of(&pp).map_or(col, |c| c.sub_rect(col, 0)); - let spacing = spacing_for(&pp, base_chars.size); + let spacing = spacing_for(&pp, base_chars.size, sp.glyphs.iter().any(|g| is_cjk_char(g.ch))); let mut lines: Vec<(std::ops::Range, String)> = Vec::new(); for _ in 0..3 { // The same drop cap, spacing, hyphenation and breaker as the layout below. @@ -1220,7 +1220,7 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &C mojikumi::apply(&mut glyphs, &doc.styles, &pp.mojikumi); let hyph_after = hyphenation_points(&story.text, &glyphs, &pp, &hyph_exceptions, &foreign_ranges(doc, story, prange.clone(), &base_chars)); let base_size = base_chars.size; - let spacing = spacing_for(&pp, base_size); + let spacing = spacing_for(&pp, base_size, glyphs.iter().any(|g| is_cjk_char(g.ch))); // An empty paragraph takes its height from its paragraph mark's character format. let mark_chars = if glyphs.is_empty() { std::borrow::Cow::Owned(doc.styles.resolve_char(&base_chars, story.char_format_of(prange.start))) @@ -2147,8 +2147,9 @@ pub fn column_rule_rects(columns: &[Rect], lines: &[Line], opts: &TextFrameOptio out } -/// Breaker parameters from the paragraph's settings. -fn spacing_for(pp: &ParaProps, base_size: f64) -> Spacing { +/// Breaker parameters from the paragraph's settings; `cjk` says the paragraph has CJK text (so +/// its 禁則 priority applies). +fn spacing_for(pp: &ParaProps, base_size: f64, cjk: bool) -> Spacing { Spacing { justify: pp.align.is_justified(), word_min: pp.word_space_min, @@ -2168,15 +2169,39 @@ fn spacing_for(pp: &ParaProps, base_size: f64) -> Spacing { hyph_zone: if pp.align.is_justified() || !pp.composer.single_line() { 0.0 } else { pp.hyph_zone }, optical: pp.optical_margin, korean_char_breaks: pp.korean_char_breaks, + kinsoku_cjk: cjk, + // JIS X 4051 禁則処理: the empty value is InDesign's default and the UI's "Push In First", + // and 調整量優先 (adjustment amount) is the breaker's minimum-adjustment mode 0. kinsoku_priority: match pp.kinsoku_type.as_str() { - "KinsokuPushInFirst" => 1, + "" | "KinsokuPushInFirst" => 1, "KinsokuPushOutFirst" => 2, "KinsokuPushOutOnly" => 3, + "KinsokuPrioritizeAdjustmentAmount" => 0, _ => 0, }, } } +/// Is `c` CJK text (the scripts the 禁則 line-start/line-end rules are about): ideographs, kana, +/// CJK punctuation and full/half-width forms, bopomofo, Hangul. +fn is_cjk_char(c: char) -> bool { + matches!( + c as u32, + 0x1100..=0x11FF + | 0x2E80..=0x2FFF + | 0x3000..=0x30FF + | 0x3100..=0x318F + | 0x3190..=0x33FF + | 0x3400..=0x4DBF + | 0x4E00..=0x9FFF + | 0xA000..=0xA4CF + | 0xAC00..=0xD7AF + | 0xF900..=0xFAFF + | 0xFE30..=0xFE4F + | 0xFF00..=0xFFEF + ) +} + /// Desired word spacing, letter spacing and glyph scaling apply to every line (any alignment). fn apply_desired_spacing(glyphs: &mut [Glyph], pp: &ParaProps) { for i in 0..glyphs.len() { @@ -3351,7 +3376,7 @@ fn layout_line( } } } - if (justify_this || squeeze_last) && (extra >= 0.0 || sp.kinsoku_priority != 3) { + if (justify_this || squeeze_last) && (extra >= 0.0 || !sp.push_out_only()) { extra = mojikumi::distribute(line.get_mut(seg..).unwrap_or_default(), extra, add.get_mut(seg..).unwrap_or_default()); } if (justify_this || squeeze_last) && !spaces.is_empty() { diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index ed4c7c476..2486107e2 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -5247,6 +5247,112 @@ fn mojikumi_kinsoku_push_in_and_push_out_select_different_legal_breaks() { } } +/// A paragraph that can compress: the Mojikumi table gives its ideographs shrinkable space, so +/// a line ending before a 禁則 boundary can be pulled in (追い込み) or pushed out (追い出し). +fn kinsoku_push_pull_doc(kind: Option<&str>) -> (Document, StoryId) { + use designcraft_doc::cjk::{MojikumiAki, MojikumiTable}; + let (mut d, sid, _) = doc_with( + "甲乙丙丁戊己庚辛", + Rect::new(0.0, 0.0, 45.0, 300.0), + ParaAttrs { + composer: Some(Composer::SingleLine), + mojikumi: Some("MojikumiTable/Compress".into()), + kinsoku_type: kind.map(str::to_string), + ..Default::default() + }, + ); + Arc::make_mut(&mut d.styles).mojikumi_tables.push(MojikumiTable { + name: "Compress".into(), + based_on: "SimpChineseDefault".into(), + overrides: vec![MojikumiAki { + target_class: 12, + side_class: 12, + after: true, + minimum: 0.0, + desired: 1.0, + maximum: 2.0, + priority: 1, + ..Default::default() + }], + }); + (d, sid) +} + +fn first_line_end(cs: &ComposedStory) -> (usize, f64) { + let line = all_lines(cs)[0]; + (line.range.end, line.end_x) +} + +#[test] +fn default_kinsoku_type_composes_as_push_in_first() { + // The empty value is InDesign's default (and what the UI's "Push In First" stores): it must + // behave as push-in-first, not as the minimum-adjustment mode. + let (d, sid) = kinsoku_push_pull_doc(None); + let default = compose_story(&d, sid, &ComposeOptions::default()); + let (d, sid) = kinsoku_push_pull_doc(Some("KinsokuPushInFirst")); + let push_in = compose_story(&d, sid, &ComposeOptions::default()); + let (d, sid) = kinsoku_push_pull_doc(Some("KinsokuPushOutFirst")); + let push_out = compose_story(&d, sid, &ComposeOptions::default()); + assert_eq!(first_line_end(&default).0, first_line_end(&push_in).0); + assert!(first_line_end(&default).0 > first_line_end(&push_out).0, "{:?} vs {:?}", first_line_end(&default), first_line_end(&push_out)); +} + +#[test] +fn push_out_only_leaves_the_line_end_uncompressed() { + // Push-out-only turns the 追い込み compression off: the line cannot be squeezed to reach a + // break, so it ends earlier (and never past the measure). + let (d, sid) = kinsoku_push_pull_doc(None); + let push_in = compose_story(&d, sid, &ComposeOptions::default()); + let (d, sid) = kinsoku_push_pull_doc(Some("KinsokuPushOutOnly")); + let push_out_only = compose_story(&d, sid, &ComposeOptions::default()); + assert!(first_line_end(&push_out_only).0 <= first_line_end(&push_in).0); + for cs in [&push_in, &push_out_only] { + for line in all_lines(cs) { + assert!(line.end_x <= line.x1 + 0.01, "line end {} past the measure {}", line.end_x, line.x1); + } + } + // Push-out-only's first line is not compressed to the measure: it ends short of it. + let (_, short) = first_line_end(&push_out_only); + let line = all_lines(&push_out_only)[0]; + assert!(line.x1 - short > 0.5, "no compression: end {short} vs measure {}", line.x1); +} + +#[test] +fn kinsoku_priority_modes_map_to_breaker_policies() { + let mut pp = ParaProps::default(); + for (kind, priority) in [ + ("", 1u8), + ("KinsokuPushInFirst", 1), + ("KinsokuPushOutFirst", 2), + ("KinsokuPushOutOnly", 3), + ("KinsokuPrioritizeAdjustmentAmount", 0), + ("KinsokuSomethingElse", 0), + ] { + pp.kinsoku_type = kind.to_string(); + let sp = spacing_for(&pp, 12.0, true); + assert_eq!(sp.kinsoku_priority, priority, "{kind}"); + assert!(sp.kinsoku_cjk, "{kind}"); + assert!(!spacing_for(&pp, 12.0, false).kinsoku_cjk, "{kind}: Latin text is not biased"); + } +} + +#[test] +fn latin_paragraphs_are_not_biased_by_the_kinsoku_priority() { + // A justified Latin paragraph composes the same with push-in-first, push-out-first and + // minimum adjustment: the policy is about CJK 禁則, and a Latin paragraph has none. + let compose_with = |kind: &str| { + let (mut d, sid, _) = + doc_with(LOREM, Rect::new(0.0, 0.0, 200.0, 500.0), ParaAttrs { align: Some(Align::FullyJustified), ..Default::default() }); + d.story_mut(sid).unwrap().paras[0].para.kinsoku_type = Some(kind.to_string()); + compose_story(&d, sid, &ComposeOptions::default()) + }; + let ends = |cs: &ComposedStory| all_lines(cs).iter().map(|l| l.range.end).collect::>(); + let push_in = ends(&compose_with("")); + assert_eq!(ends(&compose_with("KinsokuPushInFirst")), push_in); + assert_eq!(ends(&compose_with("KinsokuPushOutFirst")), push_in); + assert_eq!(ends(&compose_with("KinsokuPrioritizeAdjustmentAmount")), push_in); +} + #[test] fn mojikumi_priority_and_elastic_line_start_are_used_in_placement() { use designcraft_doc::cjk::{MojikumiAki, MojikumiTable}; diff --git a/crates/doc/src/attrs.rs b/crates/doc/src/attrs.rs index 077637672..f47a5fbbd 100644 --- a/crates/doc/src/attrs.rs +++ b/crates/doc/src/attrs.rs @@ -1276,7 +1276,10 @@ attr_set! { kinsoku: Option = None => "deserialize_explicit_value", /// Preserved spacing-table reference; compatibility audit reports unsupported composition. mojikumi: String = String::new(), - /// Preserved priority policy; the current breaker does not implement these priorities. + /// JIS X 4051 禁則処理 type, applied by both composers to CJK text: empty (the default) + /// and `KinsokuPushInFirst` compose as push-in-first, `KinsokuPushOutFirst`, + /// `KinsokuPushOutOnly` and `KinsokuPrioritizeAdjustmentAmount` (minimum adjustment) as + /// their names say. kinsoku_type: String = String::new(), kinsoku_hang: crate::cjk::KinsokuHang = crate::cjk::KinsokuHang::None, bunri_kinshi: bool = false, diff --git a/docs/cjk-typography.md b/docs/cjk-typography.md index 49d350b88..e46fb3c51 100644 --- a/docs/cjk-typography.md +++ b/docs/cjk-typography.md @@ -1,6 +1,6 @@ # CJK import and composition -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-07 · **Change:** trivial (status line and revision history added; content unchanged in the 2026-10-10 review) · **Target:** Adobe InDesign 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (the JIS X 4051 禁則処理 push-in/push-out priority modes are applied by both composers over CJK text: the empty default and Push In First compose as push-in-first, Push Out First, Push Out Only and adjustment-amount as their names say; Latin paragraphs are not biased; preflight reports only unknown values) · **Target:** Adobe InDesign 2026 Task: CJK1. This is incremental support, not a claim of InDesign composition parity. @@ -27,6 +27,7 @@ invalidation. Font listing, replacement and preflight resolve component fonts. | Tsume | Compress nonnegative glyph sidebearings without scaling ink; full compression regression | | Jidori | Fixed group width with protected internal boundaries and justification advances; both composers tested | | Kinsoku sets | Custom character sets and independent common punctuation defaults for named sets; explicit disabling retained | +| Kinsoku priorities | The four JIS X 4051 禁則処理 types, applied by both composers to CJK text: push-in-first (the empty default, as in InDesign) and push-out-first weight the break candidates by the adjustment direction, push-out-only turns the end-of-line compression off, and adjustment-amount (調整量優先) takes the candidate with the smallest adjustment; Latin paragraphs are not biased. Regressions pin the breaks, the line-end fits and the mode mapping | | Bunri kinshi / rensuuji | Protect repeated dash/ellipsis pairs and numeric sequences | | Hanging punctuation | Regular/forced edge allowance integrated with line breaking and placement | | Ideographic spaces | Paragraph switch controls whether fullwidth spaces participate in word spacing | @@ -39,9 +40,14 @@ invalidation. Font listing, replacement and preflight resolve component fonts. - **Mojikumi**: definitions, base-set names, all override rows and paragraph references survive import/export. The numeric character-class spacing tables and their compression priorities are **not executed**. Preflight reports this explicitly. -- **Kinsoku push-in/push-out priorities**: retained, but not used in candidate - selection. Preflight reports this explicitly. Boundary prohibition alone is not - equivalent to implementing this priority policy. +- **Kinsoku priority policy** is applied as a line-cost weighting in the total-fit composer (and + as the single-line composer's early-break rule): push-in-first rates breaks that would have to + stretch the line worse than ones it can reach by compressing, push-out-first the other way, + push-out-only leaves no compression at the line end, and adjustment-amount rates every + candidate by its adjustment alone. It is a preference within the composer's other costs, not a + hard "always 追い込み before 追い出し" rule. Preflight reports only values it does not + know: the four JIS X 4051 modes are not reported as unapplied. Boundary prohibition, hanging + punctuation and the named sets are unchanged. - Named kinsoku defaults are clean-room common punctuation rules, not verified reproductions of every vendor preset. Explicit custom tables take precedence. - ICF alignment currently uses font ascender/descender metrics; exact ideographic @@ -69,5 +75,6 @@ are not committed as fixtures. | Date | Change | Summary | |---|---|---| +| 2026-10-22 | minor | 禁則処理 priority modes applied: the empty default and Push In First compose as push-in-first (as InDesign's Japanese default), Push Out First, Push Out Only and adjustment-amount (minimum adjustment) as their names say, for CJK text; Latin paragraphs are not biased; preflight reports only unknown values; breaks, line-end fits and the mode mapping regression-tested | | 2026-10-10 | trivial | Reviewed in the full re-measure; status line and this table added; summarized in [typography-parity.md](typography-parity.md) and [localization-parity.md](localization-parity.md) | | 2026-10-07 | major | Created: CJK1: IDML CJK import and composition | From 573ccb8377700275873732908d9dfa0cd089b36e Mon Sep 17 00:00:00 2001 From: midasdf Date: Thu, 22 Oct 2026 21:34:42 +0900 Subject: [PATCH 2/5] fix(compose): treat supplementary ideographs as CJK in the kinsoku gate is_cjk_char stopped at the BMP, while the breaker already classifies U+20000..=U+3FFFF as Han (breaker.rs, korean_letter's `han`). A paragraph made only of supplementary ideographs therefore passed cjk=false to spacing_for at both call sites, which disabled the explicit push-in / push-out cost preference and the push-out-only compression guard for text the breaker treats as Han. Match the breaker's Han range and add a regression that composes an Extension B paragraph, asserting the push-in and push-out-only line ends still differ, and pin the predicate for U+20000, U+2A6DF and U+3FFFF. The regression fails without the added range. --- crates/compose/src/lib.rs | 3 +++ crates/compose/src/tests.rs | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 67b2fb7ff..3e96d5da1 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -2199,6 +2199,9 @@ fn is_cjk_char(c: char) -> bool { | 0xF900..=0xFAFF | 0xFE30..=0xFE4F | 0xFF00..=0xFFEF + // Extension B 以降 (U+20000..)。breaker の Han の判定と同じ範囲にして、 + // 補助面だけの段落でも禁則の指定が効くようにする + | 0x20000..=0x3FFFF ) } diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 2486107e2..67200f365 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -5250,9 +5250,15 @@ fn mojikumi_kinsoku_push_in_and_push_out_select_different_legal_breaks() { /// A paragraph that can compress: the Mojikumi table gives its ideographs shrinkable space, so /// a line ending before a 禁則 boundary can be pulled in (追い込み) or pushed out (追い出し). fn kinsoku_push_pull_doc(kind: Option<&str>) -> (Document, StoryId) { + kinsoku_push_pull_doc_text("甲乙丙丁戊己庚辛", kind) +} + +/// Same paragraph with a different body: used for the supplementary-plane ideographs, whose +/// CJK classification must match the breaker's Han set. +fn kinsoku_push_pull_doc_text(text: &str, kind: Option<&str>) -> (Document, StoryId) { use designcraft_doc::cjk::{MojikumiAki, MojikumiTable}; let (mut d, sid, _) = doc_with( - "甲乙丙丁戊己庚辛", + text, Rect::new(0.0, 0.0, 45.0, 300.0), ParaAttrs { composer: Some(Composer::SingleLine), @@ -5317,6 +5323,28 @@ fn push_out_only_leaves_the_line_end_uncompressed() { assert!(line.x1 - short > 0.5, "no compression: end {short} vs measure {}", line.x1); } +#[test] +fn supplementary_ideograph_paragraph_keeps_the_kinsoku_gate() { + // Extension B 以降の漢字 (U+20000..) は breaker では Han として扱われる。段落全体の CJK 判定 + // (is_cjk_char) がそこを落とすと、補助面だけの段落で禁則の指定が効かなくなる。 + // 補助面だけの本文でも、追い込みと追い出しで行末が変わる (指定が効いている) こと。 + let first_end = |text: &str, kind: Option<&str>| { + let (d, sid) = kinsoku_push_pull_doc_text(text, kind); + first_line_end(&compose_story(&d, sid, &ComposeOptions::default())).0 + }; + let bmp = "甲乙丙丁戊己庚辛"; + let sup = "\u{20000}\u{20001}\u{20002}\u{20003}\u{20004}\u{20005}\u{20006}\u{20007}"; + // 対照: BMP の漢字だけの段落では、追い込みと追い出しで行末が変わる + assert_ne!(first_end(bmp, None), first_end(bmp, Some("KinsokuPushOutOnly")), "BMP の対照で禁則の指定が効いていない"); + // 補助面だけの段落でも同じように効く (判定から漏れると、どちらも同じ行末になる) + assert_ne!(first_end(sup, None), first_end(sup, Some("KinsokuPushOutOnly")), "補助面だけの段落で禁則の指定が効いていない"); + // 判定そのもの (Extension B の最初と最後、Ext G の終わり) + assert!(is_cjk_char('\u{20000}')); + assert!(is_cjk_char('\u{2A6DF}')); + assert!(is_cjk_char('\u{3FFFF}')); + assert!(!is_cjk_char('A')); +} + #[test] fn kinsoku_priority_modes_map_to_breaker_policies() { let mut pp = ParaProps::default(); From 4e037320b380d5e40dc353e1e7ac2fbc82ff3630 Mon Sep 17 00:00:00 2001 From: midasdf Date: Fri, 23 Oct 2026 00:09:43 +0900 Subject: [PATCH 3/5] fix(compose): classify the paragraph's script before its drop cap and label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 禁則 gate read the CJK flag from sp.glyphs after split_drop_cap had removed the drop cap and prepend_label had added the list number. A paragraph whose only CJK character was a drop cap lost the push-in / push-out policy; a Japanese list label gave it to an English paragraph. Classify the shaped paragraph once before either change and reuse the flag in the nested-line-style pass and the final breaker. Tests: shape a paragraph with a CJK drop cap (counted) and a Latin paragraph with a generated Japanese label (not counted), pinning the glyph lists the gate sees. --- crates/compose/src/lib.rs | 15 +++++++++-- crates/compose/src/tests.rs | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index d7ad7a864..34ef24119 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -1037,6 +1037,10 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &C &[], (drop_end, &pp.drop_cap_style), ); + // The paragraph's script decides whether its 禁則 priority applies. Classify the shaped + // glyphs before split_drop_cap removes the drop cap and prepend_label adds the list + // label: a CJK drop cap is part of the paragraph, a generated label is not. + let cjk = paragraph_is_cjk(&sp.glyphs); // An empty paragraph has no glyphs of its own, so its only addressable character is its // hidden paragraph mark (the `\n` just past `prange.end`). A leading/size override applied // there (e.g. selecting the pilcrow to adjust line height) still needs to set the line's @@ -1067,7 +1071,7 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &C let cols_here = &cols[cur.fi]; let col = span_rect(cols_here, cols_here[cur.col.min(cols_here.len() - 1)], pp.span_columns); let col = SplitCfg::of(&pp).map_or(col, |c| c.sub_rect(col, 0)); - let spacing = spacing_for(&pp, base_chars.size, sp.glyphs.iter().any(|g| is_cjk_char(g.ch))); + let spacing = spacing_for(&pp, base_chars.size, cjk); let mut lines: Vec<(std::ops::Range, String)> = Vec::new(); for _ in 0..3 { // The same drop cap, spacing, hyphenation and breaker as the layout below. @@ -1220,7 +1224,7 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &C mojikumi::apply(&mut glyphs, &doc.styles, &pp.mojikumi); let hyph_after = hyphenation_points(&story.text, &glyphs, &pp, &hyph_exceptions, &foreign_ranges(doc, story, prange.clone(), &base_chars)); let base_size = base_chars.size; - let spacing = spacing_for(&pp, base_size, glyphs.iter().any(|g| is_cjk_char(g.ch))); + let spacing = spacing_for(&pp, base_size, cjk); // An empty paragraph takes its height from its paragraph mark's character format. let mark_chars = if glyphs.is_empty() { std::borrow::Cow::Owned(doc.styles.resolve_char(&base_chars, story.char_format_of(prange.start))) @@ -2183,6 +2187,13 @@ fn spacing_for(pp: &ParaProps, base_size: f64, cjk: bool) -> Spacing { } } +/// Whether the paragraph's own shaped glyphs contain CJK text, the gate for its 禁則 priority. +/// Called before `split_drop_cap` and `prepend_label`, so a drop cap counts and generated list +/// and story labels do not. +fn paragraph_is_cjk(glyphs: &[Glyph]) -> bool { + glyphs.iter().any(|g| is_cjk_char(g.ch)) +} + /// Is `c` CJK text (the scripts the 禁則 line-start/line-end rules are about): ideographs, kana, /// CJK punctuation and full/half-width forms, bopomofo, Hangul. fn is_cjk_char(c: char) -> bool { diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 9408a3909..009aab73d 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -5345,6 +5345,59 @@ fn supplementary_ideograph_paragraph_keeps_the_kinsoku_gate() { assert!(!is_cjk_char('A')); } +/// Shape `text` as a one-paragraph story with the default font and styles: the glyph list the +/// composition classifies before `split_drop_cap` and `prepend_label`. +fn shape_for_script_test(text: &str) -> Vec { + let db = designcraft_fonts::FontDb::global().scoped(0); + let mut styles = Vec::new(); + let mut missing = std::collections::HashMap::new(); + let mut table = shape::StyleTable { styles: &mut styles, missing: &mut missing }; + let mut story = Story::new(StoryId(0)); + story.insert(0, text); + shape::shape_para( + &db, + &designcraft_doc::Styles::default(), + &story, + 0, + 0..text.len(), + &designcraft_doc::CharProps::default(), + shape::TypeEnv { auto_leading: 1.2, adv: Default::default(), glyph_fallback: true }, + &SubstCtx::default(), + &mut table, + &[], + &[], + &[], + (0, ""), + ) + .glyphs +} + +#[test] +fn paragraph_script_counts_a_drop_cap_but_not_a_generated_label() { + // The 禁則 gate reads the paragraph's own shaped glyphs. The drop cap has not been split off + // yet, so a CJK one still makes the paragraph CJK. + assert!(paragraph_is_cjk(&shape_for_script_test("漢abc"))); + // A generated list label is prepended after the gate, so it is not part of the paragraph. + let mut glyphs = shape_for_script_test("abc"); + assert!(!paragraph_is_cjk(&glyphs)); + let db = designcraft_fonts::FontDb::global().scoped(0); + let mut styles = Vec::new(); + let mut missing = std::collections::HashMap::new(); + let mut table = shape::StyleTable { styles: &mut styles, missing: &mut missing }; + let n = prepend_label( + &db, + &mut glyphs, + "第1章", + 0, + &designcraft_doc::CharProps::default(), + shape::TypeEnv { auto_leading: 1.2, adv: Default::default(), glyph_fallback: true }, + &mut table, + ); + assert!(n > 0); + // The label's glyphs are CJK, so a gate computed after prepend_label would flip the answer. + assert!(glyphs.iter().take(n).any(|g| is_cjk_char(g.ch))); +} + #[test] fn kinsoku_priority_modes_map_to_breaker_policies() { let mut pp = ParaProps::default(); From a28917ef3c4107e360e4c7657d734c44ca3c4d0d Mon Sep 17 00:00:00 2001 From: midasdf Date: Fri, 23 Oct 2026 01:37:14 +0900 Subject: [PATCH 4/5] fix(compose): classify a text variable's replacement as CJK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shape_segment keeps the source marker in Glyph::ch when it shapes a text variable, page number or cross-reference replacement, so a paragraph that shows CJK only through one of them was classified as non-CJK and lost its 禁則 priority. Inspect generated_text too: the paragraph is CJK when either the source character or any character of the replacement text is. Tests: designcraft-compose 367 passed, 1 ignored; the new regression (a variable marker plus Latin text) fails without the classifier change. cargo fmt --all -- --check passed. --- crates/compose/src/lib.rs | 5 +++-- crates/compose/src/tests.rs | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 34ef24119..e5e2eb208 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -2189,9 +2189,10 @@ fn spacing_for(pp: &ParaProps, base_size: f64, cjk: bool) -> Spacing { /// Whether the paragraph's own shaped glyphs contain CJK text, the gate for its 禁則 priority. /// Called before `split_drop_cap` and `prepend_label`, so a drop cap counts and generated list -/// and story labels do not. +/// and story labels do not. A text variable or page number keeps its marker in [`Glyph::ch`], so +/// its replacement text is what the paragraph shows; inspect that too. fn paragraph_is_cjk(glyphs: &[Glyph]) -> bool { - glyphs.iter().any(|g| is_cjk_char(g.ch)) + glyphs.iter().any(|g| is_cjk_char(g.ch) || g.generated_text.as_deref().is_some_and(|text| text.chars().any(is_cjk_char))) } /// Is `c` CJK text (the scripts the 禁則 line-start/line-end rules are about): ideographs, kana, diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 009aab73d..b3881ba75 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -5348,6 +5348,11 @@ fn supplementary_ideograph_paragraph_keeps_the_kinsoku_gate() { /// Shape `text` as a one-paragraph story with the default font and styles: the glyph list the /// composition classifies before `split_drop_cap` and `prepend_label`. fn shape_for_script_test(text: &str) -> Vec { + shape_for_script_test_with(text, &SubstCtx::default()) +} + +/// Same, with text variables resolved through `sub`. +fn shape_for_script_test_with(text: &str, sub: &SubstCtx) -> Vec { let db = designcraft_fonts::FontDb::global().scoped(0); let mut styles = Vec::new(); let mut missing = std::collections::HashMap::new(); @@ -5362,7 +5367,7 @@ fn shape_for_script_test(text: &str) -> Vec { 0..text.len(), &designcraft_doc::CharProps::default(), shape::TypeEnv { auto_leading: 1.2, adv: Default::default(), glyph_fallback: true }, - &SubstCtx::default(), + sub, &mut table, &[], &[], @@ -5398,6 +5403,19 @@ fn paragraph_script_counts_a_drop_cap_but_not_a_generated_label() { assert!(glyphs.iter().take(n).any(|g| is_cjk_char(g.ch))); } +#[test] +fn paragraph_script_reads_a_text_variable_replacement() { + // A text variable's glyphs keep the source marker in `ch`; the paragraph shows the replacement, + // so a CJK replacement makes it CJK text even though no source character is. + let marker = designcraft_doc::vars::var_char(0).expect("variable 0"); + let text = format!("{marker}abc"); + let sub = SubstCtx { vars: Arc::new(vec!["漢字".into()]), ..Default::default() }; + let glyphs = shape_for_script_test_with(&text, &sub); + assert!(!glyphs.iter().any(|g| is_cjk_char(g.ch)), "the source is only the marker and Latin text"); + assert!(glyphs.iter().any(|g| g.generated_text.as_deref().is_some_and(|t| t.chars().any(is_cjk_char)))); + assert!(paragraph_is_cjk(&glyphs), "the CJK replacement is the paragraph's text"); +} + #[test] fn kinsoku_priority_modes_map_to_breaker_policies() { let mut pp = ParaProps::default(); From 4536e5d4cfc4397ea557b12b313b8f3bec3bea74 Mon Sep 17 00:00:00 2001 From: midasdf Date: Wed, 4 Nov 2026 08:46:04 +0900 Subject: [PATCH 5/5] Compose: match the CJK gate's Hangul set to the breaker's; drop the ROADMAP hunk --- ROADMAP.md | 3 +-- crates/compose/src/breaker.rs | 13 ++++++++---- crates/compose/src/lib.rs | 37 ++++++++++++++++++----------------- crates/compose/src/tests.rs | 10 ++++++++++ 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 883ca04f6..d88e8fc36 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,7 +4,7 @@ - 2026-10-23: placed-artwork layer options survive IDML and native round trips per placement, independently of shared assets. Unsupported visibility overrides are explicit import/preflight/PDF warnings; format 4 prevents older native readers from silently discarding them. Rendering parity is still open; see [graphic-layer-options.md](docs/graphic-layer-options.md). - FID1: PDF export normalizes mixed emitted gradient color spaces to RGB with an explicit warning; homogeneous device-space gradients retain their components. Linear/radial, midpoint, archival and print policies have synthetic regression coverage. -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-01 · **Change:** minor (placed graphic layer-option preservation and explicit rendering warnings; previously minor, Compose: the JIS X 4051 禁則処理 push-in/push-out priorities are applied by both composers over CJK text — the empty default and Push In First compose as push-in-first as in InDesign's Japanese default, Push Out First, Push Out Only and adjustment-amount as their names say; Latin paragraphs are not biased; preflight reports only unknown values; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text) · **Target:** Adobe InDesign 2026 +> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-01 · **Change:** minor (placed graphic layer-option preservation and explicit rendering warnings; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text) · **Target:** Adobe InDesign 2026 - AR1.1: Kashida justification tests verify space fallback without Tatweel fonts using an isolated font database, while retaining elongation assertions when fonts support it. - AR1: Arabic IDML controls now retain character direction, kashida switches, diacritic offsets/forms, paragraph policy values and independent story/table directions. Shaping preserves joining context and script/language selection; paragraph-level bidi, contextual digit conversion, mark-safe elongation, RTL columns/tables and physical column insertion have regression coverage. Vendor-specific justification and diacritic presets remain explicit preflight warnings; see docs/arabic-typography.md. @@ -446,7 +446,6 @@ Newest first. - **2026-10-23** · File › File Info… edits the document's Document Title, Author, Description, Keywords, Copyright Notice and Copyright Info URL (`file.info`), and the document saves them. PDF export (PDF/X-4 and Print Booklet included) writes the title, author, description and keywords into the PDF's document information and XMP. EPUB export takes the title and author from File Info, and HTML export takes the title. A title or author given to the export replaces File Info's, and an empty Document Title leaves the document's name as the title. No readiness percentage change. - **2026-10-23** · Save and export dialogs (Save As, Save a Copy, Export PDF and the other exports, Package, libraries and books) start in the active document's folder once it has been saved, and for a document never saved in the folder of the last file saved or exported, remembered across sessions (#1653). A folder deleted since falls back to the system's choice. No readiness percentage change. - **2026-10-22** · Autoflow (Shift-click with the loaded text cursor, autoflow on Place, `text.thread {autoflow}`) fills the pages that follow before it adds any, as InDesign does: one frame per column on each following page, whatever else the page holds, then new pages at the end of the document. It inserted pages right after the story's last frame, in front of the document's own pages. Frames it set past the end of the text go again; a page the document had stays, and a page autoflow added only for such a frame goes with it. Smart Text Reflow of the primary text frame is unchanged. No readiness percentage change. -- **2026-10-22** · Compose: the JIS X 4051 禁則処理 push-in/push-out priorities are applied, not just preserved. Both composers bias the break candidates by the selected type over CJK text: push-in-first (the empty default and the UI's Push In First, as in InDesign's Japanese default) rates breaks that would stretch the line worse than ones it can reach by compressing, push-out-first the other way, push-out-only leaves no compression at the line end, and adjustment-amount takes the smallest adjustment. Latin paragraphs are not biased by the default. New regressions pin the default = push-in-first, the push-out-only line-end fits, the mode mapping and the Latin non-bias; `docs/cjk-typography.md` now lists the modes as implemented and preflight reports only unknown values. No readiness percentage change. - **2026-10-18** · German text hyphenates using the MIT-licensed 2006 reform patterns (`hyph-de-1996.tex`) through `hypher`. Explicit 2006 names and plain/2006 locale codes reach both composers; traditional and unknown spelling variants stay unhyphenated. Tests cover this distinction, umlauts, ß, compounds, reformed ck/st breaks and paragraph limits. Six of InDesign's ~40 hyphenation languages. No readiness percentage change. - **2026-10-16** · Edit › Keyboard Shortcuts imports a set saved by InDesign's Show Set (.txt, Windows or Mac key names, UTF-8 or UTF-16): matched commands take its Default shortcuts or lose theirs, other commands give up keys it takes, and a report lists what it changed and the items it could not match (`window.importShortcuts`, #1180). Tool keys stay fixed. No readiness percentage change. - **2026-10-23** · Translations: a missing string shows in English and fails no test; `cargo xtask i18n-report`, run by `cargo xtask ci`, prints the missing strings per language. Tests keep duplicate-key and placeholder checks and the language mechanics (lookup, context captions, plural captions, right-to-left). No readiness percentage change. diff --git a/crates/compose/src/breaker.rs b/crates/compose/src/breaker.rs index 254b2c6b0..2196de58b 100644 --- a/crates/compose/src/breaker.rs +++ b/crates/compose/src/breaker.rs @@ -286,13 +286,18 @@ fn kinsoku_allows(a: char, b: char) -> bool { !NO_START.contains(b) && !NO_END.contains(a) } +/// Hangul: Jamo, compatibility Jamo, the syllables, and Jamo Extended-A/B. Shared with the +/// paragraph's CJK gate so the two classifications cannot drift apart. +pub(crate) fn is_hangul(c: char) -> bool { + matches!(c as u32, 0x1100..=0x11FF | 0x3130..=0x318F | 0xA960..=0xA97F | 0xAC00..=0xD7FF) +} + /// Hangul, and Han ideographs (hanja) in Korean text: Korean is set word by word (KLREQ), so /// these letters break like Western ones, at spaces. fn korean_letter(g: &Glyph) -> bool { - let c = g.ch as u32; - let hangul = matches!(c, 0x1100..=0x11FF | 0x3130..=0x318F | 0xA960..=0xA97F | 0xAC00..=0xD7FF); - let han = matches!(c, 0x3400..=0x4DBF | 0x4E00..=0x9FFF | 0xF900..=0xFAFF | 0x20000..=0x3FFFF); - hangul || (han && g.lang.is_some_and(|t| designcraft_doc::language_subtag(t) == "ko")) + let c = g.ch; + let han = matches!(c as u32, 0x3400..=0x4DBF | 0x4E00..=0x9FFF | 0xF900..=0xFAFF | 0x20000..=0x3FFFF); + is_hangul(c) || (han && g.lang.is_some_and(|t| designcraft_doc::language_subtag(t) == "ko")) } /// Is the place between glyphs `a` and `b` one where CJK text may break (next to an ideograph, kana diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index e9e82add2..3fe58a550 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -3407,24 +3407,25 @@ fn paragraph_is_cjk(glyphs: &[Glyph]) -> bool { /// Is `c` CJK text (the scripts the 禁則 line-start/line-end rules are about): ideographs, kana, /// CJK punctuation and full/half-width forms, bopomofo, Hangul. fn is_cjk_char(c: char) -> bool { - matches!( - c as u32, - 0x1100..=0x11FF - | 0x2E80..=0x2FFF - | 0x3000..=0x30FF - | 0x3100..=0x318F - | 0x3190..=0x33FF - | 0x3400..=0x4DBF - | 0x4E00..=0x9FFF - | 0xA000..=0xA4CF - | 0xAC00..=0xD7AF - | 0xF900..=0xFAFF - | 0xFE30..=0xFE4F - | 0xFF00..=0xFFEF - // Extension B 以降 (U+20000..)。breaker の Han の判定と同じ範囲にして、 - // 補助面だけの段落でも禁則の指定が効くようにする - | 0x20000..=0x3FFFF - ) + // Hangul comes from the breaker's classification (Jamo including Extended-A/B, syllables), + // so the two sets agree. Bopomofo is 0x3100..=0x312F; 0x3130..=0x318F is Hangul. + breaker::is_hangul(c) + || matches!( + c as u32, + 0x2E80..=0x2FFF + | 0x3000..=0x30FF + | 0x3100..=0x312F + | 0x3190..=0x33FF + | 0x3400..=0x4DBF + | 0x4E00..=0x9FFF + | 0xA000..=0xA4CF + | 0xF900..=0xFAFF + | 0xFE30..=0xFE4F + | 0xFF00..=0xFFEF + // Extension B and later (U+20000..): the same range as the breaker's Han check, + // so the kinsoku settings apply to a paragraph of supplementary-plane text alone. + | 0x20000..=0x3FFFF + ) } /// Desired word spacing, letter spacing and glyph scaling apply to every line (any alignment). diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 156c37a75..1e8d77887 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -5888,6 +5888,16 @@ fn supplementary_ideograph_paragraph_keeps_the_kinsoku_gate() { assert!(!is_cjk_char('A')); } +#[test] +fn hangul_jamo_extended_blocks_count_as_cjk() { + // `is_cjk_char` takes Hangul from the breaker's classification, so the syllables and the + // Jamo Extended-A/B blocks count as well: a Hangul-only paragraph keeps its 禁則 priority. + for c in ['\u{A960}', '\u{A97F}', '\u{D7B0}', '\u{D7FF}'] { + assert!(is_cjk_char(c), "U+{:04X} is Hangul", c as u32); + } + assert!(is_cjk_char('\u{3105}'), "bopomofo is still CJK"); +} + /// Shape `text` as a one-paragraph story with the default font and styles: the glyph list the /// composition classifies before `split_drop_cap` and `prepend_label`. fn shape_for_script_test(text: &str) -> Vec {