Repository navigation
fix(docx): give a centred or right-aligned line that fills its box Word's room - #832
Merged
Merged
Conversation
…a cell, and take the Linux LibreOffice baseline from CI
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 states a type size in half points (
w:sz), so a size the page sets to the tenth is written to the nearest half: 6.8pt as 7pt, a line 2.9% wider than the page's.measureAtWordsSizealready gave a flush-left paragraph that much more measure. A centred or right-aligned paragraph was left at the page's measure, because moving its one edge would move the line.VioletGrid's skill tiles centre a 6.8pt heading in a box it fills. In Word "INFORMATION ARCHITECTURE" broke onto two lines, and the tile's text stood 7.5pt low under it. These were the last two lines in the Word corpus more than 2pt off.What changed
DocxSemanticBackend.measureAtWordsSize:ONE_LINE_FACE_SLACK, does not fit its box (oneLinesMeasure).leftIndentTwips). The right indent gives the rest: the line fits, and moves by that much.ClassicSerif's centred summary, which Word already breaks at other words than the page, took "br…" up a line when I tried it.wordsMeasure's one-line rule also widens byroom × share, which pushed even a short centred "0.00" cell's indents past the cell's edge, and Word then set it 0.12pt off its place.widthAtWordsSize(line)is pulled out ofwordsMeasure, and both measures use it;wordsMeasure's result is unchanged.Scaling the glyphs (
w:w) instead was measured and rejected. Word breaks scaled text differently from how it draws it:CompactMono's 99%-scaled line drew at the page's width and still broke "8" onto the next line.TerracottaRaillost a line, and the Word corpus went from 2 lines past 2pt to 34.Verification
scripts/docx-visual/word-fidelity.ps1(Word 16.0.20430) → BUILD SUCCESS, with the baseline rewritten by-Update.VioletGridmoved. Its lines more than 2pt off fall from 2 to 0, and that is now 0 across the corpus.cv-violet_grid.docxchanged.VioletGrid's median falls from 5.21 to 0.36pt, its lines past 2pt from 39 to 37, and one more line matches (76 → 77). LibreOffice still sets that CV on two pages. I rewrote the Windows baseline withupdate=true. The Linux baseline is this PR's CI artifactdocx-fidelity-37145495395, which moved the same document the same way and nothing else.DocxWordSizeMeasureTest, +7 tests (18 total):wordsMeasurein place ofoneLinesMeasurefails the short-line test;./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 -am→ BUILD SUCCESS.CommittedAssetDriftTestinexamples→ 3/3 green, no committed preview moved.Known limits
VioletGrid's "Low to high-fidelity wireframes…" tile, andClassicSerif's summary, keep their line count, so nothing below them moves.Lane: shared-engine (render-docx). DOCX export geometry only, no public API change.