Repository navigation
fix(docx): keep a bulletOffset paragraph's wrapped lines the page's distance apart - #819
Merged
Merged
Conversation
…Linux LibreOffice baseline from CI
…elow the lines' mean height, and discount the prefix only where it is set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Word sets every line of a paragraph one exact height apart. The page sets each line its own height, and the export wrote the tallest.
A
bulletOffsetparagraph's prefix is laid out on the page as a span of spaces in the paragraph's style, and that span has always counted towards its line. InEditorialProposal's andNorthlineProposal's bullets that style is taller than the runs, so the wrapped line is 12.95pt against the first line's 12.0.On the page the two baselines are 13.05pt apart. The export wrote 12.95 plus the gap, so Word set them 13.8pt apart. Every item then stood half a point to a point lower than the one above it.
EditorialProposal's terms, "full payment is received." ended 4pt low, and the right-hand column of deliverables was a point low under its first item.NorthlineProposal's list ran from about 1pt to 4.2pt low.What changed
DocxLayoutMetrics.lineHeightbulletOffsetand anindentStrategy, a leading blank span (the prefix the export writes as an indent) is left out of the height of each line the strategy prefixes (writtenTextHeight): the first line forFIRST_LINEandALL_LINES, the wrapped lines forFROM_SECOND_LINEandALL_LINES. A paragraph of one line keeps its laid-out height: where it is set by its rise or its pictures (riseIntoItsLine,holdPicturesInTheLine), nothing would make up a shorter one.above.base + gap + line.height − line.base, over pairs of lines whose height is their text's, so lines a picture makes taller are left tomakeRoomForPictures. It is never written below the tallest line, which would clip it, nor above the lines' mean height, which would leave the paragraph taller than the page with nothing to owe back.oweWhatTheLinesFallShort. A paragraph written at a height other than its tallest laid-out line can come out shorter than on the page, by what its first line's top and last line's foot hold. That shortfall is owed below it (linesHeight,lineIsNotTheTallest). A paragraph at its tallest line comes out no shorter, so nothing is owed there.word-windows,libreoffice-windowsandlibreoffice-linuxare rewritten for the two documents this moves. The Linux one is taken from this PR's CI run (docx-fidelity-37024889880), whereNorthlineProposalgoes from 5 lines past 2pt to none.CHANGELOG.md, the Line height row ofdocs/recipes/docx-export.md, and thelineHeightJavadoc.Verification
Template corpus, re-measured in full. Only
EditorialProposalandNorthlineProposalchange, in both editors.EditorialProposalNorthlineProposalNorthlineProposalEditorialProposalEditorialProposal's second page in Word.EditorialProposalin LibreOffice. LibreOffice already sets this page about 45pt high, for a cause of its own.New test class,
DocxLinePitchTest, four tests.Each rule fails its test when taken out.
Full reactor gate:
./mvnw -B -ntp clean verify -pl :graph-compose-core,:graph-compose-render-pdf,:graph-compose-render-docx,:graph-compose-render-pptx,:graph-compose-templates,:graph-compose-testing,:graph-compose-qa,:graph-compose-coverage -amgives BUILD SUCCESS. render-docx runs 808 tests, qa 1814.Known limits
Lane: shared-engine (render-docx). No public API change.