Skip to content

fix(layout): bound running-band text to the content box - #469

Merged
Tim81 merged 8 commits into
mainfrom
fix/running-band-truncation
Sep 10, 2026
Merged

Tim81 merged 8 commits into
mainfrom
fix/running-band-truncation

Conversation

@Tim81

@Tim81 Tim81 commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Fixes the two defects a consumer reported against shipped VellumPdf.Layout 2.3.1, plus two more
found while fixing them. Refs #365.

Five commits, each its own change: truncation, colour, the exception message, the report channel,
and the changelog.

What was wrong

DrawBandText measured a band's whole resolved template, positioned it by an alignment formula that
had never been given a bound, and emitted every glyph. Measured on a 200pt page with zero margins
and a footer of 500 W at 12pt:

Alignment Origin Text right edge Page
Centre x = -2732 2932 200pt
Right x = -5464 200 200pt
Left x = 0, legal 5664 200pt

All 500 glyphs reached the content stream in every case, so the band was absent from every viewer
while its bytes were paid for.

The fix

FitToWidth returns the longest prefix that fits, walking forward and stopping rather than
measuring the whole string, so the work is proportional to what fits rather than to what was passed.
The width it returns is bounded by the content width, which is what makes the alignment arithmetic
safe: no clamp is needed, because no arm can place a bounded run outside the box.

Three details are load-bearing rather than incidental:

  • When the whole string fits, the width comes from one measurement of the whole string, not the
    walk's running total, because it is the more accurate width and costs nothing on a path that has
    already measured every piece. It was first justified as preventing a visible shift, which
    measurement does not support: every sweep of the two orders put the drift below 1e-11pt against an
    output format of five decimals, and substituting the running total moved no byte of any content
    stream measured. No test defends that line, so its comment does.
  • The cut prefers the last word boundary, because a template ending in a page number cut
    mid-token would show a number that is simply wrong, where dropping the token shows none.
  • When nothing fits, nothing is emitted, not even the marked-content pair. Setting a font
    registers a page resource, so an empty band would otherwise add a /Font entry to every page.

The bound has one hole, named in the code rather than left to be found: a glyph may advance zero,
which covers every character below 0x20, WinAnsi's five undefined codes, and both symbolic
Standard 14 faces, whose width tables are absent from the metrics lookup entirely. A template of
those never exceeds any width and is walked to its end.

Two more defects, found while fixing

The band ignored its own colour and inherited the page content's. Worse than ignored: the two
text renderers do not bracket their fill colour in q/Q — the image and chart renderers do, and
the chart's comment says it brackets precisely to stop this — and a band is drawn after the content,
so it took whatever colour the last paragraph or cell left set. Measured on a page whose body was
red and whose footer asked for blue, the band's text object held no rg at all and the footer
rendered red.

Every exception message in DocumentRenderer formatted with the current culture. Found while
writing a test to pin the new band-aware too-tall message: a content area printed as 161,6pt here
and 161.6pt on an English runner, so a test pinning any of them would pass on CI and fail locally.
All four now format invariantly, including the three that were already there.

Byte identity

Two changes move bytes for a document that was already fine, and both are measured rather than
assumed. Nine fitting-band configurations, three alignments across three templates, hash identically
across the truncation commit — and the before build was first confirmed not to contain the fix,
since equal hashes would otherwise only prove I measured the same build twice. Reviewers extended
the same check to twenty-one configurations, adding embedded-font bands and bands with escaped
characters, without finding a difference.

  • The colour fix, by one operator per band per page wherever the band emits text: 30 to 42 on a
    twelve-band-placement document. A band that fits nothing gains none.
  • Truncation, for an empty template. That previously emitted a text object showing an empty
    string and now emits nothing, removing five lines per placement and, on a document whose only
    text was such a band, that band's entry in the page's /Font dictionary and the font object it
    pointed at. The dictionary itself stays, empty, because every page gets one unconditionally. This
    one I missed twice; it surfaced only when a reviewer tested a template the property generator
    itself produces.

The report channel

Document.BandTruncations and DocumentRenderer.BandTruncations, following the shape
TextEncodingWarnings already set. One report per band rather than one per page: a per-page list
would hold 9,900 entries on the 4,950-page document this was reported against, and would put a list
append back into the path the fix exists to bound. It names the page that lost the most, because a
page token lengthens the resolved text as the number gains digits. It carries counts and not the
text, matching two existing channels that bound what a diagnostic retains.

Public on the renderer as well as the document, unlike TextEncodingWarnings, because there is no
other route to it: a canvas can be asked what it could not encode, but only the renderer knows the
content box a band was measured against. Twenty-four PublicAPI.Unshipped.txt entries, taken from
what the analyzer demanded rather than hand-transcribed.

Tests

22 cases in RunningBandFitTests, plus the updated band case in PaginationDepthTests. 8 of the
12 placement and boundary cases fail on the parent commit and pass here
; the other 4 are controls
that pass on both, and their passing is what shows the fix did not simply move everything.

The fixture makes every expected coordinate exact rather than approximate: Helvetica's advance for
Æ is exactly 1000 thousandths of an em, so at 10pt each glyph is exactly 10pt and a 200pt content
box holds exactly twenty.

Mutation-checked rather than assumed:

Mutation Result
Recorder disabled 5 tests fail at HEAD (4 of the 5 the channel commit added; the fifth is a control asserting emptiness)
Record the first cut instead of the worst 1 test fails
Record both bands into one slot does not compile — warnings-as-errors rejects the unused field
Delete the embedded-font colour line 1 test fails
Empty DocumentRenderer.BandTruncations 5 tests fail
Return the space's width from a word-boundary cut 3 tests fail
Remove truncation entirely the page-box property fails; with the old short band templates it passed

Scope

The plan for this work folded seven off-page sites into one pull request: the band plus images,
charts, table cells, the grid resolver, list markers and the paragraph hard break. The band alone
came to five commits, so it is split out here rather than pressed on, which is what that plan's own
risk section says to do. The remaining six follow next. #468, found while reviewing #467, is one of
them.

The changelog entry goes under ## [Unreleased] rather than a dated 2.3.2 section, which also
differs from the plan. The plan wanted a dated section so the next minor would not announce these
twice; that concern is real, but this repository already handles it the other way — #461's fixes
went under Unreleased and #465 is moving them into a 2.3.1 heading at release time. Main carries no
2.3.1 heading yet, so inventing a 2.3.2 one above 2.3.0 would be worse.

Verification

  • dotnet build VellumPdf.slnx clean, warnings are errors.
  • dotnet test VellumPdf.slnx -c Release 6,857 total, 0 failed, 319 skipped.
  • dotnet format --verify-no-changes and eng/clean-room-check.ps1 clean.

Review round

Three reviewers with disjoint lenses — the fit algorithm, the report channel with byte identity, and
claims with conventions — all with write access so they could mutate rather than derive. Twelve
findings at medium or above, every one mine. Three were false sentences rather than code faults,
which is the failure mode this repository's standard is written against.

Code fixed

Finding What it was
The report could name a page in no output SaveAsync and PrepareForSigning collected between the layout and the write, so a second call ran a whole second layout, appended pages, collected, then threw. All three paths now collect after a successful write.
The too-tall figures did not close It showed a 200.0pt page and 18.4pt of bands then reported 161.6, omitting the 20.0pt of margins — the larger term — and omitting them from the remedies. The same fault it was replacing.
Consecutive spaces charged for absent ink A trailing space in the drawn text shifted a centred band by 2.78pt per space at 10pt. Only the first space of a run is a cut point now.
The culture sweep was incomplete The previous commit fixed four and said four; the file held six and the assembly twelve. All twelve floating-point ones are now invariant, and what was left alone is named.

Claims corrected

  • The byte-identity justification asserted a shift that does not happen (above).
  • "No layout renderer brackets its drawing in q/Q" was false in five places (above).
  • "Every banded document gains one colour operator" is false at the zero-fit boundary (above).
  • The surrogate comment claimed a cut can never leave a lone surrogate. True for well-formed input
    only; and because the walk stops early, the embedded path's throw now depends on where in the
    template the surrogate sits, where before the whole template was always measured.
  • The zero-advance hole now states its consequence: a band in Symbol or ZapfDingbats measures zero
    however long it is, is never cut, and is still positioned from zero, so this defect survives for
    those two faces with no report. Measured — a 500-glyph Symbol footer emits all 500 glyphs. Filed
    as Kernel: Symbol and ZapfDingbats have no advance-width tables, so every string in them measures zero #470; unfixable from the layout engine, which has no width to work from.

