Repository navigation
feat(layout): a running band with three zones, a logo and a rule - #735
Merged
Merged
Conversation
…ogo and a rule A book-style header or footer puts a title, a chapter and a page number on one line. RunningBand takes three BandZone values, each holding styled runs or a logo. Tokens resolve through the existing band template scan. Zones that would overlap are cut by priority and reported as a string band's cut is; MirrorZones swaps the sides on even physical pages; BandRule draws a line along an edge. A string band saves the same bytes as before.
… refuse at build A zone of two runs is cut over its whole text at the last literal space that fits, and a page number, count or chapter title is drawn whole or not at all. A zone that measures zero width still has its side's place. The text box is the fonts' ascent plus descent, centred in what the rule leaves, and the rule keeps one point clear of it and of the logo. A Standard14 value the enumeration does not name, an unpaired surrogate and a size written as zero are refused when the zone is built.
…, pin the cut and the boxes Runs of a zoned band that together pass int.MaxValue characters on a page now throw InvalidOperationException naming the band, where the report cast threw OverflowException. The default height reads the largest leading once. The docs say the rule's clearance holds for a font's own bounding box and not for a viewer's substitute for a Standard 14 face, name the two exclusions of the cut, and refer to #470. Tests pin the 14 AFM boxes, the head box of an embedded font, a leading space, a run of spaces and a cut between surrogate halves.
… its widths The comment named the project whose resource files the values were read from. The tree cites the Adobe Core-14 AFM files themselves for the Standard 14 widths, so the bounding-box rows now say the same. The values are unchanged.
The changelog paragraph had a 135-character line, and it said twice that a logo is shortened by the rule. The cut remarks had a broken line. Wording and code are otherwise unchanged.
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #365.
What
A running header or footer can hold three zones on one line.
new RunningBand(left, center, right)takesthree
BandZonevalues. A zone holds styledTextRuns, a logo (BandZone.Logo(LayoutImage)), or nothing(
BandZone.Empty).Document.HeaderandDocument.Footerkeep their type, and the string constructor isuntouched.
New public types:
BandZone,BandRule,BandRulePosition. NewRunningBandmembers: the constructor,Left,Center,Right,Rule,ZoneGap,MirrorZones.Decisions
BandTemplateand resolved byBandText, the machinery a string banduses.
{chapter}still needsChapterToken.RunningBand.CountOfsums token counts over the runs, so thechapter tracking and the page-label lookup see a zoned band.
the largest descent over the band's runs, from each font's own bounding box (Adobe's published AFM
FontBBoxfor the 14 faces,
head.yMinandyMaxfor an embedded font) scaled by the run's size. It is centred in whatthe rule leaves of the band. The rule keeps 1 point clear of the text box and of a logo. The minimum height is
the text box plus the rule width plus that point; the default height is the larger of that and the largest
leading plus 4. An embedded font's
headbox encloses every glyph the font holds, so the rule never touchestext drawn in it. A Standard 14 face is not embedded: its box is Adobe's, and a viewer that substitutes a font
of its own can draw glyphs past it. A review measured this with poppler 26.08 on Windows:
Courier Bold at 30 pt, at the minimum height with a rule below, put 947 dark pixels inside the rule's rows. The
docs state this limit and recommend an embedded font where the rule must stay clear; the geometry does not
change for it.
zone, not the side, so swapping on even pages does not change who is cut. The centre stays centred, so it gets
twice the room of its nearer neighbour.
band's cut does (a space that is itself the character that does not fit is not a boundary, as there). A
boundary between two runs counts only where a space stands. A resolved token (page number, page count, chapter
title) is never cut inside, and spaces inside it are not boundaries. When no space qualifies, the cut falls at
the last position that fits outside a token, so one long literal word is cut mid-word as in a string band. A
zone of which nothing fits is dropped and counted in the report.
Symbol or ZapfDingbats (zero measured width) stays in the content box. Such a run cannot be cut or kept off the
next run of its zone, which
BandZonedocuments under "Do not pass", with Kernel: Symbol and ZapfDingbats have no advance-width tables, so every string in them measures zero #470 as the cause. The gap between two drawn zones isZoneGap(6 pt by default). The cut isreported through
BandTruncationWarningandBandTruncated, once per band, naming the page that lost the most;its counts add the characters of all zones of that page. No new warning type.
content box, a logo written with no area, and a height below the text box plus the rule width plus its clearance. Swapping the left and right
zones changes none of the logo sums, because the centre is centred, so one check covers both kinds of page.
/Artifactmarked contentas band text when the document is tagged. No alternative text, no Figure. Input is a
LayoutImage; only itsImageis read, and the other properties are ignored (documented onBandZone.Image).MirrorZonesswaps the left and right zones on even physical pages whenDocument.MirrorMarginsis set, the parity the mirrored margins use. It is not the page label. WithoutMirrorMarginsit does nothing.BandRulelies inside the band, so the content area does not move. It works on a string band too(opt-in, no change when unset).
text; a page-reference run; a styled link; a
Standard14value the enumeration does not name; an unpairedsurrogate; a font size that is not a finite number of at least 5e-6 (smaller is written as 0); a colour
channel outside 0 to 1; an image with no area; a rule width that is negative or not finite; a zone gap that is
negative or not finite; a zoned band's
Heightthat is not finite and positive or is below its text box. Atthe save: a font handle from another document, a logo that does not fit or would be written with no area, and
a height below the text box plus the rule.
ZoneGapandMirrorZoneson a stringband, and
Resolveon a zoned band, throwInvalidOperationException.constructor, which has optional parameters. A factory would not work because
Height,RuleandMirrorZonesare init-only, so the warning is suppressed on the shipped constructor with a comment. Four literal call shapes
stop compiling (CS0121, ambiguous):
new RunningBand(default, default, default),new RunningBand(null!, null, default),new RunningBand(null, null, default)andnew RunningBand(null, default, default). The rule is that the first two arguments are each a literalnullor
defaultand the third isdefault.new RunningBand(null!, null!, null!)did not compile before and nowbinds to the zoned constructor. Compiled callers bind by signature and are unaffected, and a first argument that has a
type compiles as before. The CHANGELOG says so.
image does as a body image (the class predates this change).
BandZone.Logosays the image follows the imagerules of the conformance claim.
Evidence
ThreeZones_standOnOneLine_atTheExactX,AFooter_stands_atTheFootersBaseline,RunsOfOneZone_followEachOther_withTheirOwnStyles_onOneBaselineTokens_resolveInEveryZone_onEveryPage(12 pages),Tokens_resolve_inADocumentWithPageReferences_whichMeasuresAgain,Page_printsTheLabel_whenTheDocumentDefinesLabelRangesZones_swapSides_onEvenPages_andNotOnOddOnes,EvenMeans_thePhysicalPage_notTheLabel_withRomanFrontMatterAndADecimalBody, and the two negative casesARuleBelowAHeader_isDrawnOnEveryPage_atTheExactCoordinatesAndWidth,ARuleAboveAFooter_liesOnTheBandsTopEdge_inTheMirroredMarginsOfItsPageALogo_isScaledToTheBandsHeight_atItsZonesEdge_asDecoration,ALogoInEachZone_standsAtThatZonesPlaceALongCentre_yieldsToTheRightZone_...,ALongLeft_yieldsToTheRightZone_...,ACentreNextToALogo_...,Zones_neverOverprint_...(120 random rounds)*Refuses*and*refuses*tests inBandZonesTestsALabelAndANumber_inTwoRuns_...(the reported case: "Page " and "{page}" on page 12 draw "Page"),ATokenAtARunBoundary_...,AChapterTitle_isNotCutAtASpaceInsideIt_...,ARunBoundaryWithNoSpace_*,AZoneCutAcrossRuns_neverPrintsAPartOfATokenValue_...(150 random splits)AZoneThatMeasuresZero_standsAtItsSidesEdge_insideTheContentBox(Symbol, margins 0 and 20)BandZonesRuleRenderTests(pdftoppm: no dark pixel in the rule's rows, at the minimum and the default height, above and below, Helvetica and Times),ALogoBesideARule_..., the oracle fixture's logo matrixBandZonesByteIdentityTests(144 string-band documents, recorded onorigin/mainbefore the change), a 1,500-document generator (random page sizes, margins, mirrored margins, tagged, PDF/A-2u, PDF/UA-1, Standard 14 and embedded fonts, tokens, alignments, heights, truncation, strict) whose output, truncation reports and diagnostic codes are identical onorigin/mainand here, and the existing goldensBandZonesOracleTests: veraPDF2uandua1pass on a document with a three-zone header, a logo and rules; qpdf clean; pdftotext reads the zonesMutations
Each was run in a detached worktree and fails the named tests. The first four are the original set; the rest
cover the changes made after review. The runner's environment includes the JDK, as veraPDF needs it.
Zones_swapSides_onEvenPages_andNotOnOddOnes,ALongLeft_yieldsToTheRightZone_andTheCutZoneStaysTheLeftOneWhenZonesSwap,EvenMeans_thePhysicalPage_notTheLabel_withRomanFrontMatterAndADecimalBody{chapter}in the centre zone not resolvedTokens_resolveInEveryZone_onEveryPage,EvenMeans_thePhysicalPage_...ARuleBelowAHeader_isDrawnOnEveryPage_...,ARuleAboveAFooter_liesOnTheBandsTopEdge_...Zones_neverOverprint_...,ACentreNextToALogo_...,ALongCentre_yieldsToTheRightZone_...ALabelAndANumber_inTwoRuns_...,ALiteralSpaceAfterAToken_...,ALongCentre_...,ARunBoundaryWithNoSpace_...and othersATokenAtARunBoundary_...,AChapterTitle_isNotCutAtASpaceInsideIt_...,AZoneCutAcrossRuns_...ARunBoundaryWithNoSpace_inAZoneWithNoSpace_cutsInsideTheRunAndNotAtTheBoundaryASecondRunThatOverflows_...,Zones_neverOverprint_...(zones of one to three runs) and 13 moreAZoneThatMeasuresZero_standsAtItsSidesEdge_insideTheContentBoxStandard14, unpaired surrogate, tiny font size acceptedAZone_refusesAStandard14Value...,AZone_refusesAnUnpairedSurrogate_inAnyFont,AZone_refusesAFontSizeThatIsWrittenAsZeroALogoBesideARule_...,ARuleThatTheHeightCannotHold_..., the exact-baseline tests, the oracle fixtureALogoBesideARule_..., the oracle fixtureALogoLeftAndALogoAtTheCentre_keepTheGap_atItsBoundaryAStringBandsRule_isInsideTheArtifactMarkedContent_ofATaggedDocumentATruncationWarning_namesThePageThatLostTheMost,ALabelAndANumber_...ARule_isDrawnOnEveryPage_whereTheZonesDrawNothingGates
Release build 0 warnings;
Layout.TestsRelease on net10.0 and net11.0, 4,386 tests each, 0 failed, 2 skippedeach (the named-pipe tests, which skip on Windows);
dotnet format --verify-no-changes; clean-room check;generate-roadmap.py --check. Oracles were required (REQUIRE_ORACLES=1,REQUIRE_VERAPDF=1, veraPDF 1.30.4,qpdf 12.4.2).
Not in this change
Per-section bands (#286) and
/Subtype /Header|/Footer|/PageNumartifact property lists (#303).