Skip to content

fix(docx): take a drawn shape's picture frame from the space around its line - #824

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-picture-line-frame
Oct 3, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-picture-line-frame

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Why

A drawn shape is written as a picture larger than its ink by a transparent frame on every side (DocxShapePictures.EDGE, 0.25pt), so antialiased edges are not cut.

A paragraph holding only such pictures, whose picture leaves the text's height, is written with its line at least the pictures' reach (makeRoomForPictures). It is not held exact (holdPicturesInTheLine takes lines with text only). Word then makes the line as tall as the picture itself, frame included.

MonogramSidebar's contact column is an icon paragraph over a text paragraph per contact. Each 22pt glyph is a 22.5pt picture. Every icon line stood half a point taller than the page's, and every contact half a point lower than the one above: 0.63, 1.11, 1.59, 2.21, 2.69pt. The education and skills columns under them inherited the 2.8pt. Those are all 17 of the document's lines more than 2pt off in Word.

What changed

  • PictureReach carries boxAbove and boxBelow: how far the picture's own edges reach past the page's line, frame included. A drawn shape's frame is EDGE; an image's or an SVG icon's is 0, so for them the two are its ink's reach.
  • takeThePicturesEdgesFromAround applies to a line of the paragraph's own that holds only pictures, written at least their reach, where a drawn shape has a frame. Word grows that line to the pictures' box, edge to edge. The export takes exactly that growth: from the paragraph's space above as far as the box passes the line's top, the rest from the space above what follows (hangingBelow), as holdPicturesInTheLine takes a held line's ink.
    • The ink then stands where the page draws it, and what follows where the page sets it. Word's line stays the picture's height.
    • Nothing is taken where the box does not pass the line written, since there Word keeps that height and a take would lift what follows.
    • It is not taken for a half of a line pair, which shares its line, or for a picture with no frame.
  • Baselines. word-windows, libreoffice-windows and libreoffice-linux are rewritten for MonogramSidebar, the one document this moves. The Linux one is taken from this PR's CI run (docx-fidelity-37076030391), where the median goes from 3.57 to 2.90pt as on Windows.
  • Docs. CHANGELOG.md, and the Line height row of docs/recipes/docx-export.md.

Verification

  • Template corpus, re-measured in full. Only MonogramSidebar changes, in both editors.

    Editor Past 2pt Median p90
    Word 16.0.20430 17 → 0 0.79 → 0.29pt 2.95 → 0.79pt
    LibreOffice (Windows) 50 → 50 3.57 → 2.90pt 5.69 → 3.57pt

    LibreOffice's lines past 2pt are its 2.8pt header offset on the sidebar CVs, which this change does not touch.

  • New test class, DocxPictureLineEdgeTest, two tests.

    • A 22pt dot alone in its paragraph keeps its 4pt above less the frame (75 twips), and the paragraph under it its 8pt less the frame (155).
    • A 22pt picture with no frame alone in its paragraph keeps 80 and 160: its box is its line, and nothing is taken.
  • The take fails the first test when taken out: without it the paragraphs keep 80 and 160.

  • 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 -am gives BUILD SUCCESS. render-docx runs 822 tests, qa 1814.

Known limits

  • An image's or an SVG icon's line that leaves its text keeps growing as before. Its reach past the line is its ink, not a frame, and is left to Word as before. Unmeasured.
  • An icon line closing a cell leaves its frame below in the row, not taken from anything.
  • An icon line with less space above it than the frame (opening a column) takes what there is, and its ink stands that much low; what follows still stands where the page sets it.
  • A pictures-only paragraph that wraps grows every line by the frame and is made up once.
  • No test covers a line pair's half or an icon whose box stays within its line.

Lane: shared-engine (render-docx). No public API change.

@DemchaAV
DemchaAV merged commit afcbca8 into 2.5-dev Oct 3, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-picture-line-frame branch October 3, 2026 06:54
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.

1 participant