Tests added, each proven by deleting the code and watching the suite stay green first: the
embedded-font colour branch, the renderer's own BandTruncations property (whose documentation
claimed a test that did not exist), and the width a word-boundary cut returns, where a mutation
moved the band 2.78pt with everything passing.

The property suite's band templates were widened. They were short because truncation was broken,
which is precisely the exclusion #467 said belongs in the pull request that fixes the defect.
Removing truncation now turns the page-box property red. Widening also exposed a coupling of my own:
a long template cutting at its first space drew exactly the cell word and inflated the per-element
placement counts.

One reviewer finding not accepted as stated. A LayoutBox.ToString culture fix was implied by
the sweep argument; it is a shipped public member rather than an exception message, so changing its
output is a different risk and is left out deliberately, named in the changelog.

Merge order

This inserts into the same ## [Unreleased] region that #465 rewrites, so whichever lands second
takes a textual conflict. Resolving it carelessly could file these entries under the already-published
2.3.1, so they want landing in a known order.

Verification after the fix round

  • dotnet test VellumPdf.slnx -c Release 6,862 total, 0 failed, 319 skipped.
  • dotnet build, dotnet format --verify-no-changes, eng/clean-room-check.ps1 all clean.
  • eng/hooks/commit-msg run against all six commit messages.

Confirmation round

One reviewer re-measured all twelve fixes with write access. Every fix holds behaviourally.
Three claims about them did not, and all three were counts.

  • The culture count was wrong a second time. The previous round wrapped two messages in
    LayoutImageRenderer and said twelve; PdfImageXObject.Width and Height are int, so those
    wrappers changed nothing. Reverted. Ten floating-point messages: six in DocumentRenderer, four
    in PieChartRenderer, counted as distinct messages rather than interpolated segments, and
    verified independently.
  • Byte identity had a second counterexample, above.
  • "Five cases, all failing" was four of five; the fifth is a control asserting emptiness, and
    this PR's own table already said four.

Two universals softened to what boundary measurement supports: the too-tall figures print to a
tenth, so the terms need not sum exactly — measured, margins of 10.02 and a footer of 18.04 print
20.0 and 18.0 against 161.9 — and the drift figure understated its own maximum at 9.1e-13pt while
citing a differing value that could not be reproduced.

One test renamed: an all-space template does keep its spaces, because the first space sits at index
0 and the word-boundary branch refuses that, so keepsNoTrailingSpace overstated the guard.

The pattern across both rounds is worth naming: the code held up under every mutation, and every
finding was a sentence claiming more than its measurement supported.

Verification at HEAD

  • dotnet test VellumPdf.slnx -c Release 6,862 total, 0 failed, 319 skipped.
  • dotnet build, dotnet format --verify-no-changes, eng/clean-room-check.ps1 clean.
  • CI on the previous commit: all four checks green; Layout coverage 91.98%, combined 91.6% against
    an 84% threshold.

Third review round

A focused pass over the previous corrective commit. Three findings, all wording; every code change
in that commit held under measurement.

  • "The page's /Font entry" was wrong, in four places. PdfPage sets /Font on every page
    unconditionally, so it survives as an empty dictionary. What an empty band stops emitting is its
    own entry inside it and the font object that entry pointed at. Measured: /Font occurrences 2→1,
    /Type /Font objects 1→0, /Helvetica 1→0, surviving resources /Font << >>.
  • The file contradicted itself. Correcting the changelog to say two changes move bytes for an
    already-correct document left a comment thirty-nine lines below still saying one does. Both now
    say two and name each other.
  • The changelog kept the drift figure the previous commit had declared wrong, because that commit
    fixed the code comment and never touched the changelog paragraph. Neither now states a maximum: a
    reviewer could not reproduce 9.1e-13 and measured 2.8e-13 over short strings and 6.4e-12 over long
    ones, so the number depended on sweep parameters nobody had written down. What is load-bearing is
    the six orders of magnitude between the drift and what the output can represent.

Across three rounds and four reviewers: every production-code change has held under mutation, and
the findings have converged from behaviour, through counts, to which PDF dictionary entry disappears.
Four findings required production code, three required new tests, and eleven were sentences claiming
more than their measurement supported.

DrawBandText measured a band's whole resolved template, positioned it
by an alignment formula that had never been given a bound, and emitted
every glyph. A template wider than the content box therefore went off
the page while its bytes were still written into the content stream, so
the header or footer was absent from every viewer with no warning and
no truncation. Measured on a 200pt page with zero margins and a footer
of 500 W at 12pt: the centred band was placed at x = -2732 and the
right-aligned one at x = -5464, and the left-aligned one started
legally at x = 0 and ran to 5664.

FitToWidth now returns the longest prefix that fits, walking forward
and stopping rather than measuring the whole string, so the work is
proportional to what fits rather than to what was passed. The width it
returns is bounded by the content width, which is what makes the
alignment arithmetic safe: no clamp is needed because no arm can place
a bounded run outside the box.

Three details are load-bearing rather than incidental. When the whole
string fits, the width comes from one measurement of the whole string
instead of the running total, because the metrics sum integer
thousandths and scale once at the end while the loop scales each piece;
the two differ in the last bits, which would move the text matrix of
every centre- and right-aligned band that fits today. Verified: the
decompressed content streams of nine fitting-band configurations hash
identically before and after, and the before build was confirmed not to
contain the fix. The cut prefers the last word boundary, because a
template ending in a page number cut mid-token would show a number that
is simply wrong where dropping the token shows none. And when nothing
fits, nothing is emitted at all, not even the marked-content pair,
since setting a font registers a page resource and an empty band would
otherwise add a /Font entry to every page.

The bound has one hole, named in the comment rather than left to be
found: a glyph may advance zero, which covers every character below
0x20, WinAnsi's five undefined codes, and both symbolic Standard 14
faces, whose width tables are absent from the metrics lookup. A
template of those never exceeds any width and is walked to its end.

DrawBandText also loses the RendererContext it took and never read.

Tests: 8 of the 12 new cases fail on the parent commit and pass here;
the other 4 are controls that pass on both. They use a fixture where
every coordinate is exact rather than approximate, since Helvetica's
advance for AE is exactly 1000 thousandths of an em, so at 10pt each
glyph is exactly 10pt and a 200pt content box holds exactly twenty.

Refs #365
A band never set a fill colour, so TextStyle.Color was ignored on that
path while ParagraphRenderer and TableRenderer both honour it. It is
worse than ignored. No layout renderer brackets its drawing in q/Q, and
a band is drawn from FinishCurrentPage after the page's content, so the
band inherited whatever colour the last paragraph or cell left set.

Measured on a page whose body was red and whose footer style asked for
blue: the band's own text object held no rg operator at all, and the
last one on the page was the paragraph's 1 0 0 rg, so the footer
rendered red. The colour a band shows was therefore a property of
whatever happened to be drawn above it.

The style's colour is now set after the font on both font paths,
matching the order the paragraph and table renderers emit. It has to be
unconditional rather than emitted only when it differs from black,
because a black band after red content would otherwise still inherit
the red.

This is the one change in this branch that moves bytes for a document
that was already correct: every banded document gains one colour
operator per band per page. Measured on a twelve-band-placement
document, colour operators go from 30 to 42, a delta of exactly 12,
and that document's output happened to come out 31 bytes smaller.

Refs #365
Both pagination passes threw one message for every cause of a too-tall
element: reduce the element's content or increase the page size. When a
running band is what shrank the content box, that points at the wrong
thing and suggests a remedy that cannot work, because the element never
changed. The consumer who reported this lost a first reading to it:
a footer was added to a document that had been paginating, the document
stopped rendering, and the message blamed the element.

