Skip to content

Layout: a list indent at or beyond the content width discards the item text and keeps the marker #476

Done

Description

@Tim81

A ListElement.Indent at or beyond the available content width silently loses every item's text
and still draws the marker. The caller gets a numbered list with no content and no diagnostic.

ListRenderer.BuildItems gives the content paragraph a left margin of Indent, and
ParagraphRenderer.Layout returns Nothing once its deflated width is non-positive.
ListRenderer.Layout only bails when the marker and the content are both Nothing, and the marker
paragraph has zero margins so it always fits, so the item collapses to marker height and the text
is dropped.

Measured on 4788c4b, a 200x400pt page at default margins, so a 56pt content box, one
OrderedDecimal item holding ten W at 36pt, varying only the indent:

Indent Bytes W glyphs emitted Text operators
0 1943 10 (1.) then ten (W)
20 (the default) 1946 10 same
55 1949 10 same
56 1523 0 (1.) alone
200 1523 0 (1.) alone
10000 1523 0 (1.) alone

The cliff is exactly at the content width.

Adjacent to the marker-overprint fix in #472 but a different symptom: that one draws the marker and
the text and overlaps them, this one draws the marker and discards the text. #472 bounds its own
widening so it cannot reach this state, by keeping today's indent whenever widening would leave
less room than the content's widest word, but it deliberately does not touch a caller-supplied
indent, so this case survives that pull request.

The fix belongs with the other list and table work in 2.3.2: clamp the resolved indent so the
content keeps a usable width, and report the clamp rather than silently discarding. The threshold
that matters is not merely a positive width but the width at which ParagraphRenderer stops
wrapping and starts hard-breaking words, which is the bound #472 already uses.

Reported by VellumPdfShowcase against 2.3.1; the figures above are my own reproduction against
main, and their byte counts run one lower throughout, which is the shipped package rather than a
disagreement.

Activity

  1. Tim81 commented on Sep 14, 2026

    @Tim81
    OwnerAuthor

    Moving the measured figures here out of ListElement.Indent's doc comment, which had grown to 792 words across eight paragraphs for one double and was producing a medium finding per review round in the derived detail rather than in the rules. The rules stay on the member; the numbers belong somewhere a fixture can be named.

    All figures below are reproduced: page 400×400 at a 72pt document margin unless stated, Helvetica, list Margins zero unless stated, probes resolving VellumPdf.Layout.dll from the branch worktree.

    The boundary is the list's area, not the page's content width

    ListRenderer.Layout deflates by _list.Margins before BuildItems(area.Width), so every threshold scales with the element's own margins.

    page / doc margin list Margins page content width list area flat text discarded at nested child discarded at
    400×400 / 72 none 256 256 256 128
    400×400 / 72 left 30 256 226 226 113
    400×400 / 72 right 30 256 226 226 113
    400×400 / 72 left 30, right 45 256 181 181 90.5
    595×842 / 72 none 451 451 451 225.5
    595×842 / 72 left 100, right 17 451 334 334 167
    200×300 / 20 none 160 160 160 80
    200×300 / 20 left 13, right 7 160 140 140 70

    Inclusive: at 255.999999 the flat text is present, at 256.000000 it is gone. The nested refusal sits at the full area width and does not move with the child text length (bisected at 3, 40, 400 and 4000 characters: 256.000000 every time).

    The nested half-width drop is a mechanism, not a coincidence of these fixtures. The nested gutter is max(2·indent, indent + childMarkerWidth), and once indent + childMarkerWidth reaches the area width the override reverts it to 2·indent, so the drop is 2·indent ≥ areaWidth for any non-empty child text at a positive font size. Checked against the one case that could break it, a child marker wider than the indent: OrderedRoman with 28 children on a 160pt area at sizes 10/30/40/60, marker xxviii. measuring 24.44/73.32/97.76/146.64, gives the child drop at 80.000000 in all four.

    Between half the area width and the whole of it the child marker is still emitted at margin + indent, with no warning on either reporting channel: at indent 256 the stream holds only the bullet run, TextEncodingWarnings and BandTruncations are both 0, and Save returns 1,522 bytes without throwing.

    Where a negative indent puts content

    These four held at every positive TextStyle.FontSize probed (0.0001, 0.001, 0.25, 1, 10, 50, 100, 150, 200), each flipping within the 5e-6 that PdfCanvas's "0.#####" format can write. Margin below means the page margin plus Margins's left inset.

    branch level figure
    override firing top reaches the page edge at minus the margin
    override firing nested reaches the page edge at minus half the margin
    override quiet nested crosses the margin at minus its own marker's width; reaches the page edge at minus that width and the margin together
    override quiet top stays on or right of the margin, because the larger-of cannot return less than the marker's width

    At a font size of zero or less none of the four applies. WidestWord starts its accumulator at 0.0 and takes only a strictly greater candidate, so at a non-positive size it returns 0 and the override can never change a gutter: 192 cases across sizes 0, −0.001, −10, −500 × two page widths × two document margins × fourteen indents from −1000 to 257 matched the pure larger-of prediction with zero mismatches. A negative marker width can then make either gutter negative on its own, which is what carries text across the margin where a positive size would not.

    A bisection predicate worth writing down

    The child text hard-breaks into one glyph per run before it disappears. A predicate asking whether the whole child word survives finds 117.00 where the discard boundary is 128, and 231.99 where the flat one is 256 — the wrap threshold, a different behaviour. ParagraphRenderer drops text only at a non-positive width, so the predicate that matches the prose is does any glyph of the item text survive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions