Skip to content

fix(docx): cut a composed chip's centred label to its outline - #796

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-rota-chips
Sep 30, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-rota-chips

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Why

After #795, CobaltRota still ran onto a second page in Word. Its last staff row overflowed.

  • Rows with two shifts in a day. A stacked chip is a 9.2pt outline round 8.2pt Lato on a 10pt line. The page centres the label and lets its line pass the outline. Word grew the chip's row to the line. An outlined (SOFT) chip grew again by its borders, as Word keeps a cell's borders outside its content. Each such staff row stood 3.8pt taller than the page's.
  • Rows with two plain lines. These stood 1.6pt taller, for the same reason.
  • Rows with one chip a day already stood where the page puts them.

What changed

  • cutTheLabelToItsOutline, called in writePanelPiece for a one-piece panel before its children are written. It applies to a shape composed in a table cell (no layout placement) whose layers are one paragraph of one line, without vertical margin or padding, plus drawings.
    • The label must be centred top to bottom: CENTER, CENTER_LEFT or CENTER_RIGHT, with no vertical offset. A label set from an edge overflows on one side only.
    • Where the label's laid-out line is taller than the room, it registers a DocxStackedLines.Line.
    • The room is what Word leaves the cell's content: the outline less the margins actually written (the padding, less the half of each border the page draws inside the box) and the borders Word keeps outside the content.
    • Both sides are cut alike, because the cell centres the line. The cut is as far as the line passes the room, and no closer to the letters' ink on either side than DocxStackedLines.INK_MARGIN.
    • The text is then seated on the page's baseline as a stacked line is.
    • An outlined chip, whose borders leave less room than its letters need, is cut as far as they allow.
  • Docs. CHANGELOG.md, the composed-shape paragraph of docs/recipes/docx-export.md and the composed-panel sentence of the capability matrix are updated.

Verification

  • 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 (1791 + 127 tests).
    • After install, examples run 93 green.
    • The knowledge checks and extract-api --check pass.
    • render-docx runs 710 tests.
  • New tests in DocxComposedCellTest:
    • A filled 9.2pt chip's Lato label is written at the outline's 9.2pt.
    • An outlined chip's 9.84pt line is cut alike by the 0.93pt its foot allows, to 7.98pt.
    • A 17.5pt chip padded 2pt and outlined 1.1pt comes to its outline: margins, borders and line together.
    • A label set from the chip's top is left at its own line.
  • Each rule fails its own test when reverted: the cut; the partial cut, where all-or-nothing leaves the outlined chip uncut; the like cut on both sides; the room from the written margins, where padding plus whole strokes left the padded chip 1pt short; and the alignment guard.
  • Template corpus (62 documents), against 2.5-dev: only CobaltRota changes.
    • In Word it fits one page again.
    • Rows with two plain lines stand where the page puts them (23.4pt).
    • Rows with an outlined chip are 1.1pt taller, where they were 3.8pt.
    • The 90th-percentile drift falls from 26pt to 18 in Word, and from 30pt to 17 in LibreOffice.
    • The median stays 8.9pt, set by the masthead below.
    • On Word's screen at 300%, the stacked chips' labels show whole.

Known limits

  • CobaltRota's masthead. Its subtitle's -6.5pt top margin inside a composed cell has no space above it to come out of, which leaves everything under it about 7pt low. Its own change.
  • Group icons. They are anchored a row low. Its own change.

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

@DemchaAV
DemchaAV merged commit bd4002a into 2.5-dev Sep 30, 2026
12 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-rota-chips branch September 30, 2026 22:37
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