Skip to content

Layout: every numeric property except a pie chart's accepts zero and negative and says nothing #482

Open

Description

@Tim81

Every numeric property in the layout package except a pie chart's accepts zero and negative values
and renders something, with no exception and no diagnostic. The pie chart refuses all six of its
own, each with a precise message naming the value. That contrast is what makes this a defect rather
than a preference: the package has already decided what the right behaviour is, in one element.

Measured on 4788c4b, a 300x400pt page at 10pt margins. Every row below renders and says nothing:

Property Value Outcome
TextStyle.FontSize 0 rendered
TextStyle.FontSize -12 rendered
TextStyle.Leading -40 rendered, silently ignored
LineSeparator.LineWidth 0 rendered
LineSeparator.LineWidth -5 rendered
ListElement.Indent -100 rendered
RunningBand.Height 0 rendered
RunningBand.Height -50 rendered
element Margins -20 on all sides rendered
Cell.ColSpan 50 on a one-cell row rendered
Cell.RowSpan 50 on a one-row table rendered
document Margins -20 rendered

For contrast, the pie chart refuses a diameter of 0 and -100, a slice value of -1, all-zero slices,
no slices at all, and a stroke width of -1.

Two of these are worth separating out because they are not simply ignored. A negative
ListElement.Indent puts the item content left of the content box, and negative element or document
margins inflate the area rather than deflating it, so content is placed outside the box the caller
asked for. DocumentRenderer.ValidateGeometry does check the other end: a document margin is
refused once the horizontal pair meets the page width, measured refusing at 150 on a 300pt page and
accepting at 149. So the guard exists and only covers one side.

Two releases, and the reason for the split

2.3.3 reports. Every value above is detected and reported through the notify-and-continue
channel this library already has for text-encoding warnings and, since #469, for band truncation.
That lands the whole of the diagnostic value: the caller learns the property was ignored or
mishandled, which is what they cannot find out today.

3.0 refuses. Turning these into exceptions is what a patch release must not do, because every
one of them renders something now and a caller may be relying on it. That is not a hypothesis: the
consuming showcase repository spent a full cycle removing its own caps after discovering they
narrowed what the library accepts, and it has recorded "not in a patch" as a planning constraint on
exactly this set.

TextStyle.Leading set to NaN is the one row that needs no change in either release.
EffectiveLeading is Leading > 0 ? Leading : FontSize * 1.2, and NaN fails that comparison, so
the non-finite value is discarded before it can reach a coordinate. Worth a comment saying so
rather than a guard.

The refusals whose messages misdescribe their input, and the six that name a private field as their
parameter, are separate and patch-safe, because those inputs already throw.

Follow-up: #484 is where these are refused rather than reported, on v3.0. Filed separately because an issue carries one milestone and this one closes with the 2.3.3 reporting.

Activity

  1. added this to the v2.3.3 — Hardening milestone on Sep 10, 2026
  2. Tim81 commented on Sep 12, 2026

    @Tim81
    OwnerAuthor

    A negative line width is not merely undocumented, it violates a shall

    Read from the held ISO 32000-2:2020, clause 8.4.3.2, Line width:

    The line width parameter specifies the thickness of the line used to stroke a path. It shall be a
    non-negative number
    expressed in user space units [...]

    So LineSeparator.LineWidth = -3, which this issue measures as rendering and emitting -3 w, puts a
    non-conforming operand in the content stream. That is not the same category as the other eleven rows.

    Why this changes the argument rather than adding a footnote. This issue splits on the ground that
    every value in its table "renders something now and a caller may be relying on it", so 2.3.3 reports
    and 3.0 refuses. That reasoning holds for a zero font size or a negative margin, which are legal
    tokens producing an odd result. It does not hold here: the output is already wrong by the
    specification, which is exactly the category this release is permitted to change.

    The same clause settles the zero case too, and in the opposite direction from the current
    documentation:

    A line width of 0 shall denote the thinnest line that can be rendered at device resolution: 1
    device pixel wide. However, some devices cannot reproduce 1-pixel lines, and on high-resolution
    devices, they are nearly invisible. Since the results of rendering such zero-width lines are
    device-dependent, they should not be used.

    So zero is legal and defined, which is why LayoutValidation.ValidateLineWidth deliberately leaves it
    alone, and that decision is right. But the standard advises against it, and the member's
    documentation does not say so. NOTE the standard's own word here is should not, not shall not, so
    this is a caller warning rather than a refusal.

    Suggested split, replacing the current one

    • Negative line width: refuse, in this release, on the ground above. It emits a token the
      specification forbids.
    • Zero line width: keep accepting, and add the "should not be used" advice with its clause to the
      member's documentation.
    • The remaining ten rows: unchanged, report in this release and refuse in 3.0.

    Found while verifying two specification citations that a review of #503 could not check, because
    docs/iso/ was empty in its worktree at the time.

  3. added a commit that references this issue on Sep 13, 2026
  4. Tim81 commented on Sep 20, 2026

    @Tim81
    OwnerAuthor

    Split, by the maintainer's decision on 2026-09-20:

    Read from origin/main at cbbf7d5 while triaging: LayoutValidation still checks only non-finite values for font size, line width and insets, and its comments name these rows as deferred to the next major. The claim in this issue's opening sentence that "every numeric property except a pie chart's" accepts zero and negative overreaches: ColSpan below one and non-finite font sizes, line widths and insets are already refused, and Leading at or below zero is documented as "derive from the font size".

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