Summary
Consecutive single-line DOCX paragraphs set in Courier New render 2.86 pt tighter per line than Word, about a 28% shortfall. The gap accumulates down the page: by the last body line of the technical manual, office2pdf is 15.5 pt above Word.
Both PDFs embed the same CourierNewPSMT, so this is line-box modeling, not font substitution.
Reproduction
target/release/office2pdf \
tests/golden_mocks/business/sources/docx/05_technical_manual_en.docx -o /tmp/05.pdf
pdftotext -f 1 -l 1 -bbox tests/golden_mocks/business/expected/docx/05_technical_manual_en.pdf -
pdftotext -f 1 -l 1 -bbox /tmp/05.pdf -
Each shaded code line is its own paragraph:
<w : p >
<w : pPr >
<w : shd w : fill =" F4F4F4" w : val =" clear" />
<w : spacing w : after =" 0" />
<w : ind w : left =" 240" />
</w : pPr >
<w : r >
<w : rPr ><w : rFonts w : ascii =" Courier New" .../><w : sz w : val =" 18" /></w : rPr >
<w : t xml : space =" preserve" >$ cargo install office2pdf-cli</w : t >
</w : r >
</w : p >
Measurements
Consecutive code paragraphs, 9 pt Courier New, w:spacing w:after="0", page 1:
Step
Word GT pitch
office2pdf pitch
line 1 to 2
10.08 pt
7.22 pt
line 2 to 3
10.32 pt
7.21 pt
Word's pitch matches Courier New's 1.133 em line height at 9 pt (10.2 pt). office2pdf uses 0.80 em.
Accumulated yMin drift down page 1, measured after the first-paragraph fix in #420 landed:
Line
Word GT
office2pdf
Delta
1. Installation
77.07 pt
76.35 pt
-0.72 pt
2. Basic Usage
161.55 pt
147.04 pt
-14.51 pt
3. Troubleshooting
276.27 pt
271.03 pt
-5.24 pt
for more width.
384.28 pt
368.82 pt
-15.46 pt
Expected
A paragraph with no explicit w:spacing w:line advances by the run font's line height, as Word does.
Actual
The advance is roughly 0.80 em regardless of the font's ascent and descent, so monospace-heavy documents compress.
Scope
crates/office2pdf/src/render/typst_gen_text.rs — word_line_leading_pt and the paragraph leading it feeds.
Visual checklist
Text content, fills (the F4F4F4 code shading), indents, fonts, weights, colors, and alignment match Word.
Only the vertical advance between consecutive lines deviates.
The first-paragraph offset is tracked in DOCX: first-paragraph space-before collapses at page top #420 , the header rule gap in DOCX: header paragraph border ignores w:pBdr w:space offset #446 , and table row heights in DOCX: table-cell rows render about 4.3pt shorter than Word #404 .
No rotation, flip, clipping, or overflow was found.
Related: #420 , #404
Summary
Consecutive single-line DOCX paragraphs set in Courier New render 2.86 pt tighter per line than Word, about a 28% shortfall. The gap accumulates down the page: by the last body line of the technical manual, office2pdf is 15.5 pt above Word.
Both PDFs embed the same
CourierNewPSMT, so this is line-box modeling, not font substitution.Reproduction
Each shaded code line is its own paragraph:
Measurements
Consecutive code paragraphs, 9 pt Courier New,
w:spacing w:after="0", page 1:Word's pitch matches Courier New's 1.133 em line height at 9 pt (10.2 pt). office2pdf uses 0.80 em.
Accumulated
yMindrift down page 1, measured after the first-paragraph fix in #420 landed:1. Installation2. Basic Usage3. Troubleshootingfor more width.Expected
A paragraph with no explicit
w:spacing w:lineadvances by the run font's line height, as Word does.Actual
The advance is roughly 0.80 em regardless of the font's ascent and descent, so monospace-heavy documents compress.
Scope
crates/office2pdf/src/render/typst_gen_text.rs—word_line_leading_ptand the paragraph leading it feeds.Visual checklist
F4F4F4code shading), indents, fonts, weights, colors, and alignment match Word.Related: #420, #404