The message now names the bands and prints what they reserve against
the page height, following the margins-case throw in RunLayout, which
already printed figures. The no-band wording is unchanged byte for
byte, so the existing control test still passes untouched and its
passing is the evidence that only the band case moved. Both passes
still reach one producer, for the reason the shared constant existed:
so they cannot drift to different wording on an element neither can
place (#460).

Writing a test that pins the new message turned up a second defect in
the same method. Every exception message in this file interpolated its
figures with the current culture, so the content area printed as
161,6pt on this machine and 161.6pt on an English runner. A test
pinning any of them would pass on CI and fail locally, or the reverse.
All four now format invariantly: the new band message and the three
that were already there for a non-positive content area and for
margins meeting the page width or height. Fixing one of four identical
instances and leaving three was not defensible.

Refs #365
Truncating a band makes the loss visible in the page, but a caller
still had no way to detect it in code. BandTruncations now reports it,
following the notify-and-continue shape Document.TextEncodingWarnings
already set.

One report per band, not one per page. A per-page list would hold two
entries per page, 9,900 of them on the 4,950-page document the defect
was reported against, and it would put a list append back into the
per-band-per-page path this branch exists to bound. Two slots need no
cap, so no options type is invented for them.

The report names the page that lost the most rather than the first
page cut. With a {page} or {pages} token the resolved text lengthens as
the number gains digits, so the worst page is the one that tells a
caller how much shorter the template has to be. Keeping the worst is a
comparison on the dropped count, so it costs no history.

It carries counts and not the text. Two existing channels bound what a
diagnostic retains, the reader's excerpt helper and the conformance
context, and a template can be arbitrarily long, so holding one here
would turn a caller's own input into a comparably sized retained
allocation. A caller already has the template and now knows how much
of it survived.

Public on DocumentRenderer as well as Document, unlike
TextEncodingWarnings, because there is no other route to it: a canvas
can be asked what it could not encode, but only the renderer knows the
content box a band was measured against. The three save paths reach one
collector rather than repeating the same two lines, which is the drift
the shared too-tall message exists to prevent (#460).

Twenty-four PublicAPI.Unshipped.txt entries, taken from what the
analyzer demanded rather than hand-transcribed.

Tests: five cases, all failing with the recorder disabled. One of them
started out vacuous, asserting the same unchanged list twice under a
comment that speculated about a second save. Measured instead: a second
save throws from the underlying PdfDocument before the collector runs,
so the first report survives and the collector's Clear is unreachable
through that path. The test now pins that, including the exception
message, which names a type a layout caller never used.

Refs #365
Four entries under Unreleased: the three fixes and the new
BandTruncations channel.

Placed under Unreleased rather than in a dated 2.3.2 section, which
differs from the plan for this work. The plan's reasoning was that a
dated section stops the next minor announcing these a second time, and
that concern is real, but this repository already has a mechanism for
it: #461's fixes went under Unreleased on main and #465 is moving them
into a 2.3.1 heading at release time. Following the practice the
history actually shows rather than inventing a 2.3.2 heading above a
2.3.0 one, since main carries no 2.3.1 heading yet.

Refs #365
Three reviewers on the running-band change found twelve findings at
medium or above, every one mine, and three of those were false
sentences rather than code faults. This is the fix round.

Code:

The report could name a page present in no output. SaveAsync and
PrepareForSigning collected between the layout and the write, so a
second call on an already-written document ran a whole second layout,
appending pages to the same PdfDocument, collected from it, and only
then threw. All three save paths now collect after their write
succeeds, which also makes the collector's Clear consistent rather than
reachable through a failure on two paths out of three.

The too-tall message's figures did not close. It showed a 200.0pt page
and 18.4pt of bands and then reported 161.6pt, leaving out the 20.0pt
of margins, which is the larger term, and omitting reducing the margins
from the remedies. That is the same fault the commit accused the old
message of. It now names both terms and the arithmetic closes.

Consecutive spaces left a trailing space in the drawn text, so the
width returned charged the alignment formula for ink that is not there
and shifted a centred or right-aligned band by 2.78pt per space at
10pt. Only the first space of a run is a cut point now.

The culture sweep was incomplete and the claim about it was false. The
previous commit fixed four messages and said all four, while the same
file held six and the assembly held twelve. Every exception message in
VellumPdf.Layout that interpolates a floating-point figure is now
invariant: six in DocumentRenderer, two in LayoutImageRenderer, four in
PieChartRenderer. LayoutBox.ToString is left alone deliberately, being
a shipped public member rather than a message, as are interpolations of
integers and enumeration members, which carry no separator to vary.

Claims:

The byte-identity justification asserted a movement that does not
happen. Substituting the running total for the whole-string measurement
moved no text matrix across 360 banded documents; the drift is about
7e-13pt against a five-decimal output format, and a 120,000-sample
replication found one formatted value differing. The line stays because
it is the more accurate width and costs nothing, and the comment now
says that no test defends it.

"No layout renderer brackets its drawing in q/Q" was false in five
places. LayoutImageRenderer and PieChartRenderer both do, and the
chart's own comment says it brackets precisely to stop fill colour
leaking. Narrowed to the two text renderers, which is what the argument
needs.

"Every banded document gains one colour operator per band per page" is
false at the boundary this change introduces: a band that fits nothing
returns before the colour is set and gains none.

The surrogate comment claimed a cut can never leave a lone surrogate.
True for well-formed input only. A lone surrogate is kept as one unit,
and because the walk stops early the embedded path's throw now depends
on whether it sits inside the fitted prefix, where before the whole
template was always measured. Malformed UTF-16 is caller error either
way, but the comment asserted a safety it does not have.

The zero-advance hole now states its consequence and not just its
mechanism: a band in Symbol or ZapfDingbats measures zero however long
it is, is never cut, and is still positioned from a width of zero, so
the defect this fixes survives for those two faces with no report.
Measured: a 500-glyph Symbol footer emits all 500 glyphs. Filed as
#470, and unfixable from here, which has no width to work from.

Tests:

Three paths had no test, each confirmed by deleting the code and
watching the suite stay green. The embedded-font colour branch, the
renderer's own BandTruncations property — whose documentation claimed a
test that did not exist — and the width a word-boundary cut returns,
where a mutation moved the band 2.78pt with every test passing.

The property suite's band templates were short because truncation was
broken, which is the exclusion PR #467 said belongs in the pull request
that fixes the defect. Widened here, and removing truncation now turns
the page-box property red. Widening also exposed a coupling of my own:
a long template cutting at its first space drew exactly the cell word
and inflated the per-element placement counts.

Refs #365, #470
A confirmation reviewer re-measured all twelve fixes from the previous
round. Every one holds behaviourally. Three claims about them did not,
and all three were counting errors.

The culture-sweep count was wrong a second time. The previous round
wrapped two messages in LayoutImageRenderer and said twelve, but
PdfImageXObject.Width and Height are int, so those two carry no decimal
separator to vary and the wrappers changed nothing. They are reverted,
and the count is ten: six in DocumentRenderer and four in
PieChartRenderer, counted as distinct messages rather than interpolated
segments. The same commit message had excluded integer interpolations
two sentences after wrapping two of them.

The byte-identity claim had a second counterexample, and it is one the
branch's own property generator produces. A band whose template is
empty previously emitted a text object showing an empty string and now
emits nothing, which removes five lines per band placement and, on a
document whose only text was such a band, the page's /Font entry as
well. So two changes here move bytes for a document that was already
fine: truncation for an empty template, and the colour change for every
band that draws.

"Five cases, all failing with the recorder disabled" was false. Four of
the five fail; Band_thatFits_reportsNothing asserts an empty report and
passes with the recorder gone, which is correct for a control but not
what the sentence said. The pull request's own table said four, so the
two disagreed.

Two universals are softened to what boundary measurement supports. The
too-tall figures are printed to a tenth, so the printed terms need not
sum exactly to the printed result — measured, margins of 10.02 and a
footer of 18.04 print 20.0 and 18.0 against a content area of 161.9 —
and the comment now says the point is to name every term that shrank
the box rather than to be arithmetic checked to the last digit. And the
drift figure understated its own maximum: 9.1e-13pt over 120,000
random strings, not about 7e-13, and the one differing formatted value
it cited could not be reproduced, so the claim is now that substituting
the running total moved no byte of any content stream measured.

One test is renamed. An all-space template does keep its spaces,
because the first space sits at index 0 and the word-boundary branch
refuses that, so keepsNoTrailingSpace overstated what the guard does.
It is about a run following a token, and says so.

Refs #365
Third review round on this branch, three findings, all wording.

The claim about an empty band was imprecise in four places. The page's
/Font dictionary does not disappear: PdfPage sets it on every page
unconditionally, so it survives as an empty dictionary. What goes is
that band's entry inside it and the font object the entry pointed at.
Measured on a document whose only text was an empty-template band:
/Font occurrences 2 to 1, /Type /Font objects 1 to 0, /Helvetica 1 to
0, and the surviving resources read /Font << >>.

The file contradicted itself. Correcting the changelog to say two
changes move bytes for an already-correct document left the comment
thirty-nine lines below still saying one change does. Both now say two
and name each other.

The changelog kept the drift figure the previous commit declared wrong,
because that commit corrected the code comment and never touched the
changelog paragraph. Both now say the same thing, and neither states a
maximum: a reviewer could not reproduce 9.1e-13 and measured 2.8e-13
over short strings and 6.4e-12 over long ones, so the number depended
on sweep parameters nobody had written down. What is load-bearing is
the gap to what the output can represent, which is six orders of
magnitude, so that is what both now say.

Refs #365
@Tim81
Tim81 merged commit 4788c4b into main Sep 10, 2026
4 checks passed
Tim81 added a commit that referenced this pull request Sep 10, 2026
…r box (#472)

One mechanism, four sites. A measured extent positioned content without
checking that it fit, and a centre or right alignment then put a coordinate
outside its box. #469 fixed the running band; this takes the image, the pie
chart, the list marker and an unbreakable glyph. The two table sites are
#473 and #477 and belong to the pull request that rewrites that code.

An explicit image width and a chart diameter are clamped to the area their
layout was handed, not to the width left after their own margins deflate it.
That distinction decides the fix rather than decorating it: PieChart.Margins
defaults to 6pt, so a Diameter of 300 already spans a 300pt content box
exactly, and clamping against the deflated 288 would have moved a correct
document.

Clamping alone is not sufficient, and only centred content hides that. Left
and Right take their offset inside the deflated area, so content clamped to
the content box is then pushed out of it by a margin: measured 4.8pt off a
454.4pt page in each direction. The drawn position is therefore clamped into
the content box, which cannot fire on content already inside it. An earlier
revision switched the alignment basis instead and moved documents that are
correct today, which review caught.

A list item's gutter widens to fit its own marker, per item rather than per
list, so the 26 items that render correctly do not move. It widens only
while the content's widest word still fits, because a gutter that leaves a
sliver does not overprint, it shreds: one point of surviving width turned a
two-letter item into one glyph per line and pushed the following paragraph
360pt down. Words are split the way ParagraphRenderer's wrap splits them,
which means not on a non-breaking space, since the wrap treats that as a
word character and a bound that split on it broke words the caller's own
indent kept whole.

An unbreakable glyph cannot be made to fit, so its line's origin is floored
at the box's left edge and the overflow goes right. This is the clamp #469
declined on its own formula, and the two are different decisions: there the
fitted width is proven not to exceed the box, so a floor would assert the
opposite of the proof beside it.

The test reader had to be corrected first. It bounded every curve by its
control hull; it now walks the path in order, tracks the current point
through m, l, h and re, and solves the derivative per axis for the drawn
extent. That is not a bug fix, and the pull request says so: at the default
start angle the hull span equals the true extent, so the suite as it stood
could not have caught an over-read. The exact walk is what makes a generated
start angle testable.

Evidence. 211 documents rendered before and after and hashed over their
decompressed content streams, each row carrying a text-run count so a
difference says whether text moved or was lost; six rows differ and every
one keeps its count. Each fix was reverted in isolation and the test naming
it confirmed to fail with the pre-fix number. 6898 tests pass in Debug and
in Release.

Three review rounds and a fourth on the delta found two defects in the fixes
themselves and thirty sentences that claimed more than the tree supports.
Both defects are recorded in the pull request rather than quietly repaired:
a position clamp whose left-associated bound cancelled and threw, and a
gutter bound that split on a non-breaking space.

Refs #365
@Tim81
Tim81 deleted the fix/running-band-truncation branch November 21, 2026 06: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