Repository navigation
fix(docx): grow a line holding a picture where the picture stays within its text - #957
Merged
Merged
Conversation
…in its text - DocxGrownLines reads a run holding only pictures set in the line: its pictures' top, the higher of Word's place (lowered by the run's position) and LibreOffice's (a tenth of a point above the baseline, whatever the position), and Word's lowering as their foot. The run's own face sets none of the line. - A line may grow only where its pictures stay within its text in both places (Reach.holdsItsPictures); lineOf reads a least line holding pictures only where it is at least its text's own line and holds them. - Pictures in a paragraph of broken lines, or beside spaces alone, give no reach. - Tests: within, lowered, raised, too tall, too deep, own size, broken, spaces and no-break spaces, lineOf for a line grown to its picture; a drawn marker's composed item now grows as in the flow.
DemchaAV
marked this pull request as draft
October 25, 2026 04:49
…least line no position - Reach.holdsItsPictures reads the text's own line, its faces' line gap included, not the line written: a line makeRoomForPictures wrote taller for a raised picture held that picture, and its least line was seated and given a position. - shiftToThePagesBaseline writes no position for a least line, whose text Word does not move by one; LibreOffice moves it and grows the line. - Tests: a raised picture's line and one with two points between its lines are given no position; an anchor beside a picture and a position in points give no reach; the corpus export is unchanged.
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
A line is written at a least height (
w:lineRule="atLeast"), which Word grows when a reader makes the text larger, where it is at least as tall as its runs' own line (#955, #956). A line holding a picture set in it was never read:DocxGrownLines.reachOfgave it no reach, so an icon or a drawn bullet beside words kept the line exact. WithNormaltwo points larger, Word cut the tops off those letters on screen. The corpus had 195 such exact lines at least as tall as their text's own.Measured in Word 16 and LibreOffice 24.2 (CI's build), on 8pt and 10pt Lato beside pictures 6 to 11pt tall, lowered 0 to 3pt by their run's position, in exact and least lines of 9.95, 12 and 15pt:
So a line whose pictures stay inside its text, by both readings, stands its text where it would stand without them.
What changed
DocxGrownLines.reachOfreads a run holding onlyrPrand pictures set in the line (wp:inline):PICTURE_RISEabove the baseline;It gives no reach where:
w:br), since a broken line may hold a picture alone;MidnightNavy's language dots stood the rows under them 0.56pt low, then a point lower a row.Reachcarries the two (pictureTop,pictureFoot).holdsItsPictures()asks whether no picture reaches above the text's own line, its faces' line gap included, nor below its shallowest descent. It reads the text's own line, not the line written: a linemakeRoomForPictureswrote taller for a picture, raised off the baseline say, holds that picture, and its text's own line does not.mayGrowrequires it.lineOfreads a least line holding pictures only where it is at least its text's own line and its pictures stay within that line. A linemakeRoomForPicturesgrew to a picture that rises past the text stays unread, as before, and is not seated.shiftToThePagesBaselinewrites no position for a least line. Word does not move a least line's text by one, and LibreOffice moves it and grows the line. A linemakeRoomForPictureswrote at least, whose picture stays under its faces' own line (an 11pt picture beside 10pt Poppins, two points between its lines), is now seated, by the space around it but not by a position. No document of the corpus holds one: the export with these two fixes is the same, byte for byte but for the time stamp, as the one measured below.What is written as before:
CharcoalGold's contact icons do in LibreOffice;holdPicturesInTheLine), which are cut to fit.Docs: the recipe's
Line heightrow, the CHANGELOG, the older least-line entry's picture clause, andmakeRoomForPictures' Javadoc.Verification
DocxGrownLinesTest,aLineMayGrowOnlyWhereItsPicturesStayWithinItsTextInBothEditors:lineOfreads a least line's baseline, and not a picture past the text, nor a line written shorter than its text's own, nor one written taller for a raised picture.DocxGrownLinesTest,aPictureRunHoldingAnythingButPicturesOfAWrittenSizeIsNotRead: an anchor beside a picture in one drawing, and a position in points, give no reach.DocxGrownLinesExportTest(+4):DocxComposedListTest: a drawn marker's item in a cell is now least, as the flow's.lineOf's fit, and its line-height check;line heightcounts.restyle-body-through-normal:TealPulsepasses;scripts/docx-visual/word-fidelity.ps1): BUILD SUCCESS. On the seven documents:ConsultingInvoice's line items (36 lines, both lengths) stand one step of Word's 0.12pt grid lower. Their description cells now seat the row's lift out of the space above the table by 7 twips less, and the other cells' space above takes as much less. LibreOffice sets them where they stood.TealPulse's duties (14) stand 0.24pt lower. Their 9.8pt line holds a 0.2pt gap above the text, which the space above them does not take. That is inside the quarter point a least line is held to, but further than the exact line stood.TealPulse's andOrangeOps' skills move 0.3pt down, from 0.1–0.33pt high to between 0.21pt low and 0.03pt high../mvnw -B -ntp clean verify -pl <core, render-pdf, render-docx, render-pptx, templates, testing, qa, coverage> -am→ BUILD SUCCESS: core 823, render-pdf 339, render-docx 2178, testing 5, render-pptx 142, templates 127, qa 1830../mvnw -f examples/pom.xml test→ BUILD SUCCESS, 93 tests.Lane: shared-engine (render-docx). No public API change. Picture lines' line rules change in the file.