Skip to content

fix(layout): read tabs, line breaks and form feeds in cells and bands - #679

Merged
Tim81 merged 56 commits into
mainfrom
fix/table-cell-breaks
Nov 23, 2026
Merged

Tim81 merged 56 commits into
mainfrom
fix/table-cell-breaks

Conversation

@Tim81

@Tim81 Tim81 commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #611

What changed

A table cell split its text on U+0020 only. A tab reached glyph lookup as glyph 0 in an embedded font (the ToUnicode map held <0000> <0009>, and veraPDF failed PDF/A-2u clause 6.2.11.8) and as a raw 0x09 byte in a Standard 14 font. A line feed stayed inside the word: glyph 0 in the middle of one line, or the string escape \n. #613 item 34 is the same path for a form feed in a cell or a running band.

  • A cell reads its text by one rule. CR LF, a lone CR and a lone LF each end a line. An empty line between two of them is a blank line one leading tall, and so is the one after a trailing break (a<LF> is two lines in a cell; a paragraph draws one). Runs of spaces are kept as written (a paragraph collapses them). Every other white-space control character (tab, form feed, line tabulation, next-line, U+2028, U+2029) is one space, so none reaches GetGlyphIds or ShowText. The no-break spaces and the other Unicode space separators (U+2003 and so on) are written as before; a paragraph reads the separators as spaces, and that parity is left for a later major (see below).

  • An automatic column takes its minimum from the widest word and its maximum from the widest line, each line measured by itself where 2.3.3 measured the whole text. The width it is given is shared out as before and can be more than the maximum or less than the minimum.

  • A running band draws a tab, a line feed, a carriage return or a form feed as one space, in its template and in the text a page label prints for {page} (a PageLabelRange prefix with a tab or line break wrote raw control bytes in Helvetica and glyph 0 in DejaVu under PDF/A-2u; both are tested, veraPDF included). The band measures and cuts the text it draws. This covers Tracking: defects found while doing the v2.4 work (not yet fixed) #613 item 34.

  • Rows that cannot be cut keep the unbroken layout of their cells when reading the cells' breaks would refuse them. A header row and rows joined by a RowSpan are never cut between lines. When a cell's line breaks, or its other control white space read as spaces, would leave such rows no room on a page, 2.3.3 saved and the new layout would throw. The cause is not only a line break: a tab is one space wide where 2.3.3 measured the raw character at its own width, so a tab can tip a table with no line break in it (ATabThatWouldTipARowSpanGroupOverThePageIsLaidOutUnbroken: a, ab<TAB>ab, 46 words). The cells concerned are wrapped at spaces alone and sized from their whole text, as before, with each tab and break measured at its font's width and then left out of what is drawn. The save lists each as the new LayoutDiagnosticCode.CellWhiteSpaceDropped (301, a warning; StrictDiagnostics saves). The rule is stated once, in the XML documentation of Cell.Content: when the header rows and a group have no room, the order in which they are judged and relieved, the cells each step reaches, and the all-header table. The other members (TableElement, LayoutDiagnosticCode, TableRenderer.Layout, the runtime message, the CHANGELOG) say what they add and point there.

  • A group is judged again after its own step. A step that adds only cells of the group's own rows in fixed-width columns changes no height another group reads, so only that group's rows are measured again and the group is judged once more before the next one. A step that adds a header cell or a cell in an automatic column ends the pass, because it can change other rows' heights. It does not when the cells all lie in the group's own rows and every column width comes out bit for bit as it was. This is group-by-group judging: each group is judged on the heights the earlier decisions leave. Judging the next group on the header as it stood before a later pass relieved it gave a different answer (AGroupIsJudgedAgainAfterItsOwnStepBeforeTheNextOneIsJudged).

  • Every group is judged in order, however many there are, and the decision keeps what each cell measures. There is no limit on the number of measurements. A cell's longest word and widest line are kept per mode, and its line count with the interval of column widths over which it holds, a word broken at its characters included, because each comparison that decides where it breaks bounds the interval like the others. After a step the column widths come from the per-column widths kept for the pass, raised by what the step's cells contribute unbroken; when a cell would contribute less, the table is measured again. A step that gives up only cells in the group's own rows, and leaves every column width bit for bit as it was, does not end the pass, and a table resolves its grid once for all its pages. A cell is still measured again when a column width leaves the interval its count holds over, so "once" would be false; "Cost of the fallback" has the counts.

  • A last step relieves a header or group that a cell outside it narrowed. The width of every column follows from the cells of the automatic columns, whichever rows they are in, so a cell in a column that no cell of the group is in can make the group's columns too narrow, and no step reached it. When a header or a group still has no room after the first three steps, every cell that holds control white space and spans an automatic column is laid out unbroken. The widths are then the ones 2.3.3 measured, and so are the heights of each header or group that still had no room; a group that fits keeps its breaks, so it can be taller than that. Each cell given up is reported as 301 where it is drawn. The rule is stated once, in Cell.Content; TableElement and TableRenderer.Layout say that a cell in an automatic column can be among those given up. The review of an earlier head found three of 3,000 random long tables (seeds 366, 1482, 2461) that 2.3.3 and origin/main saved and this branch refused, and a minimal one: a 400 x 300pt page, Helvetica 10, columns 100, 100 and automatic; rows 0 and 1 joined by a RowSpan over a 38-character text; row 2 holding, in the automatic column, 37 W, a line feed and 4 W. Its group was 424pt tall with 280pt left, and is 100pt.

  • A table reads its cells' breaks only where the document lays it out. The document addresses each context it builds to the renderer it calls (the mechanism of Keep the continuation limit's verdict for elements that lay out differently from 2.3.3 #686, merged as feat(layout): add one shared continuation-limit mechanism #690). A TableRenderer that a caller's renderer holds and forwards Layout to, or that is laid out under WithArea or the public constructor, is laid out by its twin: every cell unbroken, nothing reported, so its pages, and what it refuses for room or for the continuation limit, are those of the table as main lays it out, and the continuation limit holds however the table is reached. Its Draw leaves the control characters out of the drawing, as the document's own fallback does. Main wrote glyph 0, a raw control byte, ? or the font's own glyph for them and, for glyph 0 and ?, reported NotdefGlyph or UnencodableCharacter; this build does neither (see "For the maintainer" and "Differential under StrictDiagnostics"). A wrapper's Draw has to forward to the table, because the document draws the instance it called. The public XML documentation of IRenderer.Layout, TableRenderer.Layout, TableElement, Cell.Content and LayoutContext.WithArea says so.

  • The fallback is decided once per width and set of page heights and carried to the renderers for later pages, with the grid and heights it was made with, which those pages do not resolve again. The key leaves out the boxes' x, which mirrored margins move on every other page.

  • XML docs: Cell.Content, Row.AddCell(string), TableElement, TableRenderer.Layout, RunningBand.Template, LayoutDiagnosticCode, Document.Diagnostics; the one existing test that pinned "a cell and a band hand the raw 0x0C to the font" now pins a space.

  • New internal Core/LayoutText.cs holds the line-split and control-space rule. ParagraphRenderer is untouched.

  • A table that is refused when every cell is measured as one line stays refused. The decision gives up a cell's breaks only where a header or group has no room, which could leave a table that main refuses saving with its breaks read. After the decision, when some cell that holds control white space still keeps its breaks, the table is measured once more with every cell unbroken, from the same cache. The trial is a check of what the layout would do on a fresh page: the header rows must fit, and so must every run of rows the layout never splits (BuildRowspanBlockedSet), unless the run is one row that can be cut. If the trial is refused, the table is laid out that way and the save throws what main throws. Otherwise the decision's widths and heights are put back. The trial measures embedded text without adding any of it to the font's subset: without that, the control characters of cells that keep their breaks were added to the subset of an embedded font although none is drawn (found when 1,196 of 4,439 saved tables of generator X came out with another subset tag than before the check; none does now).

  • A table whose breaks would take more than 50,000 page continuations is laid out with every cell unbroken, and a table whose unbroken layout would is refused as before. The limit stays. The table reports to the document, through the shared mechanism, an upper bound on the continuations of its placement in either layout: the larger of the bound over the grid that keeps the breaks and the bound over the grid that reads every cell unbroken (twice its units less one, or 3 + 4H / A when no row is cut; the argument is in the XML doc of ContinuationBoundOf). The earlier head bounded only the layout that keeps the breaks, and asked only whether that one reached the limit, so a table whose unbroken layout alone reaches it was saved where main and 2.3.3 refuse it (the limit table below). Where the bound is within what is left of the limit nothing more runs. Above it the document places the table twice without drawing, the unbroken layout first: if that reaches the limit or throws, the table is that layout and the save throws what main throws; if the layout that keeps the breaks reaches it, the table is laid out unbroken from its first page, main's measurement, so it saves what main saves in main's pages; otherwise it keeps its breaks. The verdict is kept for each place the table starts, so each start is probed once however many passes and simulations of the keep rules ask. Each cell the fallback leaves unbroken is reported as 301 with a message that names the limit, and only where the document chose the fallback.

  • A span declared in a header row makes no group of the rows under it. The layout breaks between those rows (BuildRowspanBlockedSet starts at the first data row), so the decision judged them as a group the layout never keeps whole and gave up breaks that fit. Each of those rows is now judged by its own height, and a span declared in a data row is still a group. The mismatch on main, where InSpanGroup and the refusal messages count a header-declared span and the layout does not, is not changed; it belongs with Tracking: defects found while doing the v2.4 work (not yet fixed) #613.

