mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-16 07:12:43 +00:00
feat(compose): apply 禁則 push-in/push-out priorities (JIS X 4051)
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.
This commit is contained in:
1 parent
3ce3a24f08
commit
d4c28a246d
6 files changed
+191
-29
No files matched your search
+3
-1
@@ -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.
|
||||
|
||||
@@ -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::<f64>() + 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
|
||||
{
|
||||
|
||||
@@ -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<usize>, 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() {
|
||||
|
||||
@@ -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::<Vec<_>>();
|
||||
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};
|
||||
|
||||
@@ -1276,7 +1276,10 @@ attr_set! {
|
||||
kinsoku: Option<crate::cjk::Kinsoku> = 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,
|
||||
|
||||
+11
-4
@@ -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 |
|
||||
Reference in new issue
Block a user