Skip to content

fix: resolve DOCX table style cell margins - #2044

Merged
developer0hye merged 3 commits into
mainfrom
fix/issue-1884-table-style-margins
Oct 10, 2026
Merged

developer0hye merged 3 commits into
mainfrom
fix/issue-1884-table-style-margins

Conversation

@developer0hye

@developer0hye developer0hye commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

File submission policy

  • Any submitted sample files or attachments satisfy the submission policy, or none are submitted.

Summary

Resolved DOCX table-style cell margins are now complete. A style named “Normal Table” uses Word’s latent 0/108/0/108 twip margins when its own margin declaration is absent or partial. Other resolved styles preserve declared sides and inherit unspecified sides from the default table style, or use zero when that default supplies no value. Direct table and per-cell margin precedence remains unchanged.

Four generated DOCX probes cover absent and one-sided style margins under both “Normal Table” and “Grid Probe” names. The style IDs deliberately differ from the names so the regression verifies Word’s name-based built-in resolution.

Related issue

Related: #1884
Related: #1874

Testing

  • cargo fmt --all -- --check and git diff --check passed.
  • cargo test --locked --workspace --profile ci passed after integrating main 71e10311; a fresh --doc run also passed after the separate CLI build.
  • cargo clippy --locked --workspace --all-targets -- -D warnings passed.
  • Four fresh native Word probes passed layout, normalized text and strict cluster audits.

Visual impact

  • No rendered PDF change
  • Rendered PDF change or visual evidence added

Visual audit

  • Issue: DOCX: a default table style that states no or partial w:tblCellMar still falls through to Typst's 5pt cell inset #1884
  • Fixture: tests/fixtures/docx/issue-1884-normal-absent.docx, tests/fixtures/docx/issue-1884-normal-partial.docx, tests/fixtures/docx/issue-1884-custom-absent.docx, tests/fixtures/docx/issue-1884-custom-partial.docx
  • Page(s): 1-4
  • Renderer and DPI: pdftoppm, 150 DPI
  • Evidence mode: fix
  • Layout audit report: assets/bugfixes/issue-1884/layout-audit.json
  • Render cluster reports: assets/bugfixes/issue-1884/render-clusters-page-1.json, assets/bugfixes/issue-1884/render-clusters-page-2.json, assets/bugfixes/issue-1884/render-clusters-page-3.json, assets/bugfixes/issue-1884/render-clusters-page-4.json
  • Reference exporter differences: None
  • Fine-detail threshold: 1pt
  • Layout audit page count: Pass
  • Layout audit text flow: Pass
  • Layout audit visible fills: Pass
  • Layout audit rectangle geometry: Pass
  • Layout audit large shifts: Pass
  • Layout audit fine shifts: Pass
  • New follow-up issues found in this audit: None
  • Model vision findings: Full pages, diffs and matched content crops show both cells and the following paragraph in the native positions. The custom partial style's explicit top inset remains visible; absent sides no longer introduce Typst's unrelated 5pt inset. No missing text, wrap, clipping, overlap, rotation, fill, rule, or emphasis discrepancy was observed. These probes contain no painted borders, hairlines, pictures, bold, italic, or underlined runs. Sub-material cell-text anchor offsets are at most 0.22pt horizontally and 0.167pt vertically, tracked in Tracker: sub-materiality visual deviations (revisit in bulk) #1874; they are not claimed to be rasterization.
  • GT: assets/bugfixes/issue-1884/gt.jpg
  • Before: assets/bugfixes/issue-1884/before.jpg
  • After: assets/bugfixes/issue-1884/after.jpg
  • Native: None

Visual comparison

GT Before After
GT Before After

Required inspection

  • Rendered all evidence at 150 DPI or higher
  • Stored progressive JPEG quality 86 assets with metadata stripped
  • Used Codex/Claude vision to inspect the full GT/output pages, diff, and matched crops
  • Inspected matched region crops at full resolution
  • Ran compare_layout.py --audit --fine-shift PT and dispositioned every fine/large text-instance shift, rectangle geometry deviation, painted-text visibility mismatch, and visible-fill occlusion
  • Ran compare_render.py --cluster-report PATH --strict-clusters and dispositioned every material 5% fuzz diff cluster by explicit ID
  • Inventoried hairlines and border dash styles
  • Inventoried font weight, italic, and underline emphasis

Deviation audit

Check Result
Page count/order Matches GT
Element presence Matches GT — both cells and following paragraph are present in every probe.
Position/size Remaining: #1874 — text anchors differ by at most 0.22pt horizontally and 0.167pt vertically; the extra 5pt inset is fixed.
Rotation/flip No deviation observed
Fill Matches GT
Stroke/border Matches GT
Shape outline geometry Matches GT
Text content Matches GT
Font family/weight/style Matches GT
Text color Matches GT
Alignment Remaining: #1874 — text anchors differ by at most 0.22pt horizontally and 0.167pt vertically; the extra 5pt inset is fixed.
Line/paragraph spacing Remaining: #1874 — text anchors differ by at most 0.22pt horizontally and 0.167pt vertically; the extra 5pt inset is fixed.
Clipping/overflow No deviation observed

Checklist

  • Commits include a Signed-off-by line
  • PR scope contains one root cause
  • Remaining converter or harness deviations each reference an open issue

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye
developer0hye marked this pull request as ready for review October 10, 2026 15:50
@developer0hye
developer0hye merged commit 9d5dd26 into main Oct 10, 2026
26 of 27 checks passed
@developer0hye
developer0hye deleted the fix/issue-1884-table-style-margins branch October 10, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant