Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge #129: Fix IDML Mojikumi spacing, kinsoku composition, and nested text preflight

aionggee24cb949b1f
diff --cc ROADMAP.md
index ac8472d57,eef038e6a..fe15cfc14
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -1,7 -1,16 +1,18 @@@
# DesignCraft roadmap
+- 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.
+
+ - CJK-MOJI8: preserve shaped narrow punctuation when tracking changes its advance.
+ - CJK-MOJI7: prevent numeric coercion in Mojikumi import, preserve finite unsupported rules, and check nested note/cell rules in preflight.
+ - CJK-MOJI6: apply spacing at shaped-cluster boundaries without moving attached marks.
+ - CJK-MOJI5: share equal-priority boundary spacing and honor discrete compression endpoints, including leading-only ragged-line fitting.
+
+ - CJK-MOJI3: use the composition rule resolver in preflight, report unknown Mojikumi presets and retain regression coverage for supported and unsupported settings.
+
+ - CJK-MOJI2: share Mojikumi pair and line-edge metrics between breaking and placement; honor spacing bounds, compression priorities, explicit aki and kinsoku policies.
+
+ - CJK-MOJI1: resolve Chinese and half-em Mojikumi presets and directional custom overrides; preserve IDML table references independently of display names.
+
- FONT7: replacement recommendations check the characters actually used; placeholder LastResort fonts and glyph-zero mappings cannot masquerade as glyph coverage or suppress missing-glyph diagnostics.
- FONT6: localized and legacy family/style names share canonical resolution across shaping, inventory and replacement. Known compatible and script-based substitutes retain missing status; Find Font shows the resolved face and offers it as the replacement, while preflight reports unavailable styles.
diff --cc crates/compose/src/lib.rs
index 861272cfc,4b9e6f28f..a6365309a
--- a/crates/compose/src/lib.rs
+++ b/crates/compose/src/lib.rs
@@@ -648,18 -613,11 +649,19 @@@ fn compose_with_db(doc: &Document, stor
let spacing = spacing_for(&pp, base_chars.size);
let mut lines: Vec<(std::ops::Range<usize>, String)> = Vec::new();
for _ in 0..3 {
- let width = |j: usize| (col.width() - pp.left_indent - pp.right_indent - if j == 0 { pp.first_line_indent } else { 0.0 }).max(1.0);
- // The same spacing, hyphenation and breaker as the layout below.
+ // The same drop cap, spacing, hyphenation and breaker as the layout below.
let mut gl = sp.glyphs.clone();
+ let dc = split_drop_cap(db, &mut gl, drop_end, pp.drop_cap_lines, base_leading, base_cap, drop_grid, drop_align);
+ let width = |j: usize| {
+ let ind = match &dc {
+ Some(dc) if j < dc.lines => dc.indent(),
+ _ if j == 0 => pp.first_line_indent,
+ _ => 0.0,
+ };
+ (col.width() - pp.left_indent - pp.right_indent - ind).max(1.0)
+ };
apply_desired_spacing(&mut gl, &pp);
+ mojikumi::apply(&mut gl, &doc.styles, &pp.mojikumi);
let hy = hyphenation_points(&story.text, &gl, &pp, &hyph_exceptions, &foreign_ranges(doc, story, prange.clone(), &base_chars));
let breaks = if pp.composer == Composer::SingleLine || gl.iter().any(|g| g.ch == '\t') || gl.len() > 4000 {
breaker::greedy(&gl, &hy, &spacing, &width)
@@@ -752,19 -694,14 +754,20 @@@
);
bidi::resolve_mirroring(&mut glyphs, &bidi_info);
apply_desired_spacing(&mut glyphs, &pp);
+ 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 base_leading = match base_chars.leading {
- designcraft_doc::Leading::Auto => base_size * pp.auto_leading,
+ let spacing = spacing_for(&pp, base_size);
+ // 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)))
+ } else {
+ std::borrow::Cow::Borrowed(&base_chars)
+ };
+ let mark_leading = match mark_chars.leading {
+ designcraft_doc::Leading::Auto => mark_chars.size * pp.auto_leading,
designcraft_doc::Leading::Points(v) => v,
};
- let spacing = spacing_for(&pp, base_size);
// Paragraph start options.
if force_col[pi] {
cur.next_column(&cols);