Skip to content

DOCX: a cell paragraph with w:spacing w:line gets no fixed line box, so 1.5-line cell text advances 18% short #727

Description

@developer0hye

Summary

word_cell_line_box (crates/office2pdf/src/render/typst_gen_text.rs) bails whenever a
cell paragraph carries style.line_spacing or style.line_box, so a table-cell paragraph
with w:spacing w:line gets no fixed line box at all — it falls back to Typst's default
line advance instead of Word's multiple × line-height box. The declared multiple is
therefore never applied inside cells, and the paragraph advance comes out short.

This is independent of #625 (which fixed the default block spacing leaking between
stacked cell paragraphs): both before and after that fix, a line-spaced cell paragraph
advances the same short distance.

Measured

Probe derived from tests/golden_mocks/business/sources/docx/02_contract_ko.docx by adding
<w:spacing w:line="360" w:lineRule="auto" w:after="30"/> to the signature-cell paragraphs
(1.5-line spacing, 9.5pt Malgun Gothic — a routine Korean-contract shape):

Word model office2pdf
advance across the paragraph break 26.2pt (1.5 × 16.42pt EA line + 1.5pt w:after) 21.53pt
deficit −4.7pt (−18%)

The same 21.53pt is produced by main and by the #625 branch, confirming the defect is the
missing fixed line box rather than the block-spacing model.

Reproduction

# add w:spacing w:line="360" w:lineRule="auto" to a multi-paragraph table cell
cargo run --release -p office2pdf-cli -- <probe>.docx -o out.pdf
mutool draw -F trace -o - out.pdf 1   # cell paragraph advance 21.53pt; Word 26.2pt

Expected

A cell paragraph with w:spacing w:line gets a fixed line box of the declared multiple of
the East Asian/Latin line height, exactly as body-flow paragraphs do.

Actual

word_cell_line_box returns None for those paragraphs, so no fixed box is emitted and the
advance falls back to the engine default — 18% short on a 1.5-line Korean cell.

Related: #625 #618

Found in: the #625 fix-PR adversarial review (one-factor probe over 02_contract_ko, 2026-07-31).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions