Skip to content

Layout: an empty line whose paragraph mark is superscript or subscript is as tall as the mark's full size (#6613) - #6614

Open
Menonro wants to merge 2 commits into
storytold:mainfrom
Menonro:fix/empty-line-of-a-superscript-mark
Open

Menonro wants to merge 2 commits into
storytold:mainfrom
Menonro:fix/empty-line-of-a-superscript-mark

Conversation

@Menonro

@Menonro Menonro commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6613.

An empty paragraph whose paragraph mark is superscript or subscript was laid out a third shorter than one with a plain mark, and so was the empty line after a line break that closes such a paragraph. Word makes these lines as tall as the mark's full font size, as it does a line of superscript text.

The cases of #6613's file (Word for Windows 16.0.20625; 20 pt Arial, a line of which is 23 pt): the distance between the baselines of the lines before and after the case, pt.

case Word main This branch
S1 an empty paragraph 45.98 46.00 46.00
S2 an empty paragraph whose mark is superscript 45.96 37.95 46.00
S3 an empty paragraph whose mark is subscript 46.11 37.95 46.00
S4 "text", a line break, an empty line 69.00 68.99 68.99
S5 the same with a superscript mark 69.00 60.94 68.99
S6 the same with a subscript mark 69.03 60.94 68.99
S7 a paragraph of superscript text 45.96 46.00 46.00

What changes:

  • crates/layout/src/para/model.rs: StyleRun::full_size_extent gives a run's line ascent and descent scaled back from the size it is drawn at to its full size. It is the first half of StyleRun::line_extent, taken out; line_extent calls it and adds the w:position raise and the emphasis marks as before.
  • crates/layout/src/para/lines.rs: the two paths for a line with nothing on it, the fallback in Breaker::extents and Breaker::empty_last_line, take the mark's full_size_extent where they took its ascent and descent as they were. A mark that is neither superscript nor subscript is drawn at its full size, so nothing changes for it.

Test, in crates/layout/src/tests.rs:

  • an_empty_line_of_a_superscript_mark_is_as_tall_as_a_plain_one: an empty paragraph and a paragraph of "Text" and a line break, each with a 20 pt mark that is plain, superscript and subscript: the same height and the same number of lines whichever the mark is. Without the change: "" with a Superscript mark is (19.823698, 1), with a plain one (30.498, 1).

Checked:

  • cargo fmt -p wordcraft-layout -- --check
  • cargo clippy -p wordcraft-layout --all-targets -- -D warnings
  • cargo test -p wordcraft-layout --lib: 715 passed, 3 failed (auto_hyphenation_breaks_long_words, fragmented_hidden_text_lays_out_like_the_visible_text, hyphenation_and_proofing_follow_each_runs_language), the same three as on main in my container, which has no hyphenation patterns.
  • cargo test -p wordcraft-engine: 1455 passed, 5 failed, the same five as on main at 514085c (swiss_german_and_portugal_portuguese_keep_their_languages_rules, two fit_one_page tests, tracked_style_change_round_trips_through_docx, rejecting_a_reopened_style_change_keeps_style_metadata).
  • I did not run the full cargo xtask ci.

Compared with Word's PDFs:

  • 36 cases in two synthetic files: 7 and 20 pt Arial and 20 pt Times New Roman; empty paragraphs with a plain, a superscript and a subscript mark, also in a table cell; paragraphs of only superscript or subscript text; text with a superscript or subscript character in it; text closed by a line break under each kind of mark. Every distance is within 0.15 pt of Word's with this branch; on main the 13 with an empty line under a superscript or subscript mark are 2.9 pt short at 7 pt and 8 pt short at 20 pt.
  • 91 insurance documents filled with made-up data, each word's position compared with Word's PDF. 4 change, application forms with an empty paragraph whose mark is superscript between two notes: the 264 to 947 words below it in each move from 2.6 to 13.4 pt off Word's on average to 0.3 to 0.6 pt. The other 87 come out byte for byte as before. With my other open fixes under it the same four change, and three of them then match Word word for word.

Not done here:

Summary by CodeRabbit

  • Bug Fixes
    • Corrected line heights for empty paragraphs and empty lines after a line break when the paragraph mark is superscript or subscript. These lines now match the height of baseline-aligned paragraphs using the same font size.
  • Documentation
    • Updated layout guidance and revision history to include the empty-paragraph and line-height behavior.

…t is as tall as the mark's full size (storytold#6613)

A line with text sizes a superscript or subscript run at its full font size
(StyleRun::line_extent), as Word does. The two paths for a line with nothing on it, an empty
paragraph and the empty line after a closing line break, took the mark's ascent and descent at
the size it would be drawn at, 0.65 of the full size, so such a line came out a third shorter
than in Word. They take the mark's full-size metrics now.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ee6f99c and 9f64096.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Empty paragraphs and empty lines after closing line breaks now use full-font-size paragraph-mark metrics. A regression test checks superscript and subscript marks against baseline-aligned marks. The layout parity documentation records the case.

Changes: Empty paragraph-mark line metrics

Layer / File(s) Summary
Full-size StyleRun metrics
crates/layout/src/para/model.rs
StyleRun::full_size_extent scales ascent and descent to the run’s full font size. line_extent uses these metrics before applying the run’s position adjustment.
Empty-line layout and regression coverage
crates/layout/src/para/lines.rs, crates/layout/src/tests.rs, docs/layout-parity.md
Empty-line fallback paths use full-size paragraph-mark metrics. The regression test compares baseline, superscript, and subscript marks for empty paragraphs and lines after breaks. The parity document records the behavior and measurement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: aiongg, dylanmtaylor, claude

Merge Risk: Minimal · previous review ee6f9

Empty lines with superscript or subscript paragraph marks now match the height of lines with plain marks, as Word does. The change is narrow and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: empty lines whose paragraph mark is superscript or subscript are laid out at the mark's full size. The raw summary says lines.rs and model.rs use a new full_size_extent met…
Linked Issues check Passed Issue #6613 (direct) requires that an empty paragraph whose mark is superscript or subscript, and the empty line after a closing line break with such a mark, be as tall as the same line with a plain m…
Out of Scope Changes check Passed The whole-PR diff against merge base 514085c touches four files. lines.rs and model.rs contain the fix described above, with the only other edit being the import of StyleRun. tests.rs contains the …
Full details: Title check

Explanation

The title names the change: empty lines whose paragraph mark is superscript or subscript are laid out at the mark's full size. The raw summary says lines.rs and model.rs use a new full_size_extent method for the paragraph-mark metrics of empty lines, and the objectives describe the same fix for issue #6613. The title is specific and matches the main change, so it passes.

Full details: Linked Issues check

Explanation

Issue #6613 (direct) requires that an empty paragraph whose mark is superscript or subscript, and the empty line after a closing line break with such a mark, be as tall as the same line with a plain mark (Word sizes them at the mark's full font size). The head code implements this. Breaker::extents (lines.rs) and Breaker::empty_last_line (lines.rs) now take StyleRun::full_size_extent() for the mark's ascent and descent. full_size_extent (model.rs) scales ascent and descent from draw size back to full font size. For a plain mark the scale is 1.0, so plain-mark behaviour is unchanged. line_extent reuses the same helper and keeps the w:position raise and emphasis-mark handling. The added test an_empty_line_of_a_superscript_mark_is_as_tall_as_a_plain_one (tests.rs) checks equal height and line count for empty and 'Text'+line-break paragraphs with plain, superscript and subscript marks. I did not run the test. The Word-match figures in the PR description are the author's measurements and I did not verify them against Word. Non-coding items (the parity doc update) are not requirements.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against merge base 514085c touches four files. lines.rs and model.rs contain the fix described above, with the only other edit being the import of StyleRun. tests.rs contains the regression test for #6613. docs/layout-parity.md records the same case in the checklist and history, which supports the change. Every hunk I read connects to the #6613 objective. I found no unrelated change. The #5439 follow-up (mark position) is explicitly excluded by the PR and no such code is changed.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 514085c and ee6f99c.

Files selected for processing: 4

  • crates/layout/src/para/lines.rs
  • crates/layout/src/para/model.rs
  • crates/layout/src/tests.rs
  • docs/layout-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

This branch has not been deployed

No deployments
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.

An empty paragraph whose mark is superscript or subscript is a third shorter than in Word, and so is the empty line after a closing line break

1 participant