Repository navigation
fix(docx): seat a composed chip's label where the page sets it - #879
Merged
Merged
Conversation
- A label line taller than its shape's outline is seated from the outline's top, where the page starts it (the layer box clamps an over-tall child at its top), not from the middle the cell centres the written line on: CobaltRota's stacked chips' labels stood 0.43pt high in Word. The cut keeps the letters, set that much lower, inside the line (cutAlike), and only where Word sets the line on the shape's middle (setOnTheShapesMiddle): it fits the held height, or the cell round the shape gives back all the shape grows by. Elsewhere, or where no line on that middle holds the letters, it is read from the middle as before. - A label the shape holds whole is moved towards the page's baseline by the margins of the shape's cell, out of the height its row holds (seatTheLabelThroughItsMargins): Word's exact-line seat four fifths down and the page's differ by a quarter point in Carlito, which a half-point position does not move. CobaltRota's single-shift labels stood 0.29pt low, its legend's 0.33pt. The page's own seat off the baseline moves with it; not a label whose text a position moves, not past the room the held height leaves, not under a tenth of a point. - Docs: CHANGELOG (v2.5.0), the recipe's composed-shape paragraph, the capability matrix's clip row. - Fidelity baselines rewritten (Word, LibreOffice on Windows): only rota-cobalt moves, median 0.38 -> 0.20pt in Word, 0.31 -> 0.09pt in LibreOffice. - Tests: DocxComposedCellTest - a label taller than its chip seated from its top, raised and lowered by the margins, the room clamp, the tenth, a padded chip, the page's seat, a label a position moves, a line taller than the held height, letters no middle line holds, and the outlined chip read from the middle beside another cell or where the margins give back less.
- A label a composed shape holds whole is written at the exact line height that stands its text on the page's baseline (seatTheLabelByItsLine). Word and LibreOffice stand an exact line's baseline four fifths down it, and the cell centres the line, so the text stands three tenths of the line below the middle. CobaltRota's single-shift labels: the 12.7pt line is written 11.85pt. - This replaces moving the line by the shape cell's margins out of the row's held height. LibreOffice 24.2, the build the Linux fidelity job runs, counts a cell's margins inside an at-least row height. The single-shift chips came out half a point shorter there, every staff row with them, and 77 lines stood further. - The line is no shorter than keeps the letters three quarters of a point inside it, their reach read from the line's own baseline, and no taller than the room. A label in a standard face the export does not embed is left as it was, since its letters are read through a stand-in. - Docs: the CHANGELOG entry, the recipe's composed-shape paragraph and the matrix's clip row. - Baselines: Word and LibreOffice on Windows rewritten; only rota-cobalt moves. - Tests: DocxComposedCellTest covers a label seated by a shorter line, a taller line, the room ceiling, the tenth, the letters' floor, a deep face, a padded chip, the page's CENTER and TOP seats, and a standard face left alone.
…posed chip label seat Taken from the docx-fidelity artifact of this branch's CI run 38153180539 (LibreOffice 24.2.7.2). Only rota-cobalt moves: median 0.17 -> 0.22pt, p90 0.90 -> 0.52pt; 40 of its lines nearer, 53 further by up to 0.30pt (the single-shift labels, seated in their chips, which LibreOffice 24.2 sets 0.25pt above the page).
…umbers The CHANGELOG entry, the recipe and the capability matrix name the tenth-of-a-point floor and the standard faces the line seat leaves alone, the margin case read from the middle, and LibreOffice 24.2's counts; the Javadoc of seatTheLabelByItsLine says which faces get a taller line, and cutTheLabelToItsOutline's measures from the outline.
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 rota's shift chip — a shape composed in a table cell — is written as a one-cell table. Its row is held at the outline's height, and its one centred label line sits in it. In
CobaltRotathe chips are most of the sheet's lines, and the label stood off where the page sets it in both editors:LayerStackGeometry.verticalOffsetclamps at zero). The export seated the cut line from the middle the cell centres it on, which is half of what the line is taller above where the page draws it.CobaltRota's stacked chips (8.17pt Carlito on a 9.97pt line, in a 9.18pt chip) stood 0.43pt high in their chips in Word and about 0.4pt in LibreOffice on Windows.This was measured on the PDFs: each label's baseline against the chip's own box, page against editor, so that a misplaced chip separates from a misseated label.
What changed
In
DocxSemanticBackend:cutTheLabelToItsOutlineseats a line taller than the outline from the outline's top. Its stacked line'stopAboveislow - cut, wherelowis half of what the line is taller than the outline.cutAlike, the old inline expression) keeps the letters inside the line where the page sets them: the top that much further from them, the foot that much nearer.setOnTheShapesMiddle): the line fits the height the shape's row holds, or the cell round the shape gives back all the shape grows by (giveBackWhatTheLabelNeeds).seatTheLabelByItsLinewrites a label the shape holds whole at the exact line height that stands its text on the page's baseline.CobaltRota's 12.7pt single-shift line is written 11.85pt; Lato, which the page sets lower, on a taller line.INK_MARGINinside it, measured from the line's own baseline. It is no taller than the room, and the chip and its row keep their height.seatShift) moves with it, and what a bound leaves is the text's position.composedLabelOfis the label lookup the cut used, pulled out of it.Docs:
CHANGELOG.md(v2.5.0), the recipe's composed-shape paragraph, and the capability matrix's clip row.Verification
./mvnw -B -ntp clean verify→ BUILD SUCCESS: render-docx 1374 run, 0 failures, 1 skipped, qa 1820, core 818, examples 93.DocxComposedCellTest, over the stacked chips:DocxComposedCellTest, over labels the chip holds whole:TextVerticalAlign.CENTERis written 222;TextVerticalAlign.TOPis held at 298 by its capitals, with the rest a position of 8;Seventeen sabotages, each caught by its own test.
seatShiftdropped;DOCX fidelity corpus against
2.5-dev: onlyrota-cobaltmoves.rota-cobaltWindows baselines rewritten.
LibreOffice 24.2.7.2, the Linux job's build, also run in an
ubuntu:24.04container to measure the labels in their chips; itsrota-cobaltmatches the job's to the hundredth.rota-cobaltp90 0.90 → 0.52pt, median 0.17 → 0.22pt; 40 of its lines nearer and 53 further, by up to 0.3pt, all of them single-shift labels; no line of any other document moves.Report: the same 969 notes. The corpus DOCX are byte-identical to the measured export.
Notes for review
Lane: shared-engine (DOCX backend) —
render-docx, with theqafidelity baselines; no public API.