Deliberate output changes

  1. A<TAB>B in a cell of a table the document lays out: (A B) in Standard 14, a space glyph (glyph 3 in DejaVu Sans) between the letters in an embedded font, no <0000> ToUnicode entry.
  2. line1<LF>line2, cr1<CR><LF>cr2, a<LF>: one show string per line, the next baseline one leading lower, rows taller (12pt: 2 x 14.4 + 8 = 36.8). Automatic columns take their width from the widest line.
  3. A form feed, line tabulation, next-line character, U+2028 or U+2029 in a cell or a band is a space.
  4. A tab, line feed, carriage return or form feed in a band template or in a page label's text is a space, and is measured as one. A band that fit can now be cut: A + 120 tabs + B in Helvetica 10 on a 300pt page saved with no truncation on origin/main and now draws 1 of 122 characters and lists BandTruncated, which StrictDiagnostics refuses. A band that holds a tab is also placed by that width: a centred one moves by half the difference between the width its font gave the tab and the width of a space, a right-aligned one by the whole difference, a left-aligned one not at all. The shift comes from this change to the band and not from main: Page {page}<TAB>of {total} at 8pt starts 1.112pt further left when centred and 2.224pt further left when right-aligned in Helvetica (main measured the tab at 0; 278/1000 x 8 = 2.224pt), and 1.128pt and 2.256pt further right in DejaVu Sans (the glyph 0 main wrote for the tab is wider than a space). Measured on origin/main and on this build with one header and no table.
  5. A header row or RowSpan group that has no room on a page, when its cells' breaks or other control white space are read, keeps the 2.3.3 geometry, with the tabs and breaks left out of the drawing (see above).
  6. A table that a caller's renderer holds, or that is laid out under WithArea or the public constructor, keeps main's layout and pages and leaves its control characters out of the drawing: A<TAB>B is (AB), and A<U+2028>B is (AB) in Helvetica where main wrote the tab as a raw byte and U+2028 as ?. A DejaVu Sans cell holds no glyph 0 and the ToUnicode map no <0000> <FFFD> entry for it. The save lists no NotdefGlyph (102) or UnencodableCharacter (103) for these characters.
  7. With StrictDiagnostics on, a control white-space character in a cell, in a table the document lays out or one a caller's renderer holds, no longer makes the save throw (see below and "Differential under StrictDiagnostics").
  8. With StrictDiagnostics on, a control white-space character in a running band's template or a page label's text no longer makes the save throw either. Main reported it as NotdefGlyph or UnencodableCharacter; the band now draws it as a space and reports nothing.

With StrictDiagnostics off, no table that main refuses saves here, and none that main saves is refused: a table that main refuses is refused with main's message, a table whose breaks would pass the 50,000-continuation limit is laid out as main measures it and reported as 301, and a table that a caller's renderer holds is laid out as main lays it out (0 of 26,000 documents differ in what saves or in the refusal message, in each of four contexts, and none in the page count in the three contexts a caller builds: pass-through, WithArea and the public constructor. In the direct context 10,634 of the documents both builds save have another page count than main (Y 1,330, X 4,157, A 1,938, G 2,487, P 722), because a cell's breaks are read there (deliberate change 2); see "Differential with the shared limit mechanism").

With StrictDiagnostics on, one class of documents changes: those whose only error items were the reports of a control white-space character in a cell or in a running band. Such a character reaches no font now, so the save lists no NotdefGlyph or UnencodableCharacter for it. A document that main refuses for those reports alone saves here. Main's refusal was its own report of the #611 defect (glyph 0, or ?, written for a control white-space character), the defect is gone, and the output that now saves passes veraPDF: a PDF/A-2u file made this way is compliant, and main's own file for the same table fails clause 6.2.11.8 (see "Differential under StrictDiagnostics"). A control character that is not white space, such as U+0001, is still reported and refused in a cell. Every other strict-mode result is main's, measured over the same 26,000 documents in four contexts. The refusal is not restored: it would make a table or a band refuse the input that this change corrects.

A table whose cells hold none of tab, CR, LF, form feed, line tabulation, next-line character, U+2028 and U+2029 saves to the same bytes as before (differential below). A paragraph is unchanged: no byte of ParagraphRenderer moved.

ISO 19005-2, 6.1.13: this change shortens show strings (one per line) and writes no q or Q.

For the maintainer

Three choices are provisional. All are implemented as stated and are cheap to change.

  1. A fallback cell draws its control characters as nothing. The cell is wrapped with each at its own width (zero in Helvetica) and, drawn as spaces, came out wider than measured: 60 LF-joined ab in a 100pt column drew 102.86pt in an 88pt box, and on a 400pt page with automatic columns the first line ran from x=16 to 446.9. Leaving them out makes the drawn width equal the measured one. Measured now: 0 lines past their cell on those two fixtures, and pdftotext -raw returns all 120 letters in order (they run together in the extraction as they do in the drawing). The alternative is to wrap the fallback with each control character as a space. Heights then differ from 2.3.3, so a table 2.3.3 saved can be refused: built and measured on the 20,000 tables with control characters, wrapping alone with each as a space refuses 16 that origin/main saved, and wrapping and sizing the automatic columns that way refuses 26, against none now.

  2. Other Unicode space separators in a cell are left as written; paragraph parity for them is left for 3.0. A cell read them as one space in an earlier revision of this branch, as a paragraph does. That revision changed 9,408 of 20,000 tables whose texts hold no tab or line break (the one text with a separator there is the U+2003 one), turned two tables that saved into refusals (seeds 12243 and 4668; both save again with the rule off), and it changed 1,846 of 4,000 valid tables in DejaVu Sans, where U+2003 is a real glyph. With the rule off, none of the 40,000 Helvetica tables goes from saved to refused, and the 20,000 without control characters are byte-identical to origin/main. Cell, paragraph and band still differ on these characters; Cell.Content says so.

  3. The pass limit is gone, and every group is judged on the heights the groups before it leave. An earlier revision of this branch stopped passes from ending at the first shared step after 8 measurements, which made a table of many groups cheaper and changed which cells a later group gave up. With the measurements kept per cell, and with a step that moves no column not ending the pass, every table in "Cost of the fallback" takes less time and less allocation than 2.3.3 and than origin/main on the same table, in the single run measured. The decision is exact at any size. Had the cost stayed far from origin/main I would have kept the limit; it did not. The cost of groups that each widen an automatic column still grows with the square of their number: 1,000 of them allocate 6.5 times what 400 do.

  4. A table a caller's renderer holds draws without its control characters, where main drew them. The pages, the cell rectangles and the refusals are main's: over 26,000 documents with every table behind a forwarding renderer, 0 differ in what saves, in the refusal message or in the page count. The bytes differ where a cell holds a control character, because the twin is the same layout the document's fallback uses and that layout leaves them out, where main wrote a glyph, an escape or a raw byte for each (<0000> and (lorem\n\niii) in the lines I opened). Making the twin draw them would reproduce Layout: a tab or newline inside a table cell is written as glyph 0 (.notdef) with an embedded font, and as a raw control byte with a standard-14 font #611 for a caller's renderer: <0000> in the ToUnicode map and a PDF/A-2u failure. Of the first 40 documents of each of the five sets, 123 were saved by both. In each of them every show string that differs is main's string with its control characters removed, or with the glyph 0, ? or U+2028 and U+2029 glyph written for them; a line that holds only control characters is not written at all. 12 of the 123 also differ in the x of a text origin, and all 12 are the running header Page {page}<TAB>of {total}, not a table: that shift is deliberate change 4 (the header is centred and its tab is now measured as a space), 1.112pt in Helvetica 8. In 166 documents saved by both under a context built with the public constructor (seeds 40 to 99), 16 differ in an origin, all of them band lines. No table origin differs in either sample. The ToUnicode map and the subset also lose the entries for glyph 0. Say if main's bytes are wanted here instead; keeping the characters would restore NotdefGlyph and UnencodableCharacter for a caller's renderer too, and with them the PDF/A-2u failure.

2.3.3 against this build

Page 2000x600, 10pt margins (580pt content), Helvetica 10 (12pt leading, 8pt padding), one column 1900pt wide unless stated; a cell is n two-letter words joined by LF.

Input 2.3.3 This build
ordinary row, 46 / 47 words saves, 1 page, one line saves, 1 page, 46 / 47 lines
ordinary row, 48 / 49 / 100 words saves, 1 line saves, 2 / 2 / 3 pages (cut between lines)
header of 46 words + a 20pt row saves saves, 46 lines, no report
header of 47 / 48 / 49 / 100 words + a 20pt row saves saves, one line, warning 301
RowSpan group (rows 0-1), 46 words in row 0 saves saves, 46 lines, no report
same, 47 / 48 / 49 / 100 words saves saves, one line, warning 301
two-row group, 23 words in each row saves saves, no report
same, 24 / 25 / 30 words saves saves, both cells reported
header of 30 words over a group of 268pt saves saves; the header cell reports (the group has no break of its own)
three rows chained by RowSpans, 16 words each (3 x 200pt) saves saves, all three cells reported
header fallback cell, auto columns 10 570 1930.09932 20, 1940.09932 570 49.90068 20 the same two rectangles

Differential against origin/main (4dd521f)

Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.

20,000 random tables per set (1 to 3 columns, up to 11 rows, header rows, RowSpan, ColSpan, fixed or automatic widths, tagged or not, two page heights, Helvetica), saved on origin/main and on this branch; dates, /ID and XMP ids normalised. The first set draws texts from 17 kinds: letters, words, spaces, an accented letter, U+0001, U+007F, a no-break space and a text with U+2003, and none has a tab, line break, form feed, line tabulation or next-line character. The second adds ten kinds that do.

Texts Identical bytes Changed Saved before, refused now Refused before, saves now
without tab, line break, form feed 20,000 0 0 0
with them 1,968 (666 refused identically on both) 18,032 0 6 (11098, 13279, 16422, 18306, 18493, 19407)

In DejaVu Sans (the same generator, seeds 0 to 3,999), the 4,000 tables without those characters are byte-identical to origin/main (259 refused on both). Of the 4,000 with them, 3,576 change, 9 are refused on origin/main and save here (seeds 496, 793, 1069, 1138, 1372, 2166, 2683, 2723, 3033), none is saved there and refused here, and 182 are refused on both.

Line past a cell border (a show string that ends beyond the right edge of the smallest cell rectangle holding its start, counted on saved documents of the second set): 149 documents on origin/main and 178 here; 41 cross here and not there. In 38 of the 41 the crossing show string is one character long and none carries a fallback report; I read the other three: seed 9086 is one glyph and a space, seed 13766 (3 characters) is a text drawn below its row, and seed 16449 is a ColSpan cell measured at one column and drawn at another under a RowSpan, a mismatch origin/main has. Of the 206 saved documents that carry a fallback report, 8 have a line past a border, the crossing show strings being 1 to 14 characters long; I did not trace them.

Differential of the caches

Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.

The same seeds saved by three builds, with Timestamp and DocumentId pinned and the SHA-256 taken over the whole file: origin/main (fc2b248), this branch at 574806c with the pass limit set to int.MaxValue (exact group-by-group judging, no caches), and this build. The sets are the 20,000 Helvetica tables without and with control characters, the same generator in DejaVu Sans (4,000 each), and three generators of tables with many RowSpan groups and header rows (3,000, 2,000 and 2,000; pages 300 to 2,000pt wide).

Tables Bytes differ, exact against this build Differ from origin/main Saved there, refused here Refused there, saves here
Helvetica, no control characters 20,000 0 0 0 0
Helvetica, with them 20,000 0 18,036 0 6
DejaVu, no control characters 4,000 0 0 0 0
DejaVu, with them 4,000 0 3,578 0 9
groups, generator 1 3,000 0 1,072 0 31
groups, generator 2 2,000 0 915 0 11
groups, generator 3 2,000 0 1,720 0 4

55,000 tables, 0 differences between the exact build and this one, saved or refused. This run had the verification hook on: each cached line count that was used (568,866 of them) was checked against a fresh wrap of the same cell at the same width, and none differed. The caches answered 1,081,581 width lookups, 9,151 steps kept a pass going, and 42,320 layouts kept the grid of an earlier page. Origin/main is the fc2b248 build, before the chapter token of #681.

Cost of the fallback

Release, net10.0, a 2000 x 600pt page, Helvetica 10, one process per row, one run each on a shared machine, so read the times to a factor of two. The MB are cumulative allocation (GC.GetTotalAllocatedBytes), not memory in use: the peak working set was 71MB or less in every run. Diagnostics are capped at 1,000. "Fillers" are groups of two rows: two short cells in 36pt columns and a cell of 60 lines with RowSpan = 2 in an automatic column. "Fillers, spaces" is the same table with spaces between the lines, which has nothing to give up. "Grow n" has n groups whose cell has 48 + i lines, in three automatic columns, so each step widens a column. "Cascade 400" is 400 groups that each tip the next (columns 1980 and automatic). 2.3.3 and origin/main (a34a281) measure each cell as one line; 72330b7 is the previous head.

Table 2.3.3 origin/main 72330b7 This build
fillers 400 0.51s, 40MB 0.33s, 40MB 0.24s, 27MB 0.20s, 12MB
fillers 800 0.78s, 157MB 0.60s, 156MB 0.42s, 86MB 0.30s, 26MB
fillers 1,600 1.29s, 607MB 1.14s, 604MB 0.89s, 296MB 0.59s, 62MB
fillers 3,200 3.65s, 2,354MB 2.50s, 2,358MB 2.83s, 1,098MB 0.88s, 164MB
fillers 6,400 12.4s, 9,319MB 8.85s, 9,330MB 13.3s, 4,225MB 1.92s, 498MB
fillers, spaces 400 0.40s, 98MB 0.34s, 98MB 0.14s, 10MB 0.15s, 9MB
fillers, spaces 800 0.70s, 387MB 0.61s, 386MB 0.18s, 22MB 0.20s, 22MB
fillers, spaces 1,600 1.75s, 1,510MB 1.10s, 1,518MB 0.32s, 54MB 0.32s, 53MB
fillers, spaces 3,200 4.55s, 5,958MB 3.01s, 5,964MB 0.67s, 150MB 0.73s, 149MB
fillers, spaces 6,400 16.9s, 23,737MB 11.4s, 23,739MB 1.29s, 470MB 1.30s, 468MB
grow 400 1.97s, 1,909MB 1.57s, 1,912MB 1.02s, 876MB 0.67s, 58MB
grow 1,000 49.2s, 48,489MB 30.6s, 48,490MB 11.3s, 13,368MB 2.03s, 378MB
cascade 400 6.32s, 3,022MB 5.60s, 3,022MB 1.17s, 168MB 1.19s, 68MB

Where it stops. What the fillers cost over the same table with spaces is 3, 4, 9, 15 and 30MB at 400 to 6,400 groups, so the decision itself no longer grows with the square on that shape; what is left in both is the document's own cost, which also grows faster than the row count (9MB to 468MB over a sixteenfold increase of the spaces table). Grow still does: 1,000 groups allocate 6.5 times what 400 do (2.5 times the groups; quadratic would be 6.25) and take 3.0 times as long. Every step of that table moves a column width, so each ends the pass and the next pass visits every cell again; a line count is measured again when a width leaves the interval it holds over, 13,103 times at 400 groups and 37,730 at 1,000, against 135,397 and 768,035 on 72330b7. Three exact remedies the review named (per-column interval endpoints, measuring a row only when the group judged needs it, never judging again a group that cannot change) are not implemented: they change how the pass is organised, not how a cell is measured, and I stopped here.

How the cost was found. The decision was timed by phase in an instrumented build. At 1,600 fillers, deciding whether a step moves a column took 1,490 of 2,100ms and 232 of 278MB, because each step copied the set of cells read unbroken and resolved the whole grid. At 1,000 grow groups, 19.7 of 25.1s and 12.5 of 13.3GB went to line counts of a word broken at its characters, which were held for one exact width, so each new width measured every such cell again, with a string allocated per character. Both fixes are exact, not caps: a step raises the kept widths, and the interval is bounded by the comparisons that cut the word. The allocation left per pass was the owner text built for each cell's font-size check and an enumerator per row; both are gone.

Pins, by allocation: fillers at 400 and 1,600 groups stay under 1.5 times the same table with spaces (1.2 measured at both); 300 grow groups allocate under 60MB (32.6MB measured); a chain of 60 groups that each tip the next, under 30MB; counting the lines of a 3,000-character broken word allocates under 4KB. They replace two ratio pins: the fillers one held only near 400 groups (the ratio went 2.7, 3.9, 5.5, 7.3 and 9.0 from 400 to 6,400 on 72330b7), and the grow one passed with all four caches off because the baseline it divided by grew with them.

Differential, last step and incremental widths

Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.

Generators A (8,000 mixed tables), G (3,000 tables with many RowSpan groups near the page height) and P (3,000 long multi-page tables with mirrored margins, bands and repeated headers). Timestamp and DocumentId pinned, SHA-256 over each file, refusals compared by type and message. The builds are this branch, 72330b7, origin/main a34a281 and 2.3.3 (1c61fa6, whose Document has no pins and no MirrorMargins: its run uses the same generators without them and compares saved against refused only, so its row is not byte-for-byte the same documents).

Set Tables (saved here) Saved before, refused here: 72330b7 / origin/main / 2.3.3 Refused before, saves here: 72330b7 / origin/main / 2.3.3 Saved by both, bytes differ: 72330b7 / origin/main
A 8,000 (4,780) 0 / 0 / 0 0 / 116 / 1,047 0 / 3,281
G 3,000 (2,874) 0 / 0 / 0 0 / 16 / 22 0 / 2,858
P 3,000 (933) 0 / 0 / 0 3 / 192 / 260 0 / 741

The first 16 hex digits of sha256sum over the per-seed result lines (seed, saved or refused, SHA-256 of the file or the exception) of this build and of 72330b7: A 2164c7a534f20823 and 2164c7a534f20823, G 61ac3191c64f05db and 61ac3191c64f05db, P a84e2a96b9726b97 and 92eb2080639bd9ed. Against 72330b7 the only differences are the three tables it refused (P seeds 366, 1482, 2461); every other table saves to the same bytes or is refused with the same message. The commit that made the steps cheaper (2a1ffaa) changes no byte of any of the 14,000 tables against the commit before it. With the verification hook on, no cached line count differed from a fresh wrap, and every step that raised the kept column widths (3,949 in A, 36,478 in G, 6,108 in P) gave the widths of measuring the table again, bit for bit; 634 steps in A and 335 in P measured the table again because a cell would have contributed less, none in G. A separate probe checked the line-count intervals against a fresh wrap over 1,746,192 (text, width) cases, among them every fragment sum a broken word compares and each width's neighbours one unit in the last place apart, and the interval ends: 9,499,974 comparisons, 0 differences.

Differential, final

Generators X (6,000 tables, driven by the limit mechanism), A (8,000 mixed), G (3,000 with many RowSpan groups near the page height) and P (3,000 long, with mirrored margins, bands and repeated headers). Timestamp and DocumentId pinned, SHA-256 over each file, refusals compared by type and the whole message. Builds: this head, 329d10a (the previous head), origin/main a34a281 and 2.3.3 (1c61fa6, saved or refused only: its Document has neither pin nor mirrored margins).

Set Tables (saved here) Saved on main, refused here Refused on main, saved here Saved on 2.3.3, refused here Saved on 329d10a, refused here Both saved, bytes differ from 329d10a Messages differ from main where both refuse Verify mismatches
X 6,000 (4,439) 0 0 0 479 40 0 0
A 8,000 (4,664) 0 0 0 116 209 0 0
G 3,000 (2,858) 0 0 0 16 0 0 0
P 3,000 (741) 0 0 0 192 16 0 0
  • The tables that 329d10a saved and this head refuses are the tables main refuses (479, 116, 16 and 192, the same counts as main refusing and 329d10a saving). Of 329d10a's saved tables, the bytes of 4,399, 4,455, 2,858 and 725 are unchanged; the 40, 209 and 16 that differ are tables with a RowSpan declared in a header row, where the rows under it now keep breaks that fit (one run of the earlier commit 7583406 alone, 43, 217 and 22, before the refusals).
  • With the measurement hook on (every cell as one line), the saved and refused sets equal this head's in all four sets, so this head saves exactly where main saves (0 tables differ). The Verify hook checked every cached line count and every raised column width against a fresh measurement, and none differed (X: 8,181 raises, 28 measured again; A: 3,999 and 613; G: 36,478 and 0; P: 5,849 and 321).
  • A run of an intermediate build, before the trial measured without registering glyphs, differed in bytes from 7583406 in 1,196 of X's 4,439 saved tables, 1,628 of A's 4,664, 1 of G's 2,858 and 343 of P's 741: in the one table whose bytes I compared, the embedded font's subset tag. The rows above are from the final build, and the byte comparison with 7583406 had no difference in 4,439, 4,664, 2,858 and 741 saved tables when the trial was fixed.
  • The continuation check changed no byte of any of the four sets: none of them reaches the bound.

The continuation limit, built on this head (page 2000 x 40pt, one line of the cell per page; one cell of ab words joined by LF): 50,001 words keep their breaks and take 50,001 pages; 50,002 words are laid out unbroken, 295 pages, one report. On a 2000 x 600pt page: 2,350,047 words keep their breaks (50,001 pages), 2,350,048 take 295 pages and 2,500,000 take 314, as on main. A table (rows of a<LF>b on a 400 x 40pt page, 20pt of content) keeps its breaks at 25,000 rows (50,000 pages) and is laid out unbroken at 25,001 rows (25,001 pages, 1,000 reports and the sink's own entry for the reports it dropped) and at 30,000 (30,000 pages); main saves 25,000 rows in 25,000 pages, and the review found the previous head throwing at 30,000.

Differential with the shared limit mechanism

Generators X (6,000), A (8,000), G (3,000), P (3,000) and Y (6,000: PDF/A-2u, PDF/A-2b and PDF/UA-1 claims with DejaVu only, tagged documents, Times, Courier, Symbol, Helvetica and DejaVu, U+202F, U+2007, U+4E00 (no glyph) and NBSP, header rows and spans, data spans, tall LF cells near the page, mixed widths, keep rules, anchors, mirrored margins, bands). Timestamp and DocumentId pinned, SHA-256 over each file, refusals compared by type and the whole message. Builds: this head (built at b4a698c; 8e90128 changes one test file), origin/main c44a516 (the mechanism without this PR) and 2.3.3 (saved or refused only). Four more runs of this head: with the Verify hook (every cached line count and raised column width checked against a fresh measurement), with every cell measured as one line, and each of those documents with every table behind a forwarding IRenderer (Fwd, whose Layout and Draw forward to a public TableRenderer) on this head and on main. The head runs were repeated after the last source change and are byte-for-byte the same as before it.

Set Docs (saved here) Saved on main, refused here Refused on main, saved here Both refused, type or message differs Saved on 2.3.3, refused here Verify mismatches One-line hook differs from main (status or message) Forwarded: status, message or pages differ from main Saved by both, no control character: bytes differ (docs)
Y 6,000 (2,735) 0 0 0 0 0 0 0 0 (118)
X 6,000 (4,439) 0 0 0 0 0 0 0 0 (0)
A 8,000 (4,664) 0 0 0 0 0 0 0 0 (1,382)
G 3,000 (2,858) 0 0 0 0 0 0 0 0 (0)
P 3,000 (741) 0 0 0 0 0 0 0 0 (0)
  • 26,000 documents, 15,437 saved here. Documents with no control character in any cell or band that both builds save are byte-identical to main, embedded subsets included (118 of Y, 1,382 of A, and those same documents forwarded). No saved document carries a 301 under a forwarding renderer.
  • The 543, 253, 931, 6 and 68 documents that 2.3.3 refuses and this head saves are the documents main saves (0 differ from main): the 2.3.3 "too tall" refusals that Layout: a table row taller than the page is refused instead of paginated #516's cut saves.
  • Forwarded tables equal main's in what saves, in the refusal message and in the page count, with StrictDiagnostics off. Their bytes differ where a cell holds a control character, which is item 4 under "For the maintainer". With it on, see the next section.
  • Re-run after the empty-show change: every column is as above. Against 6773a13, the previous head, 0 of 26,000 documents differ in what saves, in the refusal message or in the page count in each of the four contexts, and the 1,500 documents without a control character that both builds save (118 of Y and 1,382 of A) are byte-identical to it and to main, direct and behind a forwarding renderer. Bytes differ from 6773a13 only in documents with a control character, where an empty line of a cell that holds control white space writes no show.

Differential under StrictDiagnostics

The same 26,000 documents (Y, X, A, G, P), each saved with StrictDiagnostics = true by this head and by origin/main c44a516, in four contexts (direct, behind a pass-through IRenderer, under WithArea, under the public constructor). A refused strict save leaves the items it found in Document.Diagnostics, so each document's error items were read from both builds, ignoring their counts.

Context Saved by this head Saved by main Main threw, this head saves Main saved, this head threw Both threw, same message Both threw, message differs
direct 7,800 3,279 4,521 0 12,896 5,304
pass-through 7,800 3,279 4,521 0 12,958 5,242
WithArea 7,800 3,279 4,521 0 12,958 5,242
public constructor 7,747 3,264 4,483 0 13,180 5,073
  • In every document that main refuses and this head saves, each error item main reported is a NotdefGlyph or UnencodableCharacter naming U+0009, U+000A, U+000B, U+000C, U+000D, U+0085, U+2028 or U+2029: 0 documents had an error item of another code or character, and 0 had none. This head reports no error item that main lacks in any document.
  • The band share of that. Of the 4,521 documents (direct) that main refuses and this head saves, the element kinds of main's error items are: 4,341 Table only, 170 Header or Footer only, and 10 both (4,483 under the public constructor: 4,305, 168 and 10). Of the documents where both throw, 239 differ because main lists a band item that this head does not (238 under the constructor); the band items are NotdefGlyph or UnencodableCharacter for a tab, a line break or a form feed in a band template or page label, which the band now draws as a space. Every item main lists that this head does not names one of the eight characters (0 items name another), in all four contexts, and this head lists no item that main lacks. The band's oracle is AStrictPdfA2uDocumentWithControlWhiteSpaceInABand_passesVeraPdf and ABandWithAControlSpaceInAPageLabelIsPdfA2uClean (veraPDF 1.30.4, flavour 2u, compliant).
  • Where both throw with different messages, every item main reports that this head does not is again a 102 or 103 for one of those eight characters, in every document of the three wrapped contexts. In the direct context 62 of the 5,304 have the same error items in both builds, and the message differs in what it names first: 59 in the page number, because the table's breaks move rows to other pages (deliberate change 2), and 3 in which of two items on the same page comes first.
  • A refusal that is not a strict one (too tall, the continuation limit) is main's in every document: with StrictDiagnostics off, status and message equal main's in all four contexts.
  • The oracle. A PDF/A-2u document (DejaVu Sans, a table of a<TAB>b, line1<LF>line2 and c<TAB>d, StrictDiagnostics on): origin/main throws NotdefGlyph (ISO 19005-2:2011, 6.2.11.8) ... U+0009 has no glyph in DejaVuSans, both directly and behind a pass-through renderer; this head saves both, and veraPDF 1.30.4 --flavour 2u reports both compliant (146 rules passed, 0 failed). With the switch off, main's file for the direct table fails veraPDF clause 6.2.11.8 and carries two error items, and this head's passes. qpdf --check is clean on both of this head's files, and pdftotext -layout returns line1 and line2 on separate lines for the direct table and line1line2 for the one a caller's renderer holds, where the words the characters separated run together as the twin draws them. The test AStrictPdfA2uDocumentWithControlWhiteSpaceInACell_passesVeraPdf pins this for both.
  • The generators above reach no continuation limit, which is why the limit has its own measurements below and its own tests at a limit of 300.

A table at the real limit (page 400 x 60pt, margins 10, Helvetica 10, two automatic columns; row 0 six mmmmmmmm joined by LF and s; then n rows of a and lorem lorem):

n main (c44a516) this head
50,000 saves, 50,001 pages (2,638s) saves, 25,003 pages (180s)
50,001 throws the continuation-limit InvalidOperationException (2,590s) throws the same exception (254s)

The previous head saved n = 50,001 in 25,004 pages, where main and 2.3.3 refuse. A wrapper (one cell of 50,002 ab words joined by LF, 2000 x 40pt page, 1900pt column, behind a forwarding IRenderer) is pinned at a limit of 300 by ATableAWrapperHolds_isLaidOutAsBeforeItsBreaksWereRead; at the real limit the previous head threw where main saved 295 pages.

Cost of the new checks

Release, net10.0, one run each on a shared machine, so read the times to a factor of two.

Table 329d10a This head
2,000 rows of four cells with a line break each, fixed columns 0.26s, 62MB 0.28s, 65MB
the same, automatic columns 0.31s, 62MB 0.37s, 69MB
20,000 rows, fixed / automatic 4.56s, 1,764MB / 3.80s, 1,479MB 4.59s, 1,790MB / 3.86s, 1,544MB
26,000 rows (3 lines each, 1,500 pages), fixed 7.22s, 2,792MB 7.27s, 2,829MB
40,000 rows, fixed 16.25s, 6,071MB 16.83s, 6,129MB
12,000 rows of a<LF>b on a 400 x 40pt page (24,000 pages) 6.5s 6.0s
25,000 such rows (50,000 pages, the most that keeps its breaks) 30.0s 55.7s
one cell of 50,001 LF-joined words, a page per line 1.85s 1.89s

The one-line trial costs 1% to 20% of time on tables that keep every break (the smallest tables show the larger shares) and 1.5% to 11% of allocation. It does not run for a table whose control-space cells have all given up their breaks. The continuation check is kept off tables far below the limit by the bound: the 26,000-row table is placed once, and an earlier bound of twice the rows placed it twice (13.9s and 5.0GB against 7.7s and 2.8GB). Near the limit it costs more layouts: 25,000 one-row pages took 55.7s where an earlier head took 30.0s, and the rows of "Cost with the shared limit mechanism" below are the head with the shared mechanism. Most of both is a cost per page that grows with the number of rows (BuildRowspanBlockedSet is rebuilt for every page); caching it for the table made the same run 22.4s in a scratch build, with more per-page work left. That is not in this branch.

Cost with the shared limit mechanism

Release, net10.0, one process per row, one run each on a shared machine, so read the times to a factor of two. Allocation is cumulative (GC.GetTotalAllocatedBytes). Main is c44a516. The shapes are those of "Cost of the fallback" and "Cost of the new checks".

Table main (c44a516) this head
fillers 6,400 17.80s, 9,320MB 1.88s, 499MB
grow 1,000 70.21s, 48,490MB 1.80s, 378MB
cascade 400 12.02s, 3,022MB 0.71s, 68MB
2,000 rows of four cells with a line break each 1.80s, 966MB 0.38s, 65MB
20,000 such rows 118.2s, 94,046MB 6.51s, 1,793MB
25,000 rows of a<LF>b, 400 x 40pt (50,000 pages, keeps its breaks) 207.1s 135.8s
25,001 such rows (the twin is chosen) 206.9s 106.5s
one cell of 50,001 LF-joined words, 2000 x 40pt 0.49s, 295 pages 3.81s, 50,001 pages

The last row is the exact limit: this head keeps the breaks of a cell that takes 50,001 pages and main lays it out unbroken in 295. The allocations are within 1MB of the earlier head's (fillers 499MB against 498MB, grow 378MB, cascade 68MB, 20,000 rows 1,793MB against 1,793MB in an independent run).

Tests

TableMainRefusalTests (18 cases, new), TableLastStepTests (7 new cases), TableContinuationLimitTests (21 cases, new) and TableStrictDiagnosticsTests (11 cases, new) with TableCellBreakTests and TableMeasureCacheTests. On the final commit, Release, with REQUIRE_ORACLES=1, REQUIRE_VERAPDF=1, veraPDF 1.30.4, qpdf 12.4.2 and poppler from C:\msys64\mingw64: Layout.Tests net10.0 and net11.0 each 2,461 run, 2,459 passed, 0 failed, 2 skipped (the two Linux-only pipe tests); Kernel.Tests each 2,666 run, 2,666 passed. The same Layout.Tests run in sequence (-parallel none) passes on net10.0 and on net11.0 with the stack-depth probes in it. Release build of VellumPdf.slnx 0 warnings; dotnet format --verify-no-changes, eng/clean-room-check.ps1 and generate-roadmap.py --check clean. The Kernel method that measures without registering has its own test now (MeasureStringWithoutRegistering_equalsMeasureString_andRegistersNothing, two fonts).

PaginationDepthTests counts PlaceLoop frames, and PlaceLoop carries [MethodImpl(MethodImplOptions.NoInlining)]. One commit changes only that test and that attribute line, so PR #682 can take it as it is. The probes counted PlaceRenderer frames, and origin/main c44a516 fails them: in full runs of its own suite in sequence (-parallel none) both probes read Expected: 1, Actual: 0 in four runs, two on net10.0 and two on net11.0. One further run on net11.0 passed (2,298 run, 0 failed). The likely cause is that the JIT inlined PlaceRenderer into its caller; I did not confirm that with a JIT dump. What the probe counts is true for the test's own renderer, which never reports: one PlaceLoop frame per Layout call. A renderer that reports puts two on the stack during a continuation probe, because the probe calls PlaceLoop from inside PlaceLoop. The attribute rules out a false failure from inlining PlaceLoop into PlaceRenderer; it does not guarantee that the JIT never turns a recursion into a loop. Mutants, each failing both probes on net10.0 and on net11.0: PlaceLoop calls itself for the overflow, in tail position or not, and PlaceLoop calls PlaceRenderer for it, in tail position or not.

The limit tests, at a limit of 300 page continuations (ContinuationSupport.Run): a table whose unbroken layout reaches the limit is refused with the message the one-line measurement gives (the shape of the limit table above), and one continuation fewer keeps its breaks; a table whose bound with its breaks read is within the limit and whose unbroken layout reaches it is refused (page 400 x 200pt, a bound of 153 against 301 continuations); a cell of 302 lines is laid out unbroken in the bytes of the one-line measurement and reported as 301 with the limit's message; a forwarding renderer in three ways (pass-through, WithArea, results cached by area) around a table of 302 lines saves in the bytes of the one-line measurement with no report and no probe, and around a table that reaches the limit is refused with that message; a forwarding renderer that lays the table out under a context it builds with the public constructor cuts no row, so a cell that does not fit a page is refused as too tall; a table that fits one page behind a forwarding renderer is drawn; under a context the caller built a table cuts no row and starts at its start row; a table within the limit keeps its breaks in the drawing pass of a document with a footer; the twin is one object. TheContinuationBoundIsNeverBelowTheContinuationsATableTakes reads the bound from the session the document makes.

Tests for the header spans, the one-line measurement and the limit: a header-span table at n = 18, 24, 26 and 34 (no cell is reported), a header span over two rows that fit alone, a row under a header span that has no room, and a span declared in a data row that still holds its rows; a table that is refused measured as one line, refused with the same message (three widths), its neighbours saved with their reports, a property over 600 shaped tables (tall header rows among them) and 250 long ones that every table refused measured as one line is refused with the same message, and a DejaVu table whose dropped measurement leaves no <0000> <FFFD> in the file; the limit exactly (50,001 pages keep their breaks), one over (the bytes of the one-line measurement, with and without a footer, and after a paragraph that makes the table move a page), a refusal by the limit's message measured as one line, the 2,350,048-word cell of the earlier body, and the bound (a property over 500 tables on short pages and 500 on tall ones that it is never below the continuations taken, and that 30,000 short rows have a bound under 50,000).

Mutations

Each applied in a detached worktree, built, and run against TableCellBreakTests and PageBreakTests (121 tests). The comment-only baseline fails none. The first group of rows below ran on an earlier build of this branch; the rows for the caches and the early cutoff ran on the final one, against the whole of Layout.Tests, and each fails at least one test.

Mutant Failing tests
group loop judges the next group in the same pass (the stale-height defect) ARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudged
header step does not end its pass AFallbackHeaderLeavesAnUnrelatedRowItsBreaks (automatic columns)
group loop skips the header step AHeaderThatTakesTheRoomOfAGroupGivesUpOnlyItsBreaks
header's third step off AHeaderThatATabTipsIsLaidOutUnbroken
third step reaches every cell ARowThatCanBeCutKeepsItsBreaksWhenATabTipsAGroup
third step never leaves the group's and header's rows ACutRowWithAFallbackCellIsReportedOnce
every column counts as automatic ARowThatCanBeCutKeepsItsBreaksWhenATabTipsAGroup
U+2028 counts as a line break AControlSpaceThatIsNotABreakIsNotTheFirstStep
row wrapping ignores the fallback ACutRowWithAFallbackCellIsReportedOnce
report on every slice of a cut row ACutRowWithAFallbackCellIsReportedOnce
minimum column width from the whole text AnAutoColumn_hasItsMinimumFromTheWordsOfEachLine, ACutRowWithAFallbackCellIsReportedOnce
adjacent span groups not merged ARowSpanChainIsOneGroup
report not kept per table TwoTablesReportTheirOwnFallbackCells
page label not normalised ABandDrawsAControlSpaceInAPageLabelAsASpace, ABandWithAControlSpaceInAPageLabelIsPdfA2uClean
fallback draws its control characters as spaces 19 failures, among them AFallbackCellIsDrawnNoWiderThanItWasMeasured
fallback measured with the control characters as spaces 19 failures
trailing break adds no line Standard14_anEmptyHardLineIsABlankLine
CRLF is two breaks 2 failures
no "no room for a line under the header" check AHeaderThatWouldLeaveNoRoomForTheRowBelowIsLaidOutUnbroken(47)
group fit ignores the header 2 failures
a group that gives up cells in fixed columns ends its pass TheCostOfGivingUpBreaksInFixedColumnsDoesNotGrowWithEachGroup
a tab-tipped group in fixed columns ends its pass TheCostOfGivingUpTabsInFixedColumnsDoesNotGrowWithEachGroup
a cell given up in an automatic column does not end the pass ARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudged (both cases)
a header cell given up does not end the pass AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemains
a width of 0 counts as a fixed column ARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudged(zeroWidths: true)
U+0085, U+2028, U+2029 not a space in a band the three new ABandDrawsAControlSpaceAsASpace cases
fallback cell measured by its column, not its place in the row AFallbackCellAfterAColSpanIsMeasuredAsItIsDrawn
third step leaves out the last header row ATabInTheLastHeaderRowThatTipsAGroupIsLaidOutUnbroken, AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemains
"no room for a line" checks the first data row only AHeaderIsRelievedWhenALaterRowHasNoRoomForALine
a group cell spanning a fixed and an automatic column checks only the first column AGroupCellSpanningAnAutoColumnEndsThePassEvenWhenItStartsInAFixedOne
a column past the width array counts as fixed AColumnPastTheWidthArrayIsAnAutoColumn
a RowSpan inside the header counts as a group ARowSpanInsideTheHeaderIsNotAGroup
the third step ignores the header's column reach TheThirdStepReachesAnAutoColumnThatOnlyTheHeaderIsIn
the decision key is the width alone ADecisionIsNotReusedForAFreshPageOfAnotherHeight
a group is not judged again after its own breaks are given up (the previous head's behaviour) AGroupIsJudgedAgainAfterItsOwnStepBeforeTheNextOneIsJudged; on the previous head the test reports row 3, cell 0 as well
a group's rows are not measured again after that step AControlSpaceThatIsNotABreakIsNotTheFirstStep
a shared step in the third step does not end the pass AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemains
a group's rows are measured again except the last / the first row only EveryRowOfAGroupIsMeasuredAgainAfterItGivesUpItsBreaks(3) / both cases
the decision key ignores the second fresh box none, and none is possible through the document. The second box is the page rectangle recomputed as Y + (Bottom - Y) and deflated by the table's own margins, so for one table it equals the first except for rounding in the last bit of the bottom edge, and the decision reads both only through FitsFresh, whose tolerance is 0.001pt. Two calls would have to agree in the first box and differ in the second by more than rounding, which no page rectangle does. The document offers one content area for every page and moves only its x.
fallback decision never reused none: the output is identical, only time and allocation differ
caches and the early cutoff (run on the final build, against all of Layout.Tests)
a cached line count holds at the high end of its interval (<=) AnIntervalIsClosedBelowAndOpenAbove
a cached line count does not hold at the low end of its interval (<) AnIntervalIsClosedBelowAndOpenAbove
the cache key ignores the mode (breaks kept or read unbroken) 41 tests, among them AColumnPastTheWidthArrayIsAnAutoColumn and AControlSpaceThatIsNotABreakIsNotTheFirstStep
a word broken at its characters does not pin the count to the width ACertificateCountsLikeTheWrapItStandsForAcrossItsInterval, ACertificateHoldsOverARangeUnlessAWordWasBroken
an empty word counts as a character of the line ACertificateCountsLikeTheWrapItStandsForAcrossItsInterval
the low bound of the interval comes from the word, not the joined line ACertificateCountsLikeTheWrapItStandsForAcrossItsInterval, TheCostOfAChainOfTippedGroupsStaysUnderAFixedBound
the high bound of the interval comes from the word, not the joined line 4 tests, among them AnIntervalIsClosedBelowAndOpenAbove
the early cutoff ignores a change of column width 4 tests, among them AStepThatMovesAColumnWidthStillEndsThePass
the early cutoff ignores a cell added in a row outside the group AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemains
the grid of the decision is kept when the key differs ADecisionIsNotReusedForAFreshPageOfAnotherHeight, ALaterPageOfAnotherWidthResolvesTheGridAgain
the cells are not validated when the table is first laid out 5 tests, among them RefusalMessageTests.Table_colSpanBelowOne_namesTheCellTheCallerWrote
last step and incremental widths (detached worktree of 2a1ffaa and 329d10a, TableLastStepTests, TableCellBreakTests, TableMeasureCacheTests, net10.0)
the last step removed AGroupThatACellOutsideItNarrowedIsRelievedByThatCell, AHeaderThatACellOutsideItNarrowedIsRelievedByThatCell, TheLastStepLeavesTheOtherCellsTheirBreaks, ALongRandomTableThatTheThreeStepsCouldNotRelieveIsSaved (3 seeds), ADocumentThatSavesMeasuredAsOneLineSaves
the last step takes only cells with a line break ADocumentThatSavesMeasuredAsOneLineSaves
the step raises the kept widths: always measure the table again AStepRaisesTheKeptColumnWidthsAndMeasuresNoOtherCell, TheCostOfGivingUpBreaksInASharedAutoColumnStaysAFixedMultipleOfNotGivingThemUp
the raise skips the check that a cell contributes no less AStepThatNarrowsAColumnMeasuresTheTableAgain
a broken word's interval ignores its low bound ACertificateCountsLikeTheWrapItStandsForAcrossItsInterval, ACertificateHoldsOverARangeWhenAWordWasBroken
a broken word's interval ignores its high bound the same two, ALongRandomTableThatTheThreeStepsCouldNotRelieveIsSaved and ADocumentThatSavesMeasuredAsOneLineSaves
a string allocated per character of a broken word CountingABrokenWordAllocatesNothingPerCharacter
width cache off 5 tests, among them all three cost pins
line cache off 5 tests, among them EveryCachedLineCountEqualsAFreshWrap and the three cost pins
early cutoff off AStepThatLeavesEveryColumnWidthAsItWasDoesNotEndThePass and 3 more, among them the fillers pin
grid reuse off 5 tests, among them ATableOverManyPagesResolvesItsGridOnce and the three cost pins
all four caches off (the step always ends the pass, the grid is resolved on every page) TheCostOfGroupsThatEachWidenTheColumnStaysUnderAFixedBound, run alone: it fails after 361 seconds; TableCellBreakTests.TheCostOfGivingUpBreaksInFixedColumnsDoesNotGrowWithEachGroup and ...TabsInFixedColumns... fail too. The whole class under this mutant did not finish in 15 minutes, so I stopped it.

| header spans and main refusals (detached worktree of an earlier head, TableMainRefusalTests and TableLastStepTests, net10.0) | |
| a span declared in a header row is a group again | ARowUnderAHeaderSpanThatHasNoRoomGivesUpItsBreaks, ASpanInTheLastHeaderRowIsNotAGroupOverTheRowsItReaches, RowsUnderAHeaderSpanAreJudgedOneAtATime (6 cases) |
| rows under a header span are not judged | ARowUnderAHeaderSpanThatHasNoRoomGivesUpItsBreaks, ADocumentThatSavesMeasuredAsOneLineSaves, ADocumentThatIsRefusedMeasuredAsOneLineIsRefused |
| the one-line trial never refuses | ATableThatIsRefusedMeasuredAsOneLineIsRefusedWithTheSameMessage (3 cases), ADocumentThatIsRefusedMeasuredAsOneLineIsRefused |
| the one-line trial measures into the subset | AMeasurementThatIsDroppedAddsNothingToAnEmbeddedFont |
| the one-line trial splits inside a RowSpan group | ADocumentThatIsRefusedMeasuredAsOneLineIsRefused |
| the one-line trial lets any single row be cut | ATableThatTakesExactlyTheLimitKeepsItsBreaks, ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine (4 cases) |
| the one-line trial tests the header rows alone | none, and none is possible: the run check refuses whatever the header test would, because header rows that do not fit leave every run without room. The test is removed. |
| the bound is zero | 7 cases, among them TheContinuationBoundIsNeverBelowTheContinuationsATableTakes and TheBoundOfAManyRowTableThatTakesFewPagesIsBelowTheLimit; see the mutations of the shared limit mechanism below |
| the bound counts the units less one | ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine |
| the height bound uses 1H in place of 4H | TheContinuationBoundIsNeverBelowTheContinuationsATableTakes, TheBoundOfAManyRowTableThatTakesFewPagesIsBelowTheLimit |
| the reason is not carried to later pages | ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine (3 cases) |
| the fallback reports the room reason | ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine (3 cases) |

Mutations of the shared limit mechanism

Each applied in a detached worktree at c78522d (the table code is that of the head, whose later commits change comments and one test), built, and run against TableContinuationLimitTests, TableMainRefusalTests and TableCellBreakTests (110 to 114 tests, net10.0, Release); the Kernel row against PeekGlyphIdTests. The first sweep ran at e8944ec; three mutants survived it and one did not build, and the tests that kill them were added, so those four rows are from the second sweep at c78522d. Every mutant below fails at least one test.

Mutant Failing tests
the table never reports 23, among them ATableThatKeepsItsBreaks_keepsThemInEveryPass, ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReported and the wrapper cases
only the call that made the decision reports 23, the same
the bound leaves out the unbroken grid ATableWhoseBreaksBoundIsWithinTheLimit_butWhoseUnbrokenLayoutReachesIt_isRefused (survived the first sweep)
the unbroken grid is bounded after the decision's grid is put back the same (survived the first sweep)
the bound leaves out the grid that keeps the breaks 7, among them ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReported and TheContinuationBoundIsNeverBelowTheContinuationsATableTakes
the bound is always zero 9, among them ATableWhoseUnbrokenLayoutReachesTheLimit_isRefusedWithTheMessageThatLayoutGives
an unaddressed table is not the twin 9, the wrapper cases and TheSameTableWithoutAWrapperKeepsItsBreaks
a delegating table does not forward Draw ATableAWrapperHolds_thatFitsOnePage_isDrawnByItsTwin (survived the first sweep: every wrapped table in it took several pages, so the table's own first call was never the one that drew)
the delegating table does not remember its twin for Draw the same
the twin is made anew on every call TheTwinIsTheSameObjectOnEveryCall (did not build in the first sweep: an unused field)
a twin's own twin is a new object TheTwinIsTheSameObjectOnEveryCall
the twin does not start at the table's start row ATableStartedAtARow_laidOutUnderAContextTheCallerBuilt_startsThere (survived the first sweep)
a twin always reports the fallback 3, the wrapper cases
the fallback is reported by every twin, chosen or not 3, the wrapper cases
a twin never reports the fallback 5, among them ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReported
a piece of the chosen twin does not carry the report 5, the same and ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine (3 cases)
the Kernel measures with registering both cases of MeasureStringWithoutRegistering_equalsMeasureString_andRegistersNothing

Mutations of the empty show, the strict-mode rule and the depth probes

The band row was applied in the worktree of this branch and then restored; the others each in a detached worktree at 55b7403 (its tree differs from the final commit in one test comment), built in Release, and run against TableContinuationLimitTests, TableStrictDiagnosticsTests and TableCellBreakTests (107 tests, net10.0) or, for the depth probes, against *stackDepthStaysFlat (2 tests, net10.0 and net11.0). The baseline fails none. Every mutant below fails at least one test.

Mutant Failing tests
no skip of an empty line both cases of ALineThatIsEmptyBecauseOfControlWhiteSpace_writesNoEmptyShow
every empty line is skipped, in a cell with no control white space as well both cases of the same test (the empty cell and the cell of spaces write their empty string again)
an empty line is skipped only in a table laid out unbroken the direct case of the same test (the blank line after a trailing break)
the table reports only when a cell holds control white space ATableWithNoControlWhiteSpace_drawsEachLineOfARowCutBetweenItsLinesOnce
a cell keeps its control white space as written 24, among them AnEmbeddedCellWithControlWhiteSpace_saves_underStrictDiagnostics (direct), AStrictPdfA2uDocumentWithControlWhiteSpaceInACell_passesVeraPdf (direct) and Standard14_aTabIsOneSpace
the twin keeps its control white space in the drawing 27, among them the three wrapper cases of TableStrictDiagnosticsTests and the wrapper case of the empty-show test
U+2028 is not a control space both cases of AStandard14CellWithControlWhiteSpace_saves_underStrictDiagnostics and 4 more
U+0001 is a control space both cases of ACellWithAControlCharacterThatIsNotWhiteSpace_isStillRefused_underStrictDiagnostics and Embedded_noControlWhiteSpaceIsGlyphZero_andOtherControlsStillAre
a band's template keeps its control white space as written (the conversion in BandTemplate switched off) *Band* filter, net10.0: both new band cases of TableStrictDiagnosticsTests and the existing band cases of TableCellBreakTests and PageBreakTests (ABandDrawsAControlSpaceAsASpace, ABandCutsAtTheSpaceAFormFeedBecame)
PlaceLoop calls itself for the overflow, not in tail position both depth probes, on net10.0 and on net11.0
the same, in tail position both depth probes, on net10.0 and on net11.0
PlaceLoop calls PlaceRenderer for the overflow, not in tail position both depth probes, on net10.0 and on net11.0
the same, in tail position both depth probes, on net10.0 and on net11.0

A first version of the twin mutant, one that made RemoveControlSpaces return its argument, hung the test process instead of failing a named test, and was replaced by the one above.

Removed in 3.0 (#688)

3.0 lays a table out one way under every context, so every compatibility device this PR adds goes. Each carries a comment naming 3.0 and #688.

  • In TableRenderer: the IContinuationTwin implementation (Twin()), the fields _readsUnbrokenForTheLimit, _twin, _laidOutBy, _placedAsTwin and _reportBound, the delegation to the twin at the top of Layout, the report to the session at the end of the decision, the bound over the unbroken grid, the forward in Draw, and the _placedAsTwin condition on the 301 report with its DroppedForTheLimit message.
  • The sentences in the public XML documentation of IRenderer.Layout, TableRenderer.Layout, TableElement, Cell.Content and LayoutContext.WithArea about a table you lay out yourself, and the CHANGELOG entry "A table is laid out with its breaks read only where the document lays it out".
  • TableMeasureProbe.ReadEveryCellUnbroken, which the tests use to measure a table as it was before breaks were honoured, and the tests that pin the twin: the wrapper cases of TableContinuationLimitTests, TheTwinIsTheSameObjectOnEveryCall, ATableStartedAtARow_laidOutUnderAContextTheCallerBuilt_startsThere.

Residual costs, for 3.0 to close with an exact technique:

  • A table near the limit costs two layout-only placements and the real one. The decision places the unbroken layout, then the one that keeps the breaks, and places the twin again when it is chosen. 25,001 rows of a<LF>b on a 400 x 40pt page (the twin is chosen) took 42.9s and 119,640MB here against 141.5s and 314,639MB on main, in one run each of net10.0 on a shared machine. I did not time the phases. The exact remedy is to keep the pieces the twin's probe placed and replay them when the twin is chosen.
  • A table without control white space is probed too, though its two layouts are one. 25,002 one-line rows of a on a 400 x 40pt page (a bound of 50,003, above the limit) took 24.5s and 71,859MB here, three placements, against 135.4s and 309,888MB on main (the same bytes, sha-256 prefix 73DE1E2F8374); 25,000 such rows (a bound of 49,999, no probe) took 10.2s and 24,114MB. The report cannot be dropped for such a table. A call that reports nothing makes the document lay out the rest of the placement as the twin, a new renderer that holds none of the lines a cut row carried, and the cut row is drawn again from its first line. Measured with the report made only for a table that holds control white space, on a 400 x 100pt page, one row of 80 words w0 to w79 in a 100pt column and no control character: 5 pages and 106 word shows, where this build and main write 4 pages and 80 (3,014 bytes on both). ATableWithNoControlWhiteSpace_drawsEachLineOfARowCutBetweenItsLinesOnce pins it. The exact remedy is a report that carries the cut row to the twin, or a bound the document can trust without probing when the two layouts are one. One candidate, unproven and not measured here: keep the report but give a bound of 0 when no cell holds control white space, so the document takes the bound branch with no probe. A review tried it on a few shapes and the table test classes passed; nobody ran the differential or the limit tests at the real limit on it, and it stretches what a bound means, so 3.0 would be better served by a flag that says the two layouts are one.
  • The bound is computed for every table the document lays out, twice for a table that keeps some breaks. It is a pass over the rows. 20,000 rows of four short cells: 1,793MB here against 1,790MB at the earlier head.
  • BuildRowspanBlockedSet and the header scan still run for every page (see "Not done").

Other open PRs

#680 and #681 are merged into this branch. The three list conflicts with #680 are unions, and its reserved-numbers comment no longer names 301 ControlCharacterInCell, which this PR defines as CellWhiteSpaceDropped. #681's copy of the control-space predicate in BandText is removed: bands, page labels, bookmark titles and cells read it through LayoutText.

Not done

  • Main treats a RowSpan declared in a header row in two ways (found by the review; to be filed with Tracking: defects found while doing the v2.4 work (not yet fixed) #613). InSpanGroup, CanCut, SpanGroupOf and the refusal messages count it as holding the data rows under it, and BuildRowspanBlockedSet starts at the first data row, so the layout still ends a page between them. This change judges those rows one at a time and leaves the layout alone.
  • The per-page cost of a long table (BuildRowspanBlockedSet and the header scan run for every page) makes a 25,000-row table of one-row pages take 30s on main. The continuation check doubles it near the limit; see "Cost of the new checks".
  • VT, FF, NEL, U+2028 and U+2029 as mandatory line breaks (UAX Deterministic output: DocumentId pin + determinism tests #14 LB4, LB5) in cells and paragraphs: both draw each as a space.
  • Control characters that are not white space (U+0001 and so on) still reach glyph lookup; NotdefGlyph reports them.
  • Tab expansion to stops in a cell: a cell has no stops, so a tab is one space.
  • A fallback cell that holds a tab but no line break is reported too, because its words run together.
  • A row's height and its drawing disagree under a RowSpan (origin/main, found while checking this change; to be filed separately). ResolveGrid measures a row's cells in consecutive columns from the left, and DrawRow skips a column that a span from an earlier row occupies, so a cell can be measured at one column's width and drawn in another. On origin/main, tables whose texts hold no tab, line break or form feed draw text outside their row: seeds 47, 118, 212 and 221 of the first set above draw 45, 36, 10 and 51 shows outside the row they belong to (counted by the same probe on origin/main). Three of the six refused-then-saved tables above show the same thing. This change leaves it as it was.
  • The cost of the decision still grows with the square of the number of groups when each group widens an automatic column (1,000 such groups, 2.0s and 378MB, 6.5 times the allocation of 400; see "Cost of the fallback"). It is below 2.3.3 and origin/main on every table measured, and every table is decided exactly group by group. The shape where a step keeps the widths no longer grows with the square.

Tim81 added 30 commits November 21, 2026 22:23
A table cell split its text on U+0020 only, so a tab reached glyph
lookup as glyph 0 (embedded font) or a raw 0x09 byte (Standard 14), and
a line feed was one line holding glyph 0 or a string-escaped newline. A
running band passed a form feed to the font as it was.

A cell now breaks lines as a paragraph does (CR LF, CR and LF each end
a line) and draws every other white-space control character as a space.
Automatic columns are sized from the widest line. A band draws those
characters as spaces and measures them as spaces.

Header rows and RowSpan groups are never cut between lines, so honouring
breaks there could turn a table that saved into a too-tall refusal. A
cell of such rows that would do so keeps the unbroken layout, with each
break drawn as a space, and is listed as the new warning
CellBreakDrawnAsSpace (301).

Closes #611
…awing

A cell laid out unbroken was wrapped with its tabs and line breaks at their
own width, zero in Helvetica, but drawn with each as a space, so its lines
came out wider than measured and crossed borders and the page edge. They are
now left out of the drawing, so a line is as wide as it was measured.

Also limit the third fallback step to the cells that can change the rows
that do not fit, end a pass after the header step so a group is judged by
the header's new height, read other Unicode space separators as a space,
and decide the fallback once per width instead of once per page.
Cover the fallback drawing no wider than it measured, a header step that
ends its pass, a tab that tips a group without reaching a fixed column's
rows, a header that gives up only its breaks, a RowSpan chain read as one
group, a report per table, one report for a cut row, and a minimum column
width taken from each line's words.
… at a time

Drop the reading of Unicode space separators as spaces: two tables that
saved are refused with it, and a paragraph's rule for them is a change for
a later major. A group step that adds a cell now ends its pass, so the next
group is judged by heights taken after the change. The text a page label
prints for {page} is read as the template's own text is. The cached decision
is keyed on the width and the boxes' heights, not their x, so mirrored
margins reuse it.
State what Count counts, scope the claim that nothing crosses a cell,
describe the random tables accurately and give the exact page boundary:
2,350,047 words save and 2,350,048 are refused.
A group that gave up its breaks ended the pass, so a table with many
such groups took one full measurement per group. A step that adds
only cells of the group's own rows in fixed-width columns changes no
height another group reads, so the pass goes on. A step that touches
a header row or an automatic column still ends it.

Also pins the header's no-room rule for a later row, a fallback cell
after a ColSpan, the all-header table, and U+0085, U+2028, U+2029 in a
band template, and says in the runtime message that the rows were
left no room, not that they were taller than a page.
A tab-tipped group in fixed columns must also be judged in one pass,
and a tab in the last header row must reach the group's third step.
A header that gives up its tab also changes the heights the next group is judged by, which one more case pins.
The tab pin allocates 1.03 times its baseline when groups are judged together and 1.93 times that when each ends the pass; a bound of five missed it.
A header falls back when it leaves the row below no room for a line,
and a group when it exceeds what a page leaves under the header, so
'taller than a page' was false for both. A table of nothing but
header rows repeats none. Corrects the qpdf and cell-border claim for
the six refused-then-saved tables, the CR LF band sentence, and
states that RunningBand.Resolve returns control characters as given.
A group that gave up a cell in a fixed-width column let the pass go on to the next group, which was then judged against a header that a later pass relieved. With that header the next group would have had room, so its breaks were dropped for nothing. Only this group's rows are measured again now, and the group is judged once more before the next one.

Each group that gives up a cell in an automatic column still ends the pass, and each pass measures the whole table, so a table with many such groups took time and allocation that grew with the square of their number. After 8 measurements the groups not yet judged are judged together. A table that needs at most 8 is decided as before; beyond that a later group can give up cells it would have kept.

Tests pin the groups the cap leaves alone, the boundary at 7 and 8 measurements, the allocation of 400 groups in automatic columns, and the decision key, the column reach of a spanning cell, a column past the width array and a RowSpan inside the header.
The rule for which table cells are laid out unbroken was copied into six places, and each copy drifted from the others: one said every step ends its pass, one said the cause was line breaks, though a tab alone can tip a table with none. Cell.Content now holds the rule in full, including the bound on measurements and what it changes. TableElement, LayoutDiagnosticCode, TableRenderer.Layout, the runtime message and the CHANGELOG say what they add and point there.

Also fixes the running band note that a carriage return and line feed pair is two spaces, and replaces the CHANGELOG sentence about identical bytes with what was measured.
The limit of 8 measurements ends passes that stop at the first shared
step. A table in which each group's fallback changes the column widths
the next group is judged against still takes one measurement per group,
and above the limit a later group can give up more cells or fewer than
group-by-group judging would. Say so in the XML docs, comments and
CHANGELOG, and pin the batch-mode branches of the group loop with tests.
The chapter token added a second copy of the predicate and the replacement that LayoutText already holds. A table cell, a page label and a bookmark title now read control white space through the one helper.
A decision that reads cells unbroken measured every cell's longest word and widest line again on each pass, though both depend only on the cell's text and mode. They are kept for the decision and dropped with it, so a table edited between saves is measured from nothing.
Measuring a row wrapped every cell again, though a cell's line count only changes when the column width crosses one of the comparisons the wrap made. The count is kept with the interval of widths over which every comparison comes out the same; a word that was broken at its characters pins it to that width. A test probe can check each hit against a fresh wrap.
After eight measurements a pass judged all the groups it reached on the heights it started with, so a group could give up more cells than judging it on the heights its predecessors left would. The limit goes, and a table decides the same cells however many groups it holds. The commits after this one keep what each cell measures, which is what made the limit unnecessary.
A group that gave up cells in an automatic column ended the pass, because the width of that column can change other rows. When the widths come out bit for bit as they were, and every cell given up lies in the group's own rows, no other row measures differently, so the pass goes on with the next group instead of starting again from the first.
Every page of a table resolved the grid again, though the renderer that carries the table over holds the grid, the heights and the decision for the same width and fresh page. The checks of the cells and the border width ran on the page that made the decision, so a later page keeps them as they were.
Allocations are counted, not time, so a loaded machine does not move the pins. The shapes are groups that give up a cell in a column other rows share, groups that each widen that column, and a chain in which each group changes the width the next is judged by.
The pass limit and its cost paragraph are gone from the changelog and the XML documentation, which now state the rule once on Cell.Content. A test pins the interval of a cached line count as closed below and open above.
A table the previous release saved was refused when an automatic column's
cell, in a row of no group, held a line break: reading it per line took
the column's minimum from its widest line, the explicit columns were
scaled down to what that left, and the group's own cells held no control
white space for any step to give up.

When a header or a group still has no room after the three steps, a last
step reads every control-white-space cell that spans an automatic column
unbroken. Those cells alone decide every column's width, so the widths,
and the header and group heights, come out as when every cell was one
line. A test hook measures a table that way, for the property test.
The widths kept for the pass, raised by a step, decide whether the step moves
a column. A step that ends the pass is followed by a measurement of the whole
table from what the cells kept, and a fixed column's step computes none.
The bound on a table's page continuations counted two for every unit, so a
table of 26,000 ordinary rows was placed twice to find out that it takes a
few thousand pages. When no row is cut, two pieces in a row are taller
together than what a page leaves under the header, so the bound also follows
from the rows' heights, and the check runs only for tables that can reach the
limit.
The three renderers a layout hands on each copied the decision field by
field, and a copy that missed one went unnoticed. The continuation verdict is
asked again rather than kept: it depends on where the element starts, and a
key that said so had no test that could tell it from a wrong one. The
refusal property now draws tall header rows too.
Header rows that do not fit a page leave every run of rows without room, so
the refusal check needs no test of its own for them; no test could tell the
two apart.
Tim81 added 10 commits November 22, 2026 20:51
Takes the shared continuation-limit mechanism (#686). The table's own
limit check in DocumentRenderer goes: the merge keeps the mechanism's
placement loop and drops the guard, the probe and the two fields the
table added.
…nism

The table now reports a bound to the document and the document decides,
instead of the table running its own placement. The bound is the larger
of the grid that keeps the breaks and the grid that reads every cell
unbroken, so a table whose unbroken layout alone reaches the limit stays
refused with the message that layout gives, as it was in 2.3.3.

A table laid out under a context the document did not address to it (a
caller's renderer that forwards here, WithArea, the public constructor)
is its own twin: it reads every cell unbroken and reports nothing, so
the document's limit holds however the table is reached. Its Draw and
ReportPlacements forward to the twin that laid it out, and the fallback
is reported only for a twin the document chose.

The guard interface, the probe and the two fields in DocumentRenderer
are gone; the mechanism's limit and verdict memo replace them. The
public XML documentation of IRenderer.Layout, TableRenderer.Layout,
TableElement, Cell.Content and LayoutContext.WithArea says what a table
you lay out yourself does. The Kernel method that measures without
registering has a direct test, and four comment lines are rewrapped.
…ntity

A table that keeps its breaks keeps them in the drawing pass of a
document with a footer, which lays the table out a second time from the
decision the first one carried. The twin is one object for the life of
the renderer. A delegating table no longer forwards its anchor: the
document reports one only for a renderer it placed, so the forward was
never reached.
…rt row

A table whose bound with its breaks read is within the limit and whose
unbroken layout reaches it is refused as before, which only holds when
the reported bound covers the unbroken grid. A wrapped table that fits
one page is drawn by its twin. A table started at a row, under a context
the caller built, is its twin from that row.
Each comment that belongs to the twin, the report and the delegation
names 3.0 and #688, as the shared mechanism's own comments do.
… starts it

The stack-depth probes counted PlaceRenderer frames. PlaceRenderer is
now a small method that starts PlaceLoop, and the JIT inlines it once it
is hot, so on net11.0 a run that placed 50,000 pages before the probes
(the table limit tests do) read zero frames. PlaceLoop holds the loop,
is not inlined, and is on the stack exactly once per Layout call.
…t it

The stack-depth probes counted PlaceRenderer frames, and in a full run of
the suite in sequence the count read 0, so both probes failed with
Expected: 1, Actual: 0. PlaceRenderer only starts the placement loop and
is small enough for the JIT to inline into its caller. PlaceLoop is the
method that recurses if the loop regresses, and a recursion into it puts a
second frame on the stack. Marking it NoInlining keeps the frame the probes
count, and the count stays 1 for a renderer that does not report.
…pace emptied

A cell the table lays out unbroken leaves its tabs and line breaks out of
what it draws, so a line made only of them came out empty and was written
as an empty string shown with Tj, which draws nothing. A blank line between
two line breaks in a cell that keeps its breaks was written the same way.
Neither writes a show now. A cell that holds no control white space is not
touched, so a table without any keeps its bytes, an empty cell and a cell of
spaces alone included.

A table reports its bound whether or not a cell holds control white space,
and a test pins why: with no report the document lays the rest of the
placement out as the twin, a new renderer without the lines a cut row
carries, and the row is drawn again from its first line.

The message for a cell given up for the continuation limit and the test
hook that measures every cell unbroken now say that 3.0 removes them.
…refusal

A tab, a line break or another control white-space character in a cell
reaches no font, so the save lists no NotdefGlyph or UnencodableCharacter
for it and StrictDiagnostics does not refuse the cell. That holds for a
table the document lays out and for one a caller's renderer holds, which
draws the character as nothing, and a PDF/A-2u file made that way passes
veraPDF. A control character that is not white space is still refused.

The XML documentation of Cell.Content and TableRenderer.Layout and the
CHANGELOG now say so, and list the output change of a table a caller's
renderer holds, which leaves the control characters out of the drawing,
and the position of a centred band that holds a tab.
The comment gave one run's result as the general one. State the runs: both probes
failed in four sequential runs on main, on net10.0 and on net11.0, and one net11.0
run passed. The inlining cause stays a likely cause, not an established one.
…kips

The skip covers every empty line of a cell that holds control white space, a line of
spaces alone included, not only a line the control characters emptied.
…efusal

A tab, line break or form feed in a band template or a page label is drawn as a
space, so StrictDiagnostics has nothing to refuse. A PDF/A-2u band passes veraPDF,
and U+0001 in a band is still refused.
…ble wrote before

RunningBand.Template and the CHANGELOG now say a control white-space character in a band
no longer reports NotdefGlyph or UnencodableCharacter. The CHANGELOG also names what a
table wrote for such a character before: glyph 0, a raw byte, ? or the font's own glyph.
@Tim81
Tim81 merged commit 215ba05 into main Nov 23, 2026
4 checks passed
Tim81 added a commit that referenced this pull request Nov 23, 2026
Three conflicts, all in documentation and the reserved-code comment. IRenderer.Layout keeps
main's table paragraph ahead of the list paragraphs. WithArea names both built-in renderers that
lay out the earlier way under the copy. The reserved list drops 203 and 301, which the two
changes now define.
@Tim81
Tim81 deleted the fix/table-cell-breaks branch November 26, 2026 20:21
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.

Layout: a tab or newline inside a table cell is written as glyph 0 (.notdef) with an embedded font, and as a raw control byte with a standard-14 font

1